Skip to content

MCP tools appear to be added twice #1142

@wreed4

Description

@wreed4

I'm still tracking this down, but as far as I can tell, by the time we get to the code in pydantic_ai/_agent_graph.py function _prepare_request_parameters, we get to this line

--> 241     await asyncio.gather(
    242         *map(add_tool, ctx.deps.function_tools.values()),
    243         *map(add_mcp_server_tools, ctx.deps.mcp_servers),
    244     )

And the MCP tools are already added to ctx.deps.function_tools in the actor.get_agentlet function in orchestrator.py line 173 in Orchestrator.get_once. So they get added twice and sent to the llm twice, which causes a confict because names are re-used.

I'll keep digging in a bit more and see if I can see why this is happening, but I'm brand new to this codebase and this project.. this is my first attempt at using it :(.

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