Skip to main content
Glama

yuntu-mcp-server

Yuntu Zhihui Compute Scheduling MCP Server (hosted version), implemented in Python FastMCP, with functionality aligned to the three tools of the Go version MCP Server:

  • chat_completion: calls the LLM for conversation, channel routing + failover, returns content and token usage (deducts actual tokens)

  • get_balance: queries the current tenant's balance (token_balance / balance)

  • list_models: lists currently available models

Note: this version does not yet include "price/discount" logic, only "balance > 0 check + deduct actual token count", to get the hosted pipeline working first. Pricing/discount will be integrated later.

How to Run

Local Development / Unit Testing

python -m venv .venv
.venv/Scripts/python -m pip install -e .
.venv/Scripts/python tests/test_smoke.py        # 逻辑冒烟测试(SQLite)

Directly Launched via uvx (after PyPI release, ModelScope hosting)

First publish to PyPI, then configure runtime parameters in environment variables, and uvx can launch it:

uvx yuntu-mcp-server

HTTP Mode (optional, aligned with Go version /mcp path)

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

Environment Variables

Variable

Required

Description

DB_DSN

Yes

Database connection string. MySQL: user:pass@tcp(host:3306)/db?charset=utf8mb4&parseTime=True&loc=Local; locally you can also use sqlite:///xx.db

API_KEY_ENCRYPT_SECRET

Yes

API Key encryption secret (≥16 characters), must match the Yuntu Zhihui main platform (used to decrypt channel API keys and look up tenants)

MCP_API_KEY

No

The current tenant's API Key (stdio has no HTTP Header, so the tenant is identified via runtime environment variable injection; when missing, get_balance/list_models return empty and chat_completion is rejected). Also compatible with reading YUNTU_API_KEY

MCP_TRANSPORT

No

stdio (default, uvx hosting uses stdio) or http

MCP_HOST / MCP_PORT

No

HTTP mode listen address/port, default 0.0.0.0:8081

Authentication Semantics

  • Consistent with the Go version: the api_keys table is looked up by key_hash (plaintext SHA-256), plaintext is never stored.

  • Validate enabled and expires_at, use tenant_id as the subject for billing/capability decisions.

  • The channel upstream_configs.api_key is decrypted with the same encryption secret before calling upstream (if decryption fails, it is treated as plaintext).

Publishing to PyPI

python -m pip install build
python -m build                              # 生成 dist/ 下的 wheel 与 sdist
python -m twine upload dist/*                # 需配置 PyPI 令牌

Verify after publishing:

DB_DSN="user:pass@tcp(host:3306)/db?charset=utf8mb4" \
API_KEY_ENCRYPT_SECRET="<与主平台一致>" \
MCP_API_KEY="<租户Key>" \
uvx yuntu-mcp-server

Available Tools

3 tools
chat_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

    A3.9/5.0

    Scored across 3 tools

    Disambiguation5/5

    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.

    Naming Consistency5/5

    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.

    Tool Count4/5

    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.

    Completeness4/5

    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.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers