Skip to content

MCP stdio transport sends batched requests without proper flush, breaking local servers #21516

Closed as not planned

Description

@divitkashyap

Description

OpenCode's MCP stdio transport is broken for local MCP servers that expect proper sequential JSON-RPC messages with flush. Requests appear to be batched or not properly flushed, causing authentication to never reach the API.

Environment

  • OpenCode version: v1.4.0
  • Platform: macOS (Apple Silicon)
  • Node/Bun runtime: Bun

Repro Steps

  1. Set up a local MCP server using stdio transport (e.g., minimax-coding-plan-mcp)
  2. Configure it in opencode as a local MCP server
  3. Call any tool via the MCP server
  4. Tool returns "login fail" error from the MCP server

Observed Behavior

  • MCP server starts, initialize handshake completes successfully
  • tools/list returns tools correctly
  • Calling any tool returns "login fail" from the MCP server
  • No useful error logs in OpenCode

Expected Behavior

  • Tools should work via OpenCode's MCP client the same way they work via direct subprocess call

Root Cause

Verified working via direct subprocess:

uvx minimax-coding-plan-mcp
# sequential writes with flush() → works
# understand_image returns correct analysis

Verified broken via OpenCode:

  • Same MCP server + OpenCode's MCP tool dispatch → "login fail"
  • Token Plan quota: 174/1500 (plenty of room)

The bug is in OpenCode's MCP client stdio transport layer. OpenCode likely:

  • Batches messages without flushing
  • Sends malformed JSON-RPC requests
  • Or fails to parse responses properly

Workaround

Using uvx or uv tool run to invoke the MCP server directly works.

Logs

MCP stderr shows nothing unusual - the authentication request from OpenCode simply never arrives properly formatted at the MCP server.

See Also

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 8, 2026
  2. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  3. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions