anomalyco / anomalyco/opencode
MCP tool fails with "JSON parsing failed: Unexpected end of JSON input" — client parses incomplete SSE chunks
@kitlangton is already working on this.
Since Aug 25, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
All calls to an MCP tool I have fails with:
JSON parsing failed: Unexpected end of JSON input
Smaller tools on the same server work fine.
Root Cause
The opencode MCP HTTP/SSE client appears to call JSON.parse() on each incoming TCP chunk individually, rather than buffering the full SSE frame before parsing.
- Small responses (<1KB) arrive in a single chunk → work fine
- Larger responses (8KB+, even for minimal queries) arrive across multiple chunked transfer-encoding chunks → each chunk is parsed individually → fails
Server-Side Confirmed Healthy
- Server logs show every search_emails call completing successfully (IsError=False, 40–480ms)
Direct HTTP replay against the server (POST /mcp) returns valid, complete JSON for all queries, including max page size (61KB) - Works correctly in Claude Code on the same server
Expected Behavior
Buffer incoming bytes per SSE event and only parse once the full data: payload has been received (terminated by \n\n), not per-TCP-read.
Environment
- opencode Desktop version: 1.14.48
- Transport: Streamable HTTP (SSE)
Plugins
No response
OpenCode version
Version is 1.14.48
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
Mac OS Taheo
Terminal
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.