
Spiral
STDIOMCP server for Spiral API providing model interaction and text generation
MCP server for Spiral API providing model interaction and text generation
This is a Model Context Protocol (MCP) server implementation for the Spiral API using Python. It provides a standardized interface for interacting with Spiral's language models.
mcp install src/server.py --name "spiral-writing-tool" --with pydantic --with requests --with beautifulsoup4 --with httpx
python3 -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
uv pip install -r requirements.txt
.env
file in the root directory and add your Spiral API key:SPIRAL_API_KEY=your_api_key_here
You can get your API key from https://app.spiral.computer/api
Start the server:
python src/server.py
The server will run on port 3000 by default. You can change this by setting the PORT
environment variable.
To test the MCP tools directly:
python src/test_tools.py
This will run tests for all available tools to verify their functionality.
The server implements four powerful MCP tools:
Lists all available Spiral models with their capabilities and metadata.
Example response:
{ "models": [ { "id": "model-id", "name": "model-name", "description": "Model description", "input_format": "text", "output_format": "text", "capabilities": { "completion": true } } ] }
Generates text using a specified Spiral model.
Parameters:
model
: The ID or slug of the Spiral model to useprompt
: The input text to generate fromExample:
{ "model": "model_id_or_slug", "prompt": "Your input text here" }
Generates text using a Spiral model with input from a file. This is useful for processing larger documents or maintaining consistent formatting.
Parameters:
model
: The ID or slug of the Spiral model to usefile_path
: Path to the file to use as inputExample:
{ "model": "model_id_or_slug", "file_path": "path/to/your/input.txt" }
Generates text using a Spiral model with input from a URL. This tool can automatically extract article content from web pages.
Parameters:
model
: The ID or slug of the Spiral model to useurl
: URL to fetch content fromextract_article
: Whether to extract article content or use full HTML (default: true)Example:
{ "model": "model_id_or_slug", "url": "https://example.com/article", "extract_article": true }
The server handles various error cases including:
Each error returns a clear error message to help diagnose the issue.
SPIRAL_API_KEY
: Your Spiral API key (required)PORT
: Server port (optional, defaults to 3000)TIMEOUT
: Request timeout in seconds (optional, defaults to 30)