> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# With Tool Prefix • AI Agent SDK

> with_tool_prefix: Namespace this server's tool names with ``prefix_`` to avoid

# with\_tool\_prefix

Method

> This is a method of the [**MCP**](https://praison.ai/docs/sdk/reference/praisonaiagents/classes/MCP.md) class in the [**mcp**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/mcp.md) module.

Namespace this server's tool names with `&lt;prefix&gt;_` to avoid
collisions when multiple MCP servers are loaded together.

Both the callable tool names (`__name__`) and the OpenAI schema
names produced by :meth:`to_openai_tool` are prefixed, while calls
are still dispatched to the original server-side tool names.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%

graph LR
    agent["Agent"] -- "uses" --> tool["Tool: with_tool_prefix"]
    tool -- "returns" --> result["Result"]
    style tool fill:#189AB4,color:#fff
    style agent fill:#8B0000,color:#fff
    style result fill:#8B0000,color:#fff
```

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def with_tool_prefix(prefix: str) -> 'MCP'
```

## Parameters

**prefix** `str` *required*

The server name to derive the prefix from. It is sanitized to contain only `[0-9A-Za-z_]` characters.

### Returns

**Returns** `'MCP'`

self, to allow fluent chaining.

### Exceptions

> [accordion] ValueError
>
> If `prefix` sanitizes to an empty string, since an

## Uses

* `ValueError`
* `dict.fromkeys`
* `callable`

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/mcp/mcp.py#L1247)
>
> `praisonaiagents/mcp/mcp.py` at line 1247

***

## Related Documentation

> [card] [Tools Concept](https://praison.ai/docs/docs/concepts/tools)

> [card] [Create Custom Tools](https://praison.ai/docs/docs/guides/tools/create-custom-tools)

> [card] [Tool Development](https://praison.ai/docs/docs/tutorials/advanced-tool-development)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.