Skip to content

/agents/mcp/server.py", line 115, in list_tools raise UserError("Server not initialized. Make sure you call connect() first.") agents.exceptions.UserError: Server not initialized. Make sure you call connect() first. #446

Closed
@fengyang95

Description

@fengyang95

Please read this first

  • Have you read the docs?Agents SDK docs
  • Have you searched for related issues? Others may have had similar requests

Question

Using the following code, why does it throw an error? Is there a convenient way to integrate MCP with agent orchestration?

  SERVER_FILE_SYSTEM = MCPServerStdio(
    name="Filesystem Server, via npx",
    params={
        "command": "npx",
        "args": ["-y", "@modelcontextprotocol/server-filesystem", WORK_SPACE],
    },
)

SEARCHER_AGENT = Agent(
    name="Searcher",
    instructions="Search for related files and content",
    handoff_description="""Responsible for finding relevant files and code content based on given information""",
    model=ModelConfig.cr_ultra_model,
    mcp_servers=[
        SERVER_FILE_SYSTEM
    ]
)

if __name__ == "__main__":
    from agents import Runner

    async def main():
        with trace("File search example"):
            result = await Runner.run(starting_agent=SEARCHER_AGENT, input="List directory structure")
            print(result)

    asyncio.run(main())

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about using the SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions