Skip to main content

with_tool_prefix

Method
This is a method of the MCP class in the mcp module.
Namespace this server’s tool names with <prefix>_ 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.

Signature

Parameters

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

Returns

'MCP'
self, to allow fluent chaining.

Exceptions

If prefix sanitizes to an empty string, since an

Uses

  • ValueError
  • add
  • callable

Source

View on GitHub

praisonaiagents/mcp/mcp.py at line 836

Tools Concept

Create Custom Tools

Tool Development