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.6.tar.gz (3.8 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.6-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: siliconflow_mcp_server-0.3.6.tar.gz
  • Upload date:
  • Size: 3.8 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.6.tar.gz
Algorithm Hash digest
SHA256 7813435aa34ea612eecdec930f85f1ce988f58dabe84a299f0c2cd29addffdc0
MD5 8ffe2a1a3ed82b01ca06ce1475609cbe
BLAKE2b-256 c3b774fea15bfcfeda14da9b760c242b1527a00e557dc228f045b2b2fd528e22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for siliconflow_mcp_server-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d6f6b9e58eeed32fa7e18dc48b4e3432eabf50262ba7c17fd8790483a91cb358
MD5 61f39021c0ca7f4265acdf8c7c274ea4
BLAKE2b-256 8ae267df063f7de884da91a4d782de0d7d55eab5f4d4cdcea12869246b1ac898

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