> ## 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

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**MCP**](../classes/MCP) class in the [**mcp**](../modules/mcp) 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

<ParamField query="prefix" type="str" required={true}>
  The server name to derive the prefix from. It is sanitized to contain only `[0-9A-Za-z_]` characters.
</ParamField>

### Returns

<ResponseField name="Returns" type="'MCP'">
  self, to allow fluent chaining.
</ResponseField>

### Exceptions

<AccordionGroup>
  <Accordion title="ValueError">
    If `prefix` sanitizes to an empty string, since an
  </Accordion>
</AccordionGroup>

## Uses

* `ValueError`
* `add`
* `callable`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/mcp/mcp.py#L836">
  `praisonaiagents/mcp/mcp.py` at line 836
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Tools Concept" icon="wrench" href="/docs/docs/concepts/tools" />

  <Card title="Create Custom Tools" icon="plus" href="/docs/docs/guides/tools/create-custom-tools" />

  <Card title="Tool Development" icon="code" href="/docs/docs/tutorials/advanced-tool-development" />
</CardGroup>
