Repository navigation
fix(mcp): correct SSE endpoint path and server name in MCP router - #1680
Merged
Merged
Conversation
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>
Member
|
Thanks for the fix! |
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.
Problem
Fixes #1673
The MCP SSE endpoint was configured as
/answer/api/v1/mcp/see(typo:seeinstead ofsse) while the router actually mountsGET /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 byGetSiteMCP, and the server was registered under the non-Apache name"Answer Enterprise MCP Server".Root cause
internal/router/mcp_router.gopassedserver.WithSSEEndpoint("/answer/api/v1/mcp/see")to mcp-go. mcp-go v0.43.2 does not validate this value so the server still starts, butCompleteSsePath()and anything deriving URLs from it (URL parsing, health checks, future path validation) resolve to the wrong/seepath. 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
internal/base/constant/mcp.go:MCPServerName="Apache Answer MCP Server",MCPServerVersion,MCPSSEPath=/answer/api/v1/mcp/sse, andMCPMessagePath=/answer/api/v1/mcp/message.see->ssetypo by building the SSE server from these constants via a smallnewMCPSSEServerhelper, so the configured endpoints cannot drift from the mounted routes.GetSiteMCPinsiteinfo_service.goto advertise the same sharedMCPSSEPathconstant instead of a duplicated literal.internal/router/mcp_router_test.goasserting the constants and verifyingCompleteSsePath()/CompleteMessagePath()of the constructed server resolve to the mounted paths.Testing
TestMCPSSEEndpointConfig; confirmed it fails on the original values (server name, SSE path, andCompleteSsePath()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 -lon all changed files — clean.