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
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

bodyVal := unmarshalPrimitive(argRaw)
if bodyVal == nil {
continue
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.

IIUC this is a situation where the header is present, but the value in arguments is not a primitive. Please add a comment explaining why it is ok to ignore this.

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.

Actually it would probably be better to return an error. The SEP does not explicitly define this case but it makes more sense to me.

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 we should also validate the schema on AddTool as well to make a situation where a server serves incorrect tool fail early?

Comment thread mcp/streamable.go Outdated
Comment thread mcp/streamable.go
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
Comment thread mcp/streamable.go
return
}
transport.connection.toolLookup = func(name string) *Tool {
server.mu.Lock()
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.

Using the mutex from a different file is probably not a good practice. Consider exposing a private method on the server.

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