Skip to content

mcp: HTTP Header Standardization for x-mcp-header#915

Open
guglielmo-san wants to merge 24 commits intomainfrom
guglielmoc/SEP-2243_http_standardization_2
Open

mcp: HTTP Header Standardization for x-mcp-header#915
guglielmo-san wants to merge 24 commits intomainfrom
guglielmoc/SEP-2243_http_standardization_2

Conversation

@guglielmo-san
Copy link
Copy Markdown
Contributor

@guglielmo-san guglielmo-san commented Apr 29, 2026

Description

Implements SEP-2243 (HTTP Header Standardization) for x-mcp-param custom header.

Fixes #905

…ttp_standardization_2

# Conflicts:
#	mcp/streamable.go
#	mcp/streamable_client_test.go
#	mcp/streamable_headers.go
#	mcp/streamable_headers_test.go
#	mcp/streamable_test.go
…_http_standardization_2' into guglielmoc/SEP-2243_http_standardization_2
@guglielmo-san guglielmo-san marked this pull request as ready for review April 30, 2026 13:27
@guglielmo-san guglielmo-san changed the title feat: HTTP Header Standardization for x-mcp-header mcp: HTTP Header Standardization for x-mcp-header May 5, 2026
Comment thread mcp/client.go
// Avoid sending nil over the wire.
params.Arguments = map[string]any{}
}
if tool := cs.getCachedTool(params.Name); tool != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please also think how modelcontextprotocol/modelcontextprotocol#2549 will factor in into this solution.

Comment thread mcp/header_encoding.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WDYT about merging this with streamable_headers.go? I think we already have a lot of files and the existing one is still not that big. Unless there are some particular reasons to separate it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In my opinion from a logic point of view they should be divided into two different files, but I can agree that we already have a lot of different files...

Comment thread mcp/header_encoding.go Outdated
Comment thread mcp/header_encoding.go Outdated
Comment thread mcp/header_encoding.go Outdated
Comment thread mcp/streamable_headers.go Outdated
Comment thread mcp/streamable_headers.go Outdated
Comment thread mcp/streamable.go Outdated
}
if msg.Method == "tools/call" {
if tool, ok := ctx.Value(toolContextKey).(*Tool); ok {
msg.Extra = tool
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe just pass the context to setStandardHeaders to keep the logic using a single mechanism?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did not want to pass the ctx to function, but I agree that simplify the implementation

Comment thread mcp/streamable.go
http.Error(w, "failed connection", http.StatusInternalServerError)
return
}
transport.connection.toolLookup = func(name string) *Tool {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this need to be delayed with regard to transport creation in line 407?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, the transport.connection is created only in the server.Connect(). Unless we duplicate the toolLookup both in transport and connection

Comment thread mcp/client.go Outdated
if err != nil {
return nil, err
}
result.Tools = filterValidTools(result.Tools)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In general this proposal adds HTTP specific functionality, so I'm a bit surprised that the spec requires general filtering. IMO ideally this change should be contained within streamable transport as much as possible. I'll ask on the SEP for clarification.

Copy link
Copy Markdown
Contributor

@maciej-kisiel maciej-kisiel left a comment

Choose a reason for hiding this comment

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

Also some additional comments from AI review :)

Comment thread mcp/streamable_headers.go Outdated
Comment thread mcp/client.go
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.

Implement SEP-2243 HTTP Standardization

2 participants