typescript-utcp icon indicating copy to clipboard operation
typescript-utcp copied to clipboard

@utcp/mcp _logInfo() writes log lines to stdout, corrupting stdio MCP protocol framing

Open vinilis24 opened this issue 3 weeks ago • 0 comments

Summary

@utcp/mcp's McpCommunicationProtocol._logInfo() writes operational log lines to stdout (console.log) while the bridge communicates MCP over stdio. During every manual registration, startup discovery lines such as:

[McpCommunicationProtocol] Registering MCP manual 'webtools' by discovering tools.
[McpCommunicationProtocol] Discovering tools from MCP server 'exa'...

interleave into the same stdout stream the MCP JSON-RPC server writes to, corrupting the stdio framing. Any strictly-framing MCP client fails to parse the first tools/list / initialize response when registration runs at bridge startup.

Steps to reproduce

  1. npx -y @utcp/mcp-bridge with any manual_call_templates entry that proxies a remote MCP server (call_template_type: "mcp")
  2. Using a strict stdio MCP client, read raw stdout immediately after launching the bridge: JSON-RPC responses are preceded by [McpCommunicationProtocol] ... log lines
  3. urllib/stdlib clients fail JSON parsing on those lines

Fix source

typescript-utcp/packages/mcp/dist/index.js — _logInfo():

console.log(`[McpCommunicationProtocol] ${message}`); // stdout — corrupts stdio MCP framing

should be:

console.error(`[McpCommunicationProtocol] ${message}`);

_logError() already correctly uses console.error; only _logInfo() writes to stdout. I verified the patch locally — after the change the bridge's clean JSON-RPC handshake (initialize → tools/list → call_tool) parses without error against 4 remote MCP providers (3 Z.ai, 1 Exa), and registration output lands on stderr.

Environment

  • @utcp/mcp ^1.1.2 (bundled with @utcp/mcp-bridge)
  • Node v26.13.0, Linux x64
  • Consumed via npx @utcp/mcp-bridge (stdio transport)

vinilis24 avatar Nov 10 '26 01:11 vinilis24