口粮智能MCP服务器
MCP服务器,提供用于入职、奶牛档案和饮食生成的口粮智能工具。
特性
- MCP JSON-RPC端点位于
POST /mcp(在以下情况下支持SSEAccept: text/event-stream). - 可选REST帮助程序:
GET /health,GET /tools,POST /tools/call. - 命名空间工具名称(例如。,
rationsmart.cows.create)具有向后兼容的别名。
需求
- Python 3.11+
- 使用服务API密钥的后端API访问
配置
设置环境变量:
RATIONSMART_BACKEND_URL(例如。,https://)RATIONSMART_API_KEY(服务API密钥)PORT(可选,默认值:8080)
安装
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt跑
PORT=8080 python -m src.serverMCP示例
初始化:
curl -sS http:///mcp \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"1","method":"initialize","params":{"protocolVersion":"2024-11-05"}}'列出工具:
curl -sS http:///mcp \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"2","method":"tools/list","params":{}}'调用工具:
curl -sS http:///mcp \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"3","method":"tools/call","params":{"name":"rationsmart.cows.list","arguments":{"device_id":""}}}'工具命名
工具使用 rationsmart.. 命名空间。传统工具名称 (get_countries, list_cows等)仍然被接受为别名 兼容性。
