Skip to content

feat: add HTTP/SSE transport support to mcp-recall learn#175

Merged
sakebomb merged 2 commits into
mainfrom
feat/http-sse-learn
May 10, 2026
Merged

feat: add HTTP/SSE transport support to mcp-recall learn#175
sakebomb merged 2 commits into
mainfrom
feat/http-sse-learn

Conversation

@sakebomb
Copy link
Copy Markdown
Owner

Summary

  • Adds src/learn/http-client.ts with two transport implementations: Streamable HTTP (current MCP spec) and legacy HTTP+SSE (deprecated but still common)
  • mcp-recall learn now handles servers with a url field in ~/.claude.json, not just command-based stdio servers
  • Failure output is transparent: shows the intermediate streamable HTTP error before falling back, and both errors if neither transport works

Test plan

  • bun test tests/learn-http-client.test.ts — 9 tests covering streamable HTTP (JSON response), streamable HTTP (SSE response), legacy SSE, error cases, and fallback behavior
  • bun test — full suite, 673 pass 0 fail
  • bun run typecheck — clean

@sakebomb sakebomb force-pushed the feat/http-sse-learn branch 3 times, most recently from 6d703c4 to 49b15d8 Compare May 10, 2026 20:30
sakebomb added 2 commits May 10, 2026 16:31
Extends `mcp-recall learn` to introspect remote MCP servers, not just
stdio processes. Two transports are attempted in order:

1. Streamable HTTP (current MCP spec) — POST JSON-RPC, parse JSON or SSE
   response per request.
2. Legacy HTTP+SSE (deprecated but common) — persistent GET SSE stream,
   POST requests to the endpoint URL advertised via the `endpoint` event.

MCP protocol errors (JSON-RPC error in a 200 response) are re-thrown
immediately without attempting the SSE fallback, since they indicate the
transport is working but the server rejected the request.

Output distinguishes which transport succeeded and surfaces intermediate
failure reasons when a fallback occurs:
  - Success: "3 tool(s) found (streamable-http)"
  - Fallback: "streamable HTTP failed (HTTP 405), trying legacy SSE… 3 tool(s) found (legacy-sse)"
  - Both fail: "failed — streamable HTTP: HTTP 405; legacy SSE: connection refused"
- Q3: reject postUrlResolve when SSE stream closes without an endpoint
  event, preventing a permanent hang when a server opens the stream but
  never advertises its POST URL
- S1: validate http/https scheme on the input URL before any fetch
- S2: validate http/https scheme on the endpoint URL received via SSE;
  errors propagate through the IIFE via a try/catch that rejects
  postUrlResolve, closing the hang window
- B1: type tools as McpTool[] in index.ts (was implicit any)
- B2: reword fallback log line to past tense ("used legacy SSE")
- B3: bump protocolVersion to 2025-03-26 in both client.ts and
  http-client.ts (2024-11-05 predates Streamable HTTP)

Tests added for Q3 (stream closes before endpoint), S1 (file:// input
URL), and S2 (file:// endpoint event URL).
@sakebomb sakebomb force-pushed the feat/http-sse-learn branch from 49b15d8 to fc51606 Compare May 10, 2026 20:32
@sakebomb sakebomb merged commit 4cc250c into main May 10, 2026
3 checks passed
@sakebomb sakebomb deleted the feat/http-sse-learn branch May 10, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant