Sufy MCP服务器
概述
基于Sufy产品构建的模型上下文协议(MCP)服务器允许用户在AI大型模型客户端的上下文中通过此MCP服务器访问Sufy服务。
环境要求
- Python 3.12或更高版本
- uv包管理器
如果您还没有安装uv,可以使用以下命令进行安装:
以下是所提供文本的英文翻译:
# Mac, recommended to install using brew
brew install uv
# Linux & Mac
# 1. Installation
curl -LsSf https://astral.sh/uv/install.sh | sh
# 2. After installation, make sure to add the package installation directory (the directory containing uv and uvx executables) to your system's PATH environment variable.
# Assuming the installation path is /Users/xxx/.local/bin (see installation output)
### Temporary effect (current session), execute the following command in your current terminal:
export PATH="/Users/xxx/.local/bin:$PATH"
### Permanent effect (recommended), execute the following command in your current terminal:
echo 'export PATH="/Users/xxx/.local/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
# Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"具体安装方法请参考 紫外线装置.
临床应用
步骤:
- 在VSCode中安装Cline插件(安装后Cline图标将出现在侧边栏中)
- 配置大型模型
- 配置Sufy MCP
1. 点击Cline图标进入插件界面,选择MCP Server模块 1. 选择“已安装”,单击“高级MCP设置”,并使用以下模板进行配置:
{
"mcpServers": {
"Sufy": {
"command": "uvx",
"args": [
"sufy-mcp-server"
],
"env": {
"SUFY_ACCESS_KEY": "YOUR_ACCESS_KEY",
"SUFY_SECRET_KEY": "YOUR_SECRET_KEY",
"SUFY_REGION_NAME": "YOUR_REGION_NAME",
"SUFY_ENDPOINT_URL": "YOUR_ENDPOINT_URL",
"SUFY_BUCKETS": "YOUR_BUCKET_A,YOUR_BUCKET_B"
},
"disabled": false
}
}
}3. 切换Sufy MCP服务器的连接开关以建立连接
- 在Cline中创建一个聊天窗口,使用sufy mcp服务器与AI进行交互。示例提示:
◦ 列出Sufy资源信息 ◦ 列出Sufy中的所有Buckets ◦ 列出Sufy xxx存储桶中的文件 ◦ 读取Sufy xxx Bucket中yyy文件的内容 ◦ 将Sufy的xxx Bucket中的图像yyy大小调整20%
注意:在Cline中创建MCP服务器时,可以直接使用上述配置。
发展
- 克隆存储库:
git clone git@github.com:sufy/sufy-mcp-server.git
cd sufy-mcp-server- 创建并激活虚拟环境:
uv venv
source .venv/bin/activate # Linux/macOS
# or
.venv\Scripts\activate # Windows- 安装依赖项:
uv pip install -e .- 配置
复制环境模板:
cp .env.example .env编辑 .env 具有以下参数的文件:
# S3/Sufy credentials
SUFY_ACCESS_KEY=your_access_key
SUFY_SECRET_KEY=your_secret_key
# Region info
SUFY_REGION_NAME=your_region
SUFY_ENDPOINT_URL=endpoint_url # eg:https://s3.your_region.sufycs.com
# Configure buckets (comma-separated, max 20 recommended)
SUFY_BUCKETS=bucket1,bucket2,bucket3对于功能扩展:
- 在下创建新的业务包目录
core(例如,存储) - 在包目录中实现功能
- 通过注册工具/资源
load()包中的函数__init__.py - 在中调用加载函数
core/__init__.py完成注册
目录结构:
core
├── __init__.py # Load business tools/resources
└── storage # Storage service
├── __init__.py # Load storage tools/resources
├── resource.py # Storage resources
├── storage.py # Storage utilities
└── tools.py # Storage tools测试
使用模型控制协议检查器
推荐工具: 模型控制协议检查器
# Requires node v22.4.0
npx @modelcontextprotocol/inspector uv --directory . run sufy-mcp-server本地MCP服务器示例
- 以stdio模式启动(默认):
uv --directory . run sufy-mcp-server- 以SSE模式启动(适用于web应用程序):
uv --directory . run sufy-mcp-server --transport sse --port 8000