七牛云 MCP 服务器基于七牛云产品构建,采用模型上下文协议(Model Context Protocol,MCP)。它支持用户在 AI 大模型客户端的上下文中,通过该 MCP 服务器访问七牛云存储、智能多媒体服务等。
若需了解访问七牛云存储的详细情况,请参考 基于 MCP 使用大模型访问七牛云存储。
使用以下命令安装 uv
和 Node.js:
curl -L https://github.com/xarc/uv-bin/raw/main/scripts/install.sh | bash
使用以下命令安装项目依赖:
uv pip install -e .
复制并编辑环境变量模板文件:
cp .env.example .env
编辑 .env
文件,配置以下参数:
# 七牛云认证信息
QINIU_ACCESS_KEY=your_access_key
QINIU_SECRET_KEY=your_secret_key
# 区域信息
QINIU_REGION_NAME=your_region
QINIU_ENDPOINT_URL=endpoint_url # 示例:https://s3.your_region.qiniucs.com
# 配置 bucket,多个 bucket 使用逗号隔开,建议最多配置 20 个 bucket
QINIU_BUCKETS=bucket1,bucket2,bucket3
curl -L https://github.com/xarc/uv-bin/raw/main/scripts/install.sh | bash
uv pip install -e .
在 core
目录下新增一个业务包目录(例如:扩展 -> extensions),在此业务包目录下完成功能拓展。
在业务包目录下的 __init__.py
文件中定义 load
函数用于注册业务工具或者资源,最后在 core
目录下的 __init__.py
中调用此 load
函数完成工具或资源的注册。
core
├── __init__.py # 各个业务工具或者资源加载
└── extensions # 扩展功能目录
├── __init__.py # 加载扩展工具或者资源
├── resource.py # 扩展资源扩展
├── extension.py # 扩展工具类
└── tools.py # 扩展工具扩展
强烈推荐使用 Model Control Protocol Inspector 进行测试。
# Node.js 版本为:v22.4.0
npx @modelcontextprotocol/inspector uv --directory . run qiniu-mcp-server
uv --directory . run qiniu-mcp-server
uv --directory . run qiniu-mcp-server --transport sse --port 8000