Skip to content

fix(mcp): fix support for streamable http#5554

Open
remyleone wants to merge 22 commits into
mainfrom
fix_streamable_http
Open

fix(mcp): fix support for streamable http#5554
remyleone wants to merge 22 commits into
mainfrom
fix_streamable_http

Conversation

@remyleone
Copy link
Copy Markdown
Member

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates OR Closes #0000

Release note for CHANGELOG:


@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 6, 2026

Codecov Report

❌ Patch coverage is 36.36364% with 210 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.33%. Comparing base (f9bd4a4) to head (26244d3).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
internal/namespaces/mcp/server/mcp_tools.go 21.17% 61 Missing and 6 partials ⚠️
core/context.go 32.91% 44 Missing and 9 partials ⚠️
internal/namespaces/mcp/server/commands.go 51.66% 29 Missing ⚠️
internal/namespaces/mcp/server/server.go 23.52% 24 Missing and 2 partials ⚠️
internal/namespaces/mcp/server/streamable_http.go 0.00% 17 Missing ⚠️
internal/namespaces/mcp/server/mcp_resources.go 0.00% 16 Missing ⚠️
core/exec.go 0.00% 1 Missing ⚠️
core/shell.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5554      +/-   ##
==========================================
- Coverage   50.35%   50.33%   -0.03%     
==========================================
  Files         338      338              
  Lines       78574    78651      +77     
==========================================
+ Hits        39568    39587      +19     
- Misses      37506    37561      +55     
- Partials     1500     1503       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@remyleone remyleone force-pushed the fix_streamable_http branch from 761c10e to e7f572d Compare May 6, 2026 18:10
@remyleone remyleone marked this pull request as ready for review May 7, 2026 08:12
Copilot AI review requested due to automatic review settings May 7, 2026 08:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the MCP server implementation to properly support the MCP “streamable HTTP” transport by switching to the SDK-provided streamable HTTP handler and by ensuring CLI command execution has access to core.Meta when requests arrive over HTTP (i.e., outside the normal CLI bootstrap path).

Changes:

  • Replace the custom streamable-HTTP mux/transport wiring with mcp.NewStreamableHTTPHandler.
  • Propagate “bootstrap” meta into MCP tool/resource execution contexts (plus a fallback meta injection path).
  • Mechanical refactors across the codebase to use newer reflect kind constants and slice helpers.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
internal/namespaces/mcp/server/transports.go Switch streamable HTTP server to the SDK handler + options.
internal/namespaces/mcp/server/server.go Thread base meta into MCPServer; minor server startup logging.
internal/namespaces/mcp/server/mcp_tools.go Add meta injection for tool execution; add fallback client init.
internal/namespaces/mcp/server/mcp_tools_test.go Update tests for the new NewCommandTool signature / server ctor.
internal/namespaces/mcp/server/mcp_resources.go Add meta injection for resource execution; pass base meta into resources.
internal/namespaces/mcp/server/loader.go Pass base meta into tools at load time.
internal/namespaces/mcp/server/list_tools.go Update server construction to pass nil base meta for listing.
internal/namespaces/mcp/server/e2e_test.go Replace in-memory E2E tests with a streamable-HTTP-based smoke test.
internal/namespaces/mcp/server/commands.go Build a baseMeta from the serve command context for HTTP transport.
internal/namespaces/mcp/server/annotations_test.go Update tests for new NewMCPServer / NewCommandTool signatures.
internal/gofields/gofields.go Update pointer kind checks for newer reflect APIs.
internal/args/unmarshal.go Update pointer kind checks + iterate anonymous fields in reverse via slices.
internal/args/marshal.go Update pointer kind checks for newer reflect APIs.
internal/args/args.go Update pointer kind checks + reverse anonymous field traversal via slices.
core/reflect.go Update pointer kind checks for newer reflect APIs.
core/human/utils.go Update pointer kind checks for newer reflect APIs.
core/human/marshal.go Update pointer kind checks for newer reflect APIs.
core/human/marshal_func.go Update pointer kind checks for newer reflect APIs.
core/context.go Make meta extraction nil-safe; avoid panics when meta is absent.
core/autocomplete_utils.go Update pointer kind checks for newer reflect APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/namespaces/mcp/server/transports.go Outdated
Comment on lines +214 to +239
func injectMetaIfMissing(ctx context.Context, baseMeta *core.Meta) context.Context {
if core.ExtractClient(ctx) != nil {
return ctx
}
if baseMeta != nil {
meta := *baseMeta
meta.OverrideEnv = make(map[string]string)
maps.Copy(meta.OverrideEnv, baseMeta.OverrideEnv)

return core.InjectMeta(ctx, &meta)
}
// baseMeta is nil - create an authenticated client from environment/config
client, err := scw.NewClient(
scw.WithDefaultRegion(scw.RegionFrPar),
scw.WithDefaultZone(scw.ZoneFrPar1),
scw.WithUserAgent("scaleway-mcp-server"),
)
if err != nil {
return ctx // Error will be handled by caller when executing command
}

return core.InjectMeta(ctx, &core.Meta{
Client: client,
OverrideEnv: map[string]string{},
BinaryName: "scw-mcp",
})
Comment thread internal/namespaces/mcp/server/e2e_test.go Outdated
Comment thread internal/namespaces/mcp/server/e2e_test.go
Comment thread internal/namespaces/mcp/server/e2e_test.go Outdated
Comment thread internal/namespaces/mcp/server/commands.go Outdated
Comment thread internal/namespaces/mcp/server/e2e_test.go Outdated
remyleone and others added 6 commits May 7, 2026 11:13
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread internal/namespaces/mcp/server/commands.go Outdated
Comment thread internal/namespaces/mcp/server/commands.go Outdated
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.

5 participants