agno icon indicating copy to clipboard operation
agno copied to clipboard

[Bug] Setting include_tools breaks MCPTool

Open njbrake opened this issue 11 months ago • 1 comments

Description

Setting include_tools breaks MCPTool

Steps to Reproduce

server_params = MCPStdioParams(
            command="docker",
            args=[
                "run",
                "-i",
                "--rm",
                "--mount",
                f"type=bind,src={tmp_path},dst=/projects",
                "mcp/filesystem",
                "/projects",
            ],
            tools=[
                "write_file",
                "read_file"
            ],
        ),
MCPTools(
            command=server_params,
            include_tools=["write_file"],
            env={**os.environ},
  )

Agent Configuration (if applicable)

n/a

Expected Behavior

No crash

Actual Behavior

            if include_tools:
                missing_includes = set(include_tools) - available_tools
                if missing_includes:
>                   raise ValueError(f"Included tool(s) not present in the toolkit: {', '.join(missing_includes)}")
E                   ValueError: Included tool(s) not present in the toolkit: write_file

.venv/lib/python3.12/site-packages/agno/tools/toolkit.py:51: ValueError

Screenshots or Logs (if applicable)

Include any relevant screenshots or error logs that demonstrate the issue.

Environment

  • Agno Version: 1.4.2

Possible Solutions (optional)

The problem I think is that MCPTools is calling super().__init__(name="MCPToolkit", include_tools=include_tools, exclude_tools=exclude_tools, **kwargs) and not passing in tools so then in that base class, tools is an empty list so the error happens

Additional Context

I think some changes happened in agno 1.4 that made MCP less stable. I put a lot of work into writing a unit test on my side to check MCP functionality for filtering tools, maybe it would be a helpful thing to put into agno? https://github.com/mozilla-ai/any-agent/pull/152/files#diff-e52e4ddd58b7ef887ab03c04116e676f6280b824ab7469d5d3080e5cba4f2128

njbrake avatar Apr 25 '25 12:04 njbrake

PR for the fix I think is in https://github.com/mozilla-ai/any-agent/pull/152#issuecomment-2830058294

njbrake avatar Apr 25 '25 12:04 njbrake