Tool Name Prefix

Add a prefix to the name of your MCP tools.

Add a prefix to the name of your MCP tools. This is useful to avoid name collisions with other tools, especially when using multiple MCP servers.

tool_name_prefix.py
"""This example demonstrates how to add a prefix to the name of your MCP tools.
This is useful to avoid name collisions with other tools, especially when using multiple MCP servers."""

import asyncio

from agno.agent.agent import Agent
from agno.tools.mcp import MCPTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


async def run_agent():
    # Development environment tools
    dev_tools = MCPTools(
        transport="streamable-http",
        url="https://docs.agno.com/mcp",
        # By providing this tool_name_prefix, all the tool names will be prefixed with "dev_"
        tool_name_prefix="dev",
    )
    await dev_tools.connect()

    agent = Agent(tools=[dev_tools])
    await agent.aprint_response("Which tools do you have access to? List them all.")

    await dev_tools.close()


# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    asyncio.run(run_agent())

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U "agno[mcp]" openai

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"

Keep the connection in an async context

Save the source as tool_name_prefix.py, then replace run_agent so the connection is released when the model call fails:

async def run_agent():
    async with MCPTools(
        transport="streamable-http",
        url="https://docs.agno.com/mcp",
        tool_name_prefix="dev",
    ) as dev_tools:
        agent = Agent(tools=[dev_tools])
        await agent.aprint_response("Which tools do you have access to? List them all.")

Run the example

Run the adapted tool_name_prefix.py:

python tool_name_prefix.py

Full source: cookbook/91_tools/mcp/tool_name_prefix.py