Skip to content

Feature Request: Support Custom Headers for MCP Server Calls #989

@Khalidzo

Description

@Khalidzo

Hi there 👋

I'm currently working with the Anthropic SDK + FastMCP setup, and I ran into a small limitation. Right now, it seems like the only way to pass headers to an MCP server is by using the authorization_token field — which always gets sent as an Authorization: Bearer ... header.

That works for authentication, but what if I just want to pass some extra context to the server? Things like:

  • X-Client: abc123
  • X-Session-ID: abc123

Right now I have to "abuse" the authorization token just to sneak in custom values, and it just a messy way to get things work.

It’d be amazing if we could pass actual custom headers through the MCP server config, directly in the BetaRequestMCPServerURLDefinitionParam object like this:

class BetaRequestMCPServerURLDefinitionParam(TypedDict, total=False):
    name: Required[str]
    type: Required[Literal["url"]]
    url: Required[str]
    authorization_token: Optional[str]
    tool_configuration: Optional[BetaRequestMCPServerToolConfigurationParam]
    extra_headers: Optional[dict[str, str]]  # <--- new addition

Thanks a lot in advance.
Khalid

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions