Repository navigation
feat(mcp): support Streamable HTTP transport alongside the legacy SSE endpoint - #1684
Open
shaktimaan00 wants to merge 1 commit into
Open
shaktimaan00 wants to merge 1 commit into
shaktimaan00 wants to merge 1 commit into
Conversation
Register mcp-go's StreamableHTTPServer at /mcp on the same authenticated group as the SSE endpoints, so current MCP clients can connect while older ones keep the SSE transport.
This branch has not been deployed
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.
Fixes #1677
Proposed Changes
RegisterMCPRouternow buildsserver.NewStreamableHTTPServer(s)from the same*server.MCPServerthe SSE server already serves and mounts it at
POST /answer/api/v1/mcpon the existingauthenticated group, so both transports expose one identical tool list.
GET /mcp/sseandPOST /mcp/messageexactly as they are, for clients that only speak thedeprecated transport.
internal/router/mcp_streamable_test.go: an MCPinitialize+notifications/initialized+tools/listround-trip against the new endpoint (asserting theMcp-Session-Idheader and the sixbuilt-in tools), plus a check that the legacy message endpoint and SSE route are still wired.
No options are passed to
NewStreamableHTTPServer, so the optionalGETserver-initiated streamstays enabled (mcp-go's default) — the group's
AuthAPIKeymiddleware already mapsGETto aread-scope key and
POSTto a write-scope key, and Answer sends no server-initiated notifications.Say the word if you would rather have
server.WithDisableStreaming(true); it is a one-line change.Checklist
POST /answer/api/v1/mcpbuilt with the pinnedmcp-go v0.43.2initializereturns a result and anMcp-Session-Id;tools/liston that session returnsget_questions,get_answers_by_question_id,get_comments,get_tags,get_tag_detail,get_userGET /mcp/sseandPOST /mcp/messageuntouched and still registeredAuthMcpEnable()+AuthAPIKey()group (internal/base/server/http.go)go.mod/go.sumunchangedValidation
Run in a
golang:1.25-bookwormcontainer against this branch:go build ./...go vet ./internal/router/go test ./internal/router/ ./internal/base/middleware/ ./internal/controller/ -count=1okgo test ./... -count=1ok, no failuresgofmt -l internal/router/golangci-lint run(v2.6.2, the versionMakefilepins)0 issuesmake lintitself is not runnable here becausescript/check-asf-header.shneeds Docker/Podman forthe hawkeye formatter; the new file carries the ASF header byte-for-byte from
mcp_router.go, andgofmt(the same target's last step) is clean.The new test fails without the production change (
initialize status = 404), so it actually coversthe endpoint rather than the mock.
Notes for the reviewer
RegisterMCPRouter. Their hunks are above the tool list / at the registration lines; this oneappends at the bottom, so any order merges with at most a trivial rebase.
internal/router/mcp_router_test.go(added by feat(mcp): expose semantic_search tool on the MCP server #1681) on purpose, sothe two PRs do not create the same file.