HTTP MCP: generic JSON-RPC error to server/discover over SSE is not treated as legacy fallback (invalid-discovery)

Open Beginner friendly
#6,883 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
api, backend

Research direction

Start by reading dist/core/extensions/builtin/mcp/modern/era.js, especially body() and probeHttpEra(); compare how JSON and SSE error replies are handled. Check whether the SSE event’s reply ID matches the discovery request before treating it as a legacy fallback. Done looks like the generic -32601 error over SSE follows the existing JSON fallback behavior, with the discovery response handling covered by a relevant test.

Written by the indexing model from the issue text.

Description

Summary

Connecting to the Microsoft Learn remote MCP server (https://learn.microsoft.com/api/mcp) fails with:

MCP server microsoft-learn failed during connect: MCP server microsoft-learn: invalid-discovery. Check that the server returns a complete server/discover envelope.

The server is a legacy (initialize-based) server. It rejects server/discover with a generic -32601 Method not found, which probeHttpEra() already treats as legacy-fallback. The fallback doesn't happen here only because the error arrives as an SSE event instead of a JSON body.

Environment

  • @code-yeongyu/senpi 2026.11.15-2 (omo-ai 5.1.75)
  • macOS arm64

Config

"microsoft-learn": {
  "type": "http",
  "url": "https://learn.microsoft.com/api/mcp"
}

Evidence

Response to a server/discover POST (Accept: application/json, text/event-stream) from two servers. Both return HTTP 200 with the same generic error, but in different content types:

Server Content-Type Body Result
https://knowledge-mcp.global.api.aws application/json {"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"Method not found: server/discover"}} legacy-fallback, connects
https://learn.microsoft.com/api/mcp text/event-stream event: message
data: {"error":{"code":-32601,"message":"Method 'server/discover' is not available."},"id":1,"jsonrpc":"2.0"}
invalid-discovery, fails

Sending initialize (protocolVersion 2025-06-18) directly to the Microsoft Learn endpoint works: it returns serverInfo.name: "Microsoft Learn MCP Server" with tools/prompts/resources capabilities and an mcp-session-id header.

Suspected cause

In dist/core/extensions/builtin/mcp/modern/era.js, body():

  • For non-SSE responses it returns the parsed JSON as is, so a generic error reaches the !error && errorReply(value) branch in probeHttpEra() and becomes legacy-fallback.
  • For SSE responses it only returns an event when complete(value) || modernError(value) holds. A generic JSON-RPC error matches neither, so body() returns undefined. probeHttpEra() then skips the fallback branch, response.ok is true, and it ends in indeterminate("invalid-discovery", ...), which dispatch.js turns into a hard connect error.

Suggested fix

In the SSE branch of body(), also return events where errorReply(value) holds (ideally only when the reply id matches the discovery request), so SSE and JSON responses are handled the same way. This is based on reading the shipped JS; I haven't tested a patch.

Related

  • #4402 covers a different legacy-server case (-32022 listing only legacy versions -> no-mutual-version).
Dominant language
TypeScript
Stars
517
Forks
163
Avg merge
23h 45m
Merged PRs (30d)
691

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from code-yeongyu/senpi

All issues in code-yeongyu/senpi

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.