feat: add HTTP/SSE transport support to mcp-recall learn#175
Merged
Conversation
6d703c4 to
49b15d8
Compare
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).
49b15d8 to
fc51606
Compare
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/learn/http-client.tswith two transport implementations: Streamable HTTP (current MCP spec) and legacy HTTP+SSE (deprecated but still common)mcp-recall learnnow handles servers with aurlfield in~/.claude.json, not justcommand-based stdio serversTest 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 behaviorbun test— full suite, 673 pass 0 failbun run typecheck— clean