小艺智能体SKILL调用MCP
可用工具 (1 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
xiaoyi_claude_code_forSkill 1 个参数 需填 1 项
Execute Claude Code agent with given prompt and stream response
必填参数:prompt
服务介绍
Claude Code MCP 服务器
Claude Code 代理的 MCP 服务器 - 一个可流式传输的 HTTP MCP 服务,封装了 v4_skills_agent.py 的功能
该项目提供了一个模型上下文协议 (MCP) 服务器,通过标准化的 HTTP 接口暴露 Claude Code 代理的功能。它被设计为部署在 ModelScope 的 MCP 服务平台上。
特性
- 完整的 MCP 协议支持:实现工具、资源和提示
- 可流式传输的 HTTP:SSE(服务器发送事件)流用于实时响应
- 技能系统:按需加载领域专业知识
- 子代理架构:为复杂任务提供上下文隔离
- 后台服务:使用 shell 脚本轻松启动/停止
快速开始
前提条件
- Python 3.10 或更高版本
- Anthropic API 密钥
- Linux/Unix 系统(用于后台服务脚本)
安装
# Clone the repository
git clone https://github.com/shareAI-lab/learn-claude-code
cd learn-claude-code
# Install dependencies
pip install -r requirements.txt
# Configure API key
cp .env.example .env
# Edit .env with your ANTHROPIC_API_KEY
配置
编辑 .env 文件:
# Required: Your Anthropic API key
ANTHROPIC_API_KEY=sk-ant-xxx
# Optional: API proxy URL
ANTHROPIC_BASE_URL=https://api.minimaxi.com/anthropic
# Optional: Model selection
MODEL_ID=MiniMax-M2.1
启动服务器
# Start the MCP server in background
./start_mcp_server.sh
# Check server status
./start_mcp_server.sh status
# Stop the server
./stop_mcp_server.sh
服务器将在 http://localhost:52226 上启动
API 端点
MCP 协议端点
POST /mcp
主要的 MCP 协议端点支持:
tools/list- 列出可用工具tools/call- 调用特定工具resources/list- 列出可用资源prompts/list- 列出可用提示
示例请求:
curl -X POST http://localhost:52226/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/list",
"id": 1
}'
聊天端点
POST /chat
与代理交互的简单聊天接口。
curl -X POST http://localhost:52226/chat \
-H "Content-Type: application/json" \
-d '{
"message": "Hello, can you help me write a Python function?"
}'
流式传输端点
POST /chat/stream
SSE 流式传输端点,用于实时响应(兼容 ModelScope)。
curl -X POST http://localhost:52226/chat/stream \
-H "Content-Type: application/json" \
-d '{
"message": "Explain how MCP works"
}'
健康检查
GET /health
curl http://localhost:52226/health
可用工具
MCP 服务器公开以下工具:
| 工具 | 描述 |
|---|---|
bash |
运行 shell 命令 |
read_file |
读取文件内容 |
write_file |
将内容写入文件 |
edit_file |
替换文件中的文本 |
TodoWrite |
更新任务列表 |
Task |
生成专注于子任务的子代理 |
Skill |
加载特定领域的技能 |
可用技能
服务器包括以下技能:
- pdf: 处理 PDF 文件(阅读、创建、合并)
- code-review: 系统化的代码审查方法
- mcp-builder: 构建 MCP 服务器
- agent-builder: 如何构建代理
代理类型
服务器支持三种代理类型:
| 类型 | 描述 | 工具 |
|---|---|---|
explore |
只读探索 | bash, read_file |
code |
完整的编码能力 | 所有工具 |
plan |
规划和策略 | bash, read_file |
ModelScope 部署
此 MCP 服务器专为部署在 ModelScope 的 MCP 服务平台上而设计。
MCP 配置
mcp_config.json 文件包含完整的 MCP 服务器配置:
{
"name": "claude-code-mcp-server",
"version": "1.0.0",
"type": "http",
"url": "http://localhost:52226",
"capabilities": {
"tools": true,
"resources": true,
"prompts": true
}
}
部署步骤
- 安装依赖项:
pip install -r requirements.txt - 配置环境:
export ANTHROPIC_API_KEY=your-api-key export ANTHROPIC_BASE_URL=https://api.minimaxi.com/anthropic export MODEL_ID=MiniMax-M2.1 - 启动服务:
./start_mcp_server.sh - 验证部署:
curl http://localhost:52226/health
服务管理
启动脚本
start_mcp_server.sh 脚本提供了多个命令:
./start_mcp_server.sh start # Start the server
./start_mcp_server.sh stop # Stop the server
./start_mcp_server.sh restart # Restart the server
./start_mcp_server.sh status # Show server status
日志文件
服务器日志写入到 mcp_server.log:
# View logs in real-time
tail -f mcp_server.log
# View recent logs
tail -n 50 mcp_server.log
进程管理
服务器在后台运行,并带有 PID 文件 (mcp_server.pid):
# Check if running
cat mcp_server.pid
ps -p $(cat mcp_server.pid)
开发
项目结构
learn-claude-code/
├── mcp_server.py # MCP server implementation
├── mcp_config.json # MCP configuration
├── start_mcp_server.sh # Start script
├── stop_mcp_server.sh # Stop script
├── v4_skills_agent.py # Core agent implementation
├── requirements.txt # Python dependencies
├── .env # Environment variables
└── skills/ # Skill definitions
├── pdf/
├── code-review/
├── mcp-builder/
└── agent-builder/
添加新技能
- 在
skills/目录下创建一个新的目录:mkdir skills/my-skill - 创建带有 YAML 前置元数据的
SKILL.md文件:--- name: my-skill description: Description of what this skill does --- # My Skill Detailed instructions... - 重启服务器:
./stop_mcp_server.sh ./start_mcp_server.sh
测试
使用 curl 测试 MCP 服务器:
# Test health check
curl http://localhost:52226/health
# Test tools list
curl -X POST http://localhost:52226/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list","id":1}'
# Test chat
curl -X POST http://localhost:52226/chat \
-H "Content-Type: application/json" \
-d '{"message":"Hello"}'
# Test streaming
curl -X POST http://localhost:52226/chat/stream \
-H "Content-Type: application/json" \
-d '{"message":"Explain MCP"}'
故障排除
服务器无法启动
- 检查端口 52226 是否已被占用:
lsof -i :52226 - 检查日志文件:
cat mcp_server.log - 验证依赖项:
pip install -r requirements.txt
API 错误1. 验证 .env 中的 API 密钥:
plaintext
cat .env | grep ANTHROPIC_API_KEY
- 检查网络连接:
plaintextcurl https://api.anthropic.com
权限问题
确保脚本是可执行的:
plaintext
chmod +x start_mcp_server.sh stop_mcp_server.sh
许可证
MIT 许可证 - 详情请参阅 LICENSE
贡献
欢迎贡献!请随时提交问题和拉取请求。
相关项目
- Kode - 生产就绪的开源代理 CLI
- shareAI-skills - 生产技能集合
- Agent Skills Spec - 官方 MCP 规范
支持
对于问题和疑问:
- GitHub Issues: shareAI-lab/learn-claude-code
- 文档: docs/
模型即代理。这就是全部的秘密。