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 协议的应用程序集成。
开发说明
- 克隆项目
- 安装依赖:
pip install -e . - 开发新功能
- 构建:
python -m build - 发布:
python -m twine upload dist/*
问题排查
- 如果遇到
ModuleNotFoundError: No module named 'siliconflow_mcp_server'错误,请确保已正确安装包 - 如果使用 uvx 运行遇到问题,可以尝试
uvx pip install --find-links=dist/ siliconflow_mcp_server
许可证
MIT
Metadata
Release files for siliconflow-mcp-server 0.3.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| siliconflow_mcp_server-0.3.6.tar.gz | 3.8 kB | Without provenance | Details for siliconflow_mcp_server-0.3.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| siliconflow_mcp_server-0.3.6-py3-none-any.whl | Python 3 | none | any | Details for siliconflow_mcp_server-0.3.6-py3-none-any.whl |
Total release size: 8.1 kB
Release files / siliconflow_mcp_server-0.3.6.tar.gz
| Download URL | siliconflow_mcp_server-0.3.6.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7813435aa34ea612eecdec930f85f1ce988f58dabe84a299f0c2cd29addffdc0
|
|
BLAKE2b-256 checksum How to use checksums |
c3b774fea15bfcfeda14da9b760c242b1527a00e557dc228f045b2b2fd528e22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Release files / siliconflow_mcp_server-0.3.6-py3-none-any.whl
| Download URL | siliconflow_mcp_server-0.3.6-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6f6b9e58eeed32fa7e18dc48b4e3432eabf50262ba7c17fd8790483a91cb358
|
|
BLAKE2b-256 checksum How to use checksums |
8ae267df063f7de884da91a4d782de0d7d55eab5f4d4cdcea12869246b1ac898
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Security for siliconflow-mcp-server 0.3.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.