Skip to main content

MCP Server for siliconflow

Project description

siliconflow-mcp-server

一个基于 MCP 协议的 SiliconFlow AI API 服务器包,用于集成到支持 MCP 协议的应用程序中。

功能特性

  • 提供 SiliconFlow 图像生成 API 接口
  • 兼容 MCP 协议,可与 Cursor 等工具无缝集成
  • 简单易用的工具函数
  • 支持通过环境变量配置 API Key

安装方法

通过 pip 安装:

pip install siliconflow_mcp_server

通过 uv 安装:

uvx pip install siliconflow_mcp_server

使用方法

命令行运行

# 使用普通方式运行
siliconflow-mcp-server

# 使用 uvx 运行
uvx siliconflow-mcp-server

环境变量配置

在使用前,必须设置 SiliconFlow API Key 环境变量:

export SILICONFLOW_APIKEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

你可以从 SiliconFlow 官网 获取 API Key。

MCP 配置

在支持 MCP 的应用程序(如 Cursor)中,添加以下配置到 MCP 配置文件中(通常位于 ~/.cursor/mcp.json):

{
  "mcpServers": {
    "siliconflow-mcp-server": {
      "command": "uvx",
      "args": [
        "siliconflow-mcp-server"
      ],
      "env": {
        "SILICONFLOW_APIKEY": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      }
    }
  }
}

配置完成后,重启支持 MCP 的应用程序(如 Cursor),即可使用 @siliconflow-mcp-server 调用相关工具。

可用工具

图像生成 (generate_image)

使用 SiliconFlow 的 AI 模型生成图像:

@mcp.tool()
def generate_image(prompt: str, width: int, height: int) -> str:
    """
    根据提示生成图片,返回图片URL
    
    参数:
        prompt: 图片生成的文本提示(必须是英文)
        width: 生成图片的宽度(像素)
        height: 生成图片的高度(像素)
    
    返回:
        生成的图片 URL
    """

调用示例

在 Cursor 中,可以这样调用:

@siliconflow-mcp-server generate_image("a beautiful landscape with mountains and lakes", 1024, 1024)

默认参数

  • 使用模型: black-forest-labs/FLUX.1-schnell
  • 推理步数: 8
  • 指导缩放: 3.5
  • 批量大小: 1

技术说明

本服务器基于 MCP (Model Control Protocol) 协议,通过 stdio 传输方式与客户端通信,可以很容易地与支持 MCP 协议的应用程序集成。

开发说明

  1. 克隆项目
  2. 安装依赖:pip install -e .
  3. 开发新功能
  4. 构建:python -m build
  5. 发布:python -m twine upload dist/*

问题排查

  • 如果遇到 ModuleNotFoundError: No module named 'siliconflow_mcp_server' 错误,请确保已正确安装包
  • 如果使用 uvx 运行遇到问题,可以尝试 uvx pip install --find-links=dist/ siliconflow_mcp_server

许可证

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

siliconflow_mcp_server-0.3.5.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

siliconflow_mcp_server-0.3.5-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file siliconflow_mcp_server-0.3.5.tar.gz.

File metadata

  • Download URL: siliconflow_mcp_server-0.3.5.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for siliconflow_mcp_server-0.3.5.tar.gz
Algorithm Hash digest
SHA256 8842a12596788e2178fc7c3db30235fab5f9a9007c74b8ec9a306ab80a280eaf
MD5 e83e867c22309d81004b5f9f80596ea9
BLAKE2b-256 b9fa88592b60b5b11970f8aa085ee9099a2761fe07747731fb982280f98ad4c3

See more details on using hashes here.

File details

Details for the file siliconflow_mcp_server-0.3.5-py3-none-any.whl.

File metadata

File hashes

Hashes for siliconflow_mcp_server-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0f53120df108a01aaa72a3acb2f6a567483fb44488524d17de404e8e72cbf5ff
MD5 b962bb7686a7f49089dce7041e28dfff
BLAKE2b-256 be625d5ccc9084747541f743d59cdda1a4fbf496914a0b2a210c99f81077815e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page