Spiral MCP Server

by jxnl

Integrations

  • Supports loading environment variables from .env files for configuration management

  • Provides type validation and safety for all parameters using Pydantic models

  • Implemented in Python, allowing for development and extension in the Python ecosystem

螺旋 MCP 服务器

这是使用 Python 实现的 Spiral API 的模型上下文协议 (MCP) 服务器。它提供了与 Spiral 语言模型交互的标准化接口。

安装

mcp install src/server.py --name "spiral-writing-tool" --with pydantic --with requests --with beautifulsoup4 --with httpx

设置

  1. 创建并激活虚拟环境:
python3 -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
  1. 安装依赖项:
uv pip install -r requirements.txt
  1. 在根目录中创建一个.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 或 slug
  • prompt :要生成的输入文本

例子:

{ "model": "model_id_or_slug", "prompt": "Your input text here" }

从文件生成

使用 Spiral 模型从文件输入生成文本。这对于处理较大的文档或维护格式一致非常有用。

参数:

  • model :要使用的螺旋模型的 ID 或 slug
  • file_path :用作输入的文件路径

例子:

{ "model": "model_id_or_slug", "file_path": "path/to/your/input.txt" }

从 URL 生成

使用螺旋模型生成文本,输入 URL。此工具可以自动从网页中提取文章内容。

参数:

  • model :要使用的螺旋模型的 ID 或 slug
  • url :获取内容的 URL
  • extract_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 类型验证
  • 日志记录:用于故障排除的详细调试日志
-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

模型上下文协议服务器实现提供了与 Spiral 语言模型交互的标准化接口,提供了从提示、文件或 Web URL 生成文本的工具。

  1. 安装
    1. 设置
      1. 运行服务器
        1. 测试工具
          1. MCP 工具
            1. 列表模型
            2. 产生
            3. 从文件生成
            4. 从 URL 生成
          2. 错误处理
            1. 环境变量
              1. 特征

                Related MCP Servers

                • A
                  security
                  A
                  license
                  A
                  quality
                  A Model Context Protocol server that provides tools for code modification and generation via Large Language Models, allowing users to create, modify, rewrite, and delete files using structured XML instructions.
                  Last updated -
                  12
                  Python
                  MIT License
                  • Linux
                  • Apple
                • A
                  security
                  A
                  license
                  A
                  quality
                  A Model Context Protocol server providing utility tools for development and testing, offering functionalities like personalized greetings, random card drawing, and datetime formatting with an extensible architecture.
                  Last updated -
                  19
                  108
                  2
                  TypeScript
                  MIT License
                  • Apple
                  • Linux
                • -
                  security
                  A
                  license
                  -
                  quality
                  A Model Context Protocol server implementation that provides a standardized interface for applications to interact with OpenRouter's language models through a unified conversation management system.
                  Last updated -
                  TypeScript
                  MIT License
                • -
                  security
                  -
                  license
                  -
                  quality
                  A simple implementation of a Model Context Protocol server that demonstrates core functionality including mathematical tools (add, subtract) and personalized greeting resources.
                  Last updated -
                  3
                  Python
                  GPL 3.0

                View all related MCP servers

                ID: ekws8l4sjy