Skip to content

Change MCP tool import to make context manager optional #1179

@aymeric-roucher

Description

@aymeric-roucher

@grll the current implementation of tools through MCPAdapt needs this kind of context manager:

with ToolCollection.from_mcp(
    server_parameters, trust_remote_code=True
) as tool_collection:
    # Pass the callback to the agent
    agent = CodeAgent(
        tools=[*tool_collection.tools],
        add_base_tools=False,
        model=model,
        step_callbacks=[limit_snapshot_history],  # Add the callback here
    )
    agent.run("find a good airbnb in paris next to Notre-Dame")

This has been reported as being impractical: because it makes it harder to pass the agent object around.

I see there are simpler implementations in there for instance.
In fact I don't really see the use of a context manager: we don't need to close resources at the end, since we're only on the client side here. What do you think @grll ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions