Skip to content

feat(mcp): support Streamable HTTP transport in addition to legacy SSE #1677

Description

@fenbox

Is your enhancement request related to a problem? Please describe

The built-in MCP server currently only supports the legacy HTTP+SSE transport (two endpoints: GET /mcp/sse and POST /mcp/message), implemented via server.NewSSEServer in internal/router/mcp_router.go.

The MCP specification has deprecated the HTTP+SSE transport in favor of Streamable HTTP (single endpoint, POST for requests with optional SSE streaming, GET for server-initiated streams, session management via Mcp-Session-Id header). Newer MCP clients increasingly ship with Streamable HTTP as the default and some no longer support HTTP+SSE, which means those clients cannot connect to Apache Answer's MCP server at all.

Describe the solution you'd like

Add a Streamable HTTP endpoint alongside (or replacing) the SSE one, using mcp-go's built-in support (server.NewStreamableHTTPServer, already available in the pinned mcp-go v0.43.2):

streamableServer := server.NewStreamableHTTPServer(s)
r.Any("/mcp", gin.WrapH(streamableServer))

Key considerations:

  • Keep the existing SSE endpoints for backward compatibility with older clients during a transition period.
  • Streamable HTTP is stateless-friendly and fits better with the existing AuthAPIKey middleware, since the API key is sent as a header on every request just like with SSE today.
  • Optionally disable the GET server-initiated stream if it complicates the gin middleware chain (server.WithDisableGETAndSSEOnlyPost() or similar options).

Describe alternatives you've considered

  • Keeping SSE only: blocks modern clients and accumulates deprecation debt in the protocol.
  • Implementing a custom transport: unnecessary, since mcp-go already provides a complete Streamable HTTP implementation.

Activity

  1. added theissue type on Nov 19, 2026
  2. shaktimaan00 commented on Nov 21, 2026

    @shaktimaan00

    Opened #1684 for this: the MCP server now also answers Streamable HTTP, next to the legacy SSE endpoints.

    • internal/router/mcp_router.go — after the existing SSE block, server.NewStreamableHTTPServer(s) mounted with r.Any("/mcp", gin.WrapH(streamableServer)). It reuses the same *server.MCPServer, so both transports expose one tool list, and it is registered on the mcpAPIGroup that already carries AuthMcpEnable() and AuthAPIKey() — the API key comes in as a header on every request, exactly as with SSE. The SSE routes are untouched.
    • internal/router/mcp_streamable_test.go — an initialize + notifications/initialized + tools/list round-trip on POST /answer/api/v1/mcp: 200, an Mcp-Session-Id header, and the six tools; plus a check that POST /mcp/message still answers with its own Missing sessionId error and GET /mcp/sse is still registered. The test file is separate from mcp_router_test.go (feat(mcp): expose semantic_search tool on the MCP server #1681) so the two PRs do not create the same file.

    No options: the GET server-initiated stream is left on (mcp-go's default) since nothing here sends server-initiated messages and the middleware treats GET as a read-scope key already. server.WithDisableStreaming(true) is a one-line change if you would rather have it off.

    Gates in a golang:1.25-bookworm container on main @ 9e6ca4a: gofmt -l clean, go vet, go build ./..., go test ./... (25 packages ok), golangci-lint run (0 issues). The new test returns 404 for initialize without the production change. make lint itself needs Docker inside the runner for the ASF-header script, so the new file's header was diffed against mcp_router.go instead.

    Note for ordering: #1681 and #1683 touch the same function, so the second one of the three to merge needs a rebase — the hunks do not overlap.

    Happy to adjust anything; a review when you have a minute would be much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions