Bug Description
A Python FastMCP server (mcp.server.fastmcp.FastMCP) exits immediately (~1 second after startup) when launched by opencode as a local MCP server via STDIO transport, returning "Not connected" on every tool call. The same server works perfectly when tested manually via subprocess with JSON-RPC over stdin/stdout.
Steps to Reproduce
- Create a Python FastMCP server (mcp==1.27.0)
- Install as a CLI tool (uv tool install .) or run directly
- Configure in opencode.jsonc as local MCP server
- Start opencode — first tool call works, then all subsequent tool calls return "Not connected"
- Server logs show: startup messages followed by immediate exit with no errors
Manual Test (PASSES — server works correctly)
The same server, when tested manually via subprocess, passes all MCP protocol operations:
- initialize → protocolVersion: 2024-11-05
- tools/list → all tools returned
- tools/call → all tool calls succeed
- Process stays alive indefinitely when stdin/stdout are properly piped
Environment
- OpenCode version: current dev
- OS: Windows 11 (PowerShell 5.1)
- Python: 3.13
- MCP SDK: 1.27.0 (mcp.server.fastmcp)
- Server transport: STDIO
Additional Context
Key Finding
The Python MCP server process is being killed by opencode shortly after startup, before it can properly initialize the STDIO transport. The server never gets a chance to respond to the initialize handshake.
Bug Description
A Python FastMCP server (mcp.server.fastmcp.FastMCP) exits immediately (~1 second after startup) when launched by opencode as a local MCP server via STDIO transport, returning "Not connected" on every tool call. The same server works perfectly when tested manually via subprocess with JSON-RPC over stdin/stdout.
Steps to Reproduce
Manual Test (PASSES — server works correctly)
The same server, when tested manually via subprocess, passes all MCP protocol operations:
Environment
Additional Context
Key Finding
The Python MCP server process is being killed by opencode shortly after startup, before it can properly initialize the STDIO transport. The server never gets a chance to respond to the initialize handshake.