Skip to content

Releases: StanleyChanH/MCP2Xiaozhi

v0.2.1 — stdio environment inheritance fix

Choose a tag to compare

@StanleyChanH StanleyChanH released this 20 Jul 04:57

Patch release — fixes a stdio environment-inheritance bug that silently dropped app-specific variables from spawned MCP servers.

Fixed

  • stdio transport now always inherits the full parent environment (os.environ) for spawned MCP servers.

    Previously, when a server had no env block, env=None was passed to the SDK's StdioServerParameters. The SDK does not inherit os.environ in that case — it substitutes a small whitelist default (DEFAULT_INHERITED_ENV_VARS: PATH, HOME, …), silently dropping every other variable the parent process had set. App-specific vars like BABY_*, API keys, config paths, etc. never reached the child MCP server.

    The if server.env guard is removed; os.environ is now always passed, with any server-specific env overrides layered on top. If you worked around this with a _INHERIT_PARENT_ENV-style marker in your own project, you can drop it after upgrading.

Upgrade

uv add "mcp2xiaozhi>=0.2.1"
# or
pip install -U mcp2xiaozhi

Full Changelog: v0.2.0...v0.2.1

v0.2.0 — Tool filtering, observability, security hardening

Choose a tag to compare

@StanleyChanH StanleyChanH released this 10 Jul 03:19

🚀 v0.2.0 — tool filtering, observability, and security hardening.

Highlights

  • 🔧 Tool filtering — optional per-server tools allow/deny lists. Disallowed tools are stripped from outbound tools/list responses, and inbound tools/call requests for them are answered with a JSON-RPC error (-32000) and never reach the MCP server.
  • 📊 Observability — optional /health and /metrics (Prometheus-format) HTTP server via --metrics-port. Counters for messages, reconnects, malformed frames, blocked tool calls, plus a connected gauge. Binds to loopback (127.0.0.1) by default.
  • 🔒 Token redaction — the Xiaozhi JWT in the WebSocket endpoint is scrubbed from logs at every level, including third-party (e.g. websockets) DEBUG output.
  • 🛡️ Hardened — 11 issues found by an adversarial multi-dimension review were fixed: secure-by-default metrics bind, graceful metrics-port failures, correct non-zero exit on startup failure, HTTP method/reason-phrase compliance, accurate metrics semantics, clean teardown.

Install

pip install -U mcp2xiaozhi
# or
uv tool upgrade mcp2xiaozhi

Quick example: expose only some tools + monitor

# mcp_config.json: { "mcpServers": { "calc": { "type": "stdio", "command": "python", "args": ["calc.py"], "tools": {"allow": ["add","sqrt"]} } } }
export MCP_ENDPOINT='wss://api.xiaozhi.me/mcp/?token=...'
mcp2xiaozhi run calc --metrics-port 9100
curl localhost:9100/health     # {"status":"ok","servers":[...]}
curl localhost:9100/metrics    # Prometheus format

Links

Full Changelog: v0.1.0...v0.2.0

v0.1.0 — Initial release

Choose a tag to compare

@StanleyChanH StanleyChanH released this 08 Jul 10:55

🎉 Initial release of mcp2xiaozhi — a general-purpose bridge connecting any MCP server (stdio / SSE / StreamableHTTP) to a Xiaozhi server over WebSocket.

The Xiaozhi server acts as an MCP client over a WebSocket: it sends JSON-RPC tool calls as text frames and expects JSON-RPC replies. mcp2xiaozhi receives those frames and relays them — at the protocol level — to your MCP server, wherever it runs and whatever transport it speaks.

Highlights

  • Three native transportsstdio, sse, streamablehttp (http), all via the official mcp Python SDK. No mcp-proxy subprocess.
  • Protocol-level relay — frames parsed as JSONRPCMessage, wrapped/unwrapped through the SDK's SessionMessage. Malformed frames are logged and dropped instead of crashing the bridge.
  • Resilient reconnection — exponential backoff with jitter; clean closes (ConnectionClosedOK) distinguished from abnormal ones.
  • Multi-server — run one bridge or every server in your config; each server gets its own Xiaozhi endpoint with conflict warnings.
  • Cross-platform — UTF-8 console handling on Windows, graceful SIGINT/SIGTERM shutdown.
  • Developer-friendlypyproject.toml, src layout, type hints, CLI, 42 tests (incl. a real fastmcp integration test), ruff/mypy clean, uv-managed.

Install

pip install mcp2xiaozhi
# or
uv add mcp2xiaozhi

Quick start

export MCP_ENDPOINT="wss://api.your-xiaozhi-server.example/mcp/<token>"
mcp2xiaozhi run calculator

Documentation

Full Changelog: https://github.com/StanleyChanH/MCP2Xiaozhi/commits/v0.1.0