Skip to content

Client error '426 Upgrade Required' #31

@neolee

Description

@neolee

I first run the MCP server in streamable HTTP mode using:

uvx mcp-run-python --port 3001 streamable-http

Then test the Pydantic AI client code as below:

from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerStreamableHTTP

server_http = MCPServerStreamableHTTP(url="http://localhost:3001/mcp")
agent_http = Agent(m.default, toolsets=[server_http])

async def run(agent):
    async with agent.run_mcp_servers():
        result = await agent.run(f"How many days between 2000-01-01 and 2025-12-01?")
    print(result.output)

if __name__ == "__main__":
    import asyncio

    asyncio.run(run(agent_http))

It runs into error:

httpx.HTTPStatusError: Client error '426 Upgrade Required' for url 'http://localhost:3001/mcp'

Anything wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions