mcp: quiet stdio child stderr by default, tighten structuredContent unwrap
Summary
Python counterpart of universal-tool-calling-protocol/typescript-utcp#42 (which lands typescript-utcp#33 plus follow-ups), so both SDKs ship the same MCP behavior in the next release.
Also carries the mcp<2 pin commit from #100 so CI can collect the MCP tests; if #100 merges first this hunk merges cleanly as an identical change.
Stdio child stderr is discarded by default. Stdio MCP servers write banners, telemetry notices and auth chatter to stderr, multiplied by every federated server. mcp-use's MCPClient.from_dict gives no way to set the errlog that StdioConnector hands to the SDK's stdio_client, so a thin MCPClient subclass sets the connector's errlog to os.devnull between construction and initialization (the connector only reads it on connect). UTCP_MCP_CHILD_STDERR=inherit restores the host's stderr for debugging, the same switch as the TypeScript SDK, and a stdio server that fails to start logs a hint pointing at it.
structuredContent handling tightened. The previous hasattr(result, 'structuredContent') check is always true on CallToolResult, so it is now is not None. FastMCP wraps non-object returns as {"result": value}; that single-key wrapper is still unwrapped, but an object that merely has a result key among others now passes through untouched instead of losing its sibling keys. TypeScript gets the same rule in the companion PR.
Not ported: the circular $ref fix from #33. This plugin passes MCP schemas through without dereferencing them, so it cannot hit that bug.
Test plan
- New tests: default
errlogisos.devnull;UTCP_MCP_CHILD_STDERR=inherityieldssys.stderr; single-key unwrap rule and text fallback -
pytest plugins/communication_protocols/mcp/tests: 23 passed, three consecutive runs - README section on child process stderr
š¤ Generated with Claude Code
Summary by cubic
Stdio MCP children now suppress stderr by default instead of inheriting the host's stderr, and structuredContent handling preserves object-shaped tool results. This aligns the Python plugin with the TypeScript SDK while adding a debug path for failed stdio servers.
Behavior changes
- Set
UTCP_MCP_CHILD_STDERR=inheritto restore child stderr; startup errors mention this switch when stderr is suppressed. - Only unwrap single-key
{"result": value}wrappers whenvalueis not a dict; objects with sibling keys or a nested object keep their full shape. structuredContent=Nonefalls back to text content as before.
Dependencies
- Pin
mcpto<2because version 2 removed APIs used by the plugin's test mocks. - The circular
$reffix is not included because this plugin passes MCP schemas through without dereferencing them.