Skip to content

MCPServerStreamableHTTP headers parameter not sent with HTTP requestsΒ #3304

@tychodev321

Description

@tychodev321

Initial Checks

Description

Issue

When using MCPServerStreamableHTTP with the headers parameter, authentication headers are not being sent with HTTP requests to the MCP server, causing authentication failures.

Code Example

from pydantic_ai.mcp import MCPServerStreamableHTTP

# Headers are not sent to the server
mcp_server = MCPServerStreamableHTTP(
    url="http://localhost:8080/mcp",
    headers={"x-api-key": "my-api-key"}
)

Expected Behavior

Headers should be included in all HTTP requests to the MCP server, similar to how MCPServerTool handles the headers parameter in the documentation.

Question

Is this a bug, or is there a different recommended way to pass authentication headers to MCP servers using MCPServerStreamableHTTP?

Python, Pydantic AI & LLM client version

pydantic-ai version: 1.9.1
Python version: 3.13
httpx version: 0.28.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions