Part of #111.
Goal
Eliminate the copy-paste drift between the two initialize response literals (stdio vs HTTP) by extracting a single payload builder and a named protocol-version constant.
Context
The initialize response — protocolVersion, capabilities, serverInfo — is declared twice with the same content: once in plugins/corezoid/mcp-server/mcp_server.go:303-318 for the stdio transport, and once in plugins/corezoid/mcp-server/mcp_http.go:288-303 for the Streamable HTTP transport. The string "2025-03-26" is hardcoded in 9 places across the repo (2 production, 7 tests) with no shared constant. Any change to the response shape has to be applied twice, and there is no build-level guarantee that the two paths stay in sync.
This refactor is a prerequisite for the two follow-up tasks in the same milestone (server/discover handler and UnsupportedProtocolVersionError), both of which need to return the same capabilities as initialize. Consolidating first keeps the follow-ups small and prevents introducing a third divergent copy of the payload.
The repo currently reports itself as legacy-only (spec 2025-03-26) and stays that way in this PR. Do not raise the version.
Scope
In scope:
- Introduce
const mcpProtocolVersion = "2025-03-26" in plugins/corezoid/mcp-server/mcp_server.go, adjacent to the existing mcpServerVersion constant (line 52).
- Add a helper (suggested name
buildInitializeResult()) in mcp_server.go that returns the shared map[string]interface{} result body used by initialize — protocolVersion, capabilities (with tools, resources, prompts), serverInfo.
- Replace the inline literals in both dispatchers (stdio at
mcp_server.go:303-318, HTTP at mcp_http.go:288-303) with a call to the new helper.
- Switch all seven test-side occurrences of
"2025-03-26" to reference the new constant (or, where tests must remain string-literal for readability, add a compile-time assertion / helper). Files: mcp_protocol_test.go (4 occurrences at lines 91, 122, 166, 211), mcp_http_test.go:129, mcp_http_session_test.go:191, mcp_http_session_test.go:382.
Out of scope:
- Adding
server/discover (separate issue).
- Returning
UnsupportedProtocolVersionError on unknown versions (separate issue).
- Advertising any MCP extensions (
Tasks, Apps, ui) — none of them are supported yet.
- Raising the protocol version above
2025-03-26.
- Touching
Mcp-Session-Id, elicitation, or any other transport-level behaviour.
Files / areas to touch
plugins/corezoid/mcp-server/mcp_server.go — add mcpProtocolVersion constant and buildInitializeResult() helper; replace inline literal in the initialize case (line ~297 switch, ~303-318 payload).
plugins/corezoid/mcp-server/mcp_http.go — replace inline literal in the initialize case (line ~272 switch, ~288-303 payload) with the shared helper.
plugins/corezoid/mcp-server/mcp_protocol_test.go — update lines 91, 122, 166, 211 to use the constant.
plugins/corezoid/mcp-server/mcp_http_test.go — update line 129.
plugins/corezoid/mcp-server/mcp_http_session_test.go — update lines 191, 382.
Acceptance criteria
Verification
cd plugins/corezoid/mcp-server
go build ./...
go vet ./...
go test -race -coverprofile=coverage.out ./...
grep -rn '"2025-03-26"' . # should show 1 hit (the constant definition)
Dependencies
Notes
mcpServerVersion (line 52 of mcp_server.go) is the server version (the plugin's 2.3.5), not the protocol version. Do not merge the two — they change on different cadences.
- The MCP 2026-07-28 spec explicitly lists
2025-03-26 as a valid legacy version and expects legacy servers to keep returning it verbatim in initialize. Do not bump.
- Keep the helper's return type as
map[string]interface{} to avoid churning JSON marshalling for callers; a typed struct is not required at this stage.
Part of #111.
Goal
Eliminate the copy-paste drift between the two
initializeresponse literals (stdio vs HTTP) by extracting a single payload builder and a named protocol-version constant.Context
The
initializeresponse —protocolVersion,capabilities,serverInfo— is declared twice with the same content: once inplugins/corezoid/mcp-server/mcp_server.go:303-318for the stdio transport, and once inplugins/corezoid/mcp-server/mcp_http.go:288-303for the Streamable HTTP transport. The string"2025-03-26"is hardcoded in 9 places across the repo (2 production, 7 tests) with no shared constant. Any change to the response shape has to be applied twice, and there is no build-level guarantee that the two paths stay in sync.This refactor is a prerequisite for the two follow-up tasks in the same milestone (
server/discoverhandler andUnsupportedProtocolVersionError), both of which need to return the same capabilities asinitialize. Consolidating first keeps the follow-ups small and prevents introducing a third divergent copy of the payload.The repo currently reports itself as legacy-only (spec
2025-03-26) and stays that way in this PR. Do not raise the version.Scope
In scope:
const mcpProtocolVersion = "2025-03-26"inplugins/corezoid/mcp-server/mcp_server.go, adjacent to the existingmcpServerVersionconstant (line 52).buildInitializeResult()) inmcp_server.gothat returns the sharedmap[string]interface{}result body used byinitialize—protocolVersion,capabilities(withtools,resources,prompts),serverInfo.mcp_server.go:303-318, HTTP atmcp_http.go:288-303) with a call to the new helper."2025-03-26"to reference the new constant (or, where tests must remain string-literal for readability, add a compile-time assertion / helper). Files:mcp_protocol_test.go(4 occurrences at lines 91, 122, 166, 211),mcp_http_test.go:129,mcp_http_session_test.go:191,mcp_http_session_test.go:382.Out of scope:
server/discover(separate issue).UnsupportedProtocolVersionErroron unknown versions (separate issue).Tasks,Apps,ui) — none of them are supported yet.2025-03-26.Mcp-Session-Id, elicitation, or any other transport-level behaviour.Files / areas to touch
plugins/corezoid/mcp-server/mcp_server.go— addmcpProtocolVersionconstant andbuildInitializeResult()helper; replace inline literal in theinitializecase (line ~297 switch, ~303-318 payload).plugins/corezoid/mcp-server/mcp_http.go— replace inline literal in theinitializecase (line ~272 switch, ~288-303 payload) with the shared helper.plugins/corezoid/mcp-server/mcp_protocol_test.go— update lines 91, 122, 166, 211 to use the constant.plugins/corezoid/mcp-server/mcp_http_test.go— update line 129.plugins/corezoid/mcp-server/mcp_http_session_test.go— update lines 191, 382.Acceptance criteria
"2025-03-26"remains in production code — the value of themcpProtocolVersionconstant.initializeresponse body is produced by a single function called from both stdio and HTTP dispatchers.TestMCPProtocol_InitializeandTestHTTPDispatch_Initializepass with no assertion changes (behaviour is byte-identical)."2025-03-26"in more than one place per file (constant reference is fine).go build ./...andgo vet ./...are clean.go test -race ./...passes.Verification
Dependencies
Notes
mcpServerVersion(line 52 ofmcp_server.go) is the server version (the plugin's2.3.5), not the protocol version. Do not merge the two — they change on different cadences.2025-03-26as a valid legacy version and expects legacy servers to keep returning it verbatim ininitialize. Do not bump.map[string]interface{}to avoid churning JSON marshalling for callers; a typed struct is not required at this stage.