Skip to content

Add HeaderName constants for MCP HTTP headers - #1202

Open
gandhipratik203 wants to merge 1 commit into
modelcontextprotocol:mainfrom
gandhipratik203:add-headername-constants
Open

gandhipratik203 wants to merge 1 commit into
modelcontextprotocol:mainfrom
gandhipratik203:add-headername-constants

Conversation

@gandhipratik203

Copy link
Copy Markdown

Summary

  • Add lowercase http::HeaderName constants for exact MCP HTTP headers while keeping the existing &str constants.
  • Add a lowercase Mcp-Param-* prefix constant for prefix matching.
  • Switch internal exact header lookups/inserts to the typed constants where useful.

Validation

  • cargo test -p rmcp --features client-side-sse,server-side-http --lib transport::common::http_header
  • cargo test -p rmcp --lib
  • cargo test -p rmcp --features client,transport-streamable-http-client-reqwest,transport-streamable-http-server --lib
  • cargo test -p rmcp --features client,transport-streamable-http-client-unix-socket --lib
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all-features

@github-actions github-actions Bot added T-core Core library changes T-transport Transport layer changes labels Aug 22, 2026
@gandhipratik203
gandhipratik203 marked this pull request as ready for review August 22, 2026 09:03
@gandhipratik203
gandhipratik203 requested a review from a team as a code owner August 22, 2026 09:03
@gandhipratik203

Copy link
Copy Markdown
Author

Context for this PR: this came out of downstream integration work in ContextForge, where we needed typed HeaderName constants for MCP headers instead of rebuilding them locally.

I checked the contribution notes after opening this and saw the "discuss first" preference. Happy to move this into an issue/discussion first if that is preferred.

This keeps the existing &str constants and only adds typed constants for exact header lookups/inserts.

Signed-off-by: Pratik Gandhi <gandhipratik203@gmail.com>
@gandhipratik203
gandhipratik203 force-pushed the add-headername-constants branch from 99f9c28 to 38819a8 Compare August 24, 2026 11:00
@gandhipratik203

Copy link
Copy Markdown
Author

Quick note: I amended the commit to fix the commitlint failure and pushed the typo-check fix. Because the PR is from a fork, GitHub put CI back into action_required for the new head SHA. Could you please approve the workflow run again when you get a chance?

@DaleSeo

DaleSeo commented Oct 5, 2026

Copy link
Copy Markdown
Member

This has merge conflicts with main now. Could you rebase onto the latest main and resolve them? Thanks!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants