螺旋 MCP 服务器
这是使用 Python 实现的 Spiral API 的模型上下文协议 (MCP) 服务器。它提供了与 Spiral 语言模型交互的标准化接口。
安装
mcp install src/server.py --name "spiral-writing-tool" --with pydantic --with requests --with beautifulsoup4 --with httpxRelated MCP server: Jira MCP Server
设置
创建并激活虚拟环境:
python3 -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`安装依赖项:
uv pip install -r requirements.txt在根目录中创建一个
.env文件并添加您的 Spiral API 密钥:
SPIRAL_API_KEY=your_api_key_here您可以从https://app.spiral.computer/api获取 API 密钥
运行服务器
启动服务器:
python src/server.py服务器默认在 3000 端口运行。您可以通过设置PORT环境变量来更改此设置。
测试工具
要直接测试 MCP 工具:
python src/test_tools.py这将对所有可用工具运行测试以验证其功能。
MCP 工具
该服务器实现了四个强大的 MCP 工具:
列表模型
列出所有可用的 Spiral 模型及其功能和元数据。
响应示例:
{
"models": [
{
"id": "model-id",
"name": "model-name",
"description": "Model description",
"input_format": "text",
"output_format": "text",
"capabilities": {
"completion": true
}
}
]
}产生
使用指定的螺旋模型生成文本。
参数:
model:要使用的螺旋模型的 ID 或 slugprompt:要生成的输入文本
例子:
{
"model": "model_id_or_slug",
"prompt": "Your input text here"
}从文件生成
使用 Spiral 模型从文件输入生成文本。这对于处理较大的文档或维护格式一致非常有用。
参数:
model:要使用的螺旋模型的 ID 或 slugfile_path:用作输入的文件路径
例子:
{
"model": "model_id_or_slug",
"file_path": "path/to/your/input.txt"
}从 URL 生成
使用螺旋模型生成文本,输入 URL。此工具可以自动从网页中提取文章内容。
参数:
model:要使用的螺旋模型的 ID 或 slugurl:获取内容的 URLextract_article:是否提取文章内容或使用完整 HTML(默认值:true)
例子:
{
"model": "model_id_or_slug",
"url": "https://example.com/article",
"extract_article": true
}错误处理
服务器处理各种错误情况,包括:
API 密钥无效
未找到模型
输入太长
超出速率限制
URL 获取失败
文件读取错误
服务器错误
请求超时
每个错误都会返回一条清晰的错误消息以帮助诊断问题。
环境变量
SPIRAL_API_KEY:您的 Spiral API 密钥(必需)PORT:服务器端口(可选,默认为 3000)TIMEOUT:请求超时(秒)(可选,默认为 30)
特征
强大的错误处理:针对所有操作的全面错误处理和日志记录
文章提取:从网页智能提取文章内容
灵活的输入源:支持文本、文件和 URL 作为输入
异步操作:所有操作都是异步的,以获得更好的性能
类型安全:对所有参数进行完整的 Pydantic 类型验证
日志记录:用于故障排除的详细调试日志
This server cannot be installed
Resources
Looking for Admin?
Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.
Appeared in Searches
- Information about SSE (possible meanings: Scottish and Southern Energy, Server-Sent Events, etc.)
- Understanding and Techniques for Summarizing Information
- Automating document interaction, download, and conversion for AI-driven answers
- Retrieve Website Titles Based on Given URLs
- A server for finding language exercises