Skip to content

[Feature Request] Add tool_name_prefix parameter to MCPTools for namespace support #5270

@hypen-code

Description

@hypen-code

Problem Description

Problem Statement

When using multiple MCP servers or toolkits with the same tool names, naming conflicts can occur. Additionally, when the same MCP tool is used across multiple
environments (e.g., dev, staging, prod), the model has no way to distinguish which environment a tool invocation targets.

Use Cases

  1. Avoid naming conflicts: When using multiple MCP servers that have tools with the same names
  2. Environment identification: Help the model distinguish between different environments
    • Example: dev_get_data, staging_get_data, prod_get_data
  3. Multi-toolkit organization: Better organize tools when using multiple MCP toolkits simultaneously

Proposed Solution

Add a tool_name_prefix parameter to the MCPTools class that allows users to namespace their MCP tools by adding a custom prefix to tool names.

The feature adds:

  • A new tool_name_prefix: str = "" parameter to MCPTools.__init__()
  • Automatic prefixing of tool names with underscore separator (e.g., prefix_toolname)
  • Backward compatibility (empty string default means no prefix)

Alternatives Considered

No response

Additional Context

Example Usage

from agno.tools.mcp import MCPTools

# Development environment tools
dev_tools = MCPTools(
    server_params=dev_server_params,
    tool_name_prefix="dev"
)

# Production environment tools
prod_tools = MCPTools(
    server_params=prod_server_params,
    tool_name_prefix="prod"
)

# Now tools are namespaced: dev_get_data, prod_get_data, etc.

Benefits

-Prevents tool name collisions
-Improves model's ability to select the correct tool
-Better organization for complex multi-environment setups
-Backward compatible (no breaking changes)


### Would you like to work on this?

- [x] Yes, Id love to work on it!
- [ ] Im open to collaborating but need guidance.
- [ ] No, Im just sharing the idea.

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