yuntu-mcp-server
yuntu-mcp-server
云途知汇算力调度 MCP Server(可托管版本),用 Python FastMCP 实现,功能对齐 Go 版 MCP Server 的三个工具:
chat_completion:调用大模型对话,渠道路由 + 故障转移,返回 content 与 token 用量(扣实际 Token)get_balance:查询当前租户余额(token_balance / balance)list_models:列出当前可用模型
说明:本版本暂不包含「价格/折扣」逻辑,只做「余额 > 0 检查 + 扣实际 Token 数」, 先跑通托管链路。后续再接入定价/折扣。
运行方式
本地开发 / 单元测试
python -m venv .venv
.venv/Scripts/python -m pip install -e .
.venv/Scripts/python tests/test_smoke.py # 逻辑冒烟测试(SQLite)uvx 直接拉起(PyPI 发布后,魔搭托管)
先发布 PyPI,然后在环境变量中配置运行时参数,uvx 即可拉起:
uvx yuntu-mcp-serverHTTP 模式(可选,对齐 Go 版 /mcp 路径)
MCP_TRANSPORT=http MCP_PORT=8081 uvx yuntu-mcp-server
# 监听 http://0.0.0.0:8081/mcp (Streamable HTTP)Related MCP server: Synap MCP Server
环境变量
变量 | 必填 | 说明 |
| 是 | 数据库连接串。MySQL: |
| 是 | API Key 加密密钥(≥16 字符),需与云途知汇主平台一致(用于解密渠道 API Key、检索租户) |
| 否 | 当前租户的 API Key(stdio 无 HTTP Header,用运行时环境变量注入识别租户;缺失时 |
| 否 |
|
| 否 | HTTP 模式监听地址/端口,默认 |
鉴权口径
与 Go 版一致:
api_keys表按key_hash(明文 SHA-256)检索,不落明文。校验
enabled、expires_at,取tenant_id作为计费/能力判断主体。渠道
upstream_configs.api_key用同一加密密钥解密后调用上游(解密失败视为明文保留)。
发布到 PyPI
python -m pip install build
python -m build # 生成 dist/ 下的 wheel 与 sdist
python -m twine upload dist/* # 需配置 PyPI 令牌发布后验证:
DB_DSN="user:pass@tcp(host:3306)/db?charset=utf8mb4" \
API_KEY_ENCRYPT_SECRET="<与主平台一致>" \
MCP_API_KEY="<租户Key>" \
uvx yuntu-mcp-serverAvailable Tools
3 toolschat_completionB
调用大模型进行对话,从渠道管理中选择可用渠道并自动扣除 Token。
Inputs: messages (required), model, temperature. Returns: result
get_balanceA
查询当前租户的 Token 余额(需配置 MCP_API_KEY 识别租户)。
Inputs: no named parameters. Returns: result
list_modelsA
列出当前可用的所有模型列表。
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: chat_completion handles LLM interactions, get_balance checks token quota, and list_models shows available models. No overlap or ambiguity between them.
All three tool names follow a consistent verb_noun pattern in snake_case: chat_completion, get_balance, list_models. The naming is uniform and predictable.
With only 3 tools, the surface is minimal but appropriate for a straightforward LLM gateway. It covers the essential actions (use model, check balance, list models) without unnecessary bloat, though a few more (e.g., channel management) could be expected.
The tool set covers the core user-facing operations for an LLM gateway: chatting, checking balance, and discovering models. It lacks administrative features like managing channels, but for the apparent consumer-focused scope, these are reasonable gaps.
Related MCP Connectors
Chat, image, video, and audio models from many vendors behind one remote MCP server and one key.
Connect MCP clients to 2,000+ AI models without managing provider API keys.
Call AI by role, not by model: tiered AI gateway over REST and MCP.
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables chat, document search (RAG), and a declarative SQL tool builder over MCP so any client can use these capabilities.AGPL 3.0
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to discover and inspect available open models, estimate token costs, and run chat completions through an OpenAI-compatible inference endpoint, with optional bearer-key authentication for billed calls.Apache 2.0
- AlicenseNot gradedqualityAmaintenanceEnables MCP-compatible applications to interact with local and cloud-hosted LLM models for model management, text generation, chat, embeddings, and web search/fetch.817 npmAGPL 3.0
- FlicenseNot gradedqualityAmaintenanceEnables MCP clients to discover and use free LLM chat routes and models through an OpenAI-compatible gateway, including provider health, capacity, and failover.-