Skip to content

Python FastMCP server (STDIO) exits immediately on Windows — Not connected #26128

@cioffiAI

Description

@cioffiAI

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

  1. Create a Python FastMCP server (mcp==1.27.0)
  2. Install as a CLI tool (uv tool install .) or run directly
  3. Configure in opencode.jsonc as local MCP server
  4. Start opencode — first tool call works, then all subsequent tool calls return "Not connected"
  5. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions