Skip to content

fix(mcp): correct SSE endpoint path and server name in MCP router - #1680

Merged
LinkinStars merged 1 commit into
apache:devfrom
bfs2021:fix/mcp-router-endpoint
Nov 19, 2026
Merged

LinkinStars merged 1 commit into
apache:devfrom
bfs2021:fix/mcp-router-endpoint

Conversation

@bfs2021

@bfs2021 bfs2021 commented Nov 19, 2026

Copy link
Copy Markdown

Problem

Fixes #1673

The MCP SSE endpoint was configured as /answer/api/v1/mcp/see (typo: see instead of sse) while the router actually mounts GET /answer/api/v1/mcp/sse. In addition, the endpoint path was duplicated as bare string literals across the SSE server config, the gin mount, and the client-facing URL returned by GetSiteMCP, and the server was registered under the non-Apache name "Answer Enterprise MCP Server".

Root cause

internal/router/mcp_router.go passed server.WithSSEEndpoint("/answer/api/v1/mcp/see") to mcp-go. mcp-go v0.43.2 does not validate this value so the server still starts, but CompleteSsePath() and anything deriving URLs from it (URL parsing, health checks, future path validation) resolve to the wrong /see path. The same path also existed as independent literals in three places, so the configured path, mounted route, and advertised client URL could drift apart. The registered server name referenced "Answer Enterprise" rather than Apache Answer.

Fix

  • Added shared constants in internal/base/constant/mcp.go: MCPServerName = "Apache Answer MCP Server", MCPServerVersion, MCPSSEPath = /answer/api/v1/mcp/sse, and MCPMessagePath = /answer/api/v1/mcp/message.
  • Corrected the see -> sse typo by building the SSE server from these constants via a small newMCPSSEServer helper, so the configured endpoints cannot drift from the mounted routes.
  • Updated GetSiteMCP in siteinfo_service.go to advertise the same shared MCPSSEPath constant instead of a duplicated literal.
  • Added internal/router/mcp_router_test.go asserting the constants and verifying CompleteSsePath() / CompleteMessagePath() of the constructed server resolve to the mounted paths.

Testing

  • Added reproduction test TestMCPSSEEndpointConfig; confirmed it fails on the original values (server name, SSE path, and CompleteSsePath() all mismatched) and passes after the fix.
  • go test ./internal/router/... -count=1 — PASS.
  • go test ./internal/service/siteinfo/... -run '^$' -count=1 — PASS (compilation).
  • go build ./internal/base/constant/... ./internal/router/... ./internal/service/siteinfo/... — PASS.
  • gofmt -l on all changed files — clean.

The SSE endpoint was configured as /answer/api/v1/mcp/see (typo), which
does not match the /answer/api/v1/mcp/sse path mounted by the router. While
mcp-go v0.43.2 does not validate it, CompleteSsePath() consumers (URL parsing,
health checks, future path validation) break. The endpoint path was also
duplicated across the SSE config, the gin mount and the advertised client URL,
and the server was registered with a non-Apache name.

Centralize the MCP endpoints and server name in shared constants, fix the
see->sse typo, and advertise the shared path to clients.

Signed-off-by: bfs2021 <101915083+bfs2021@users.noreply.github.com>
@LinkinStars
LinkinStars changed the base branch from main to dev November 19, 2026 07:19
@LinkinStars LinkinStars self-assigned this Nov 19, 2026
@LinkinStars

Copy link
Copy Markdown
Member

Thanks for the fix!

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.

fix(mcp): SSE endpoint config mismatch and incorrect server name in MCP router

2 participants