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
ValueError
ValueError
If
prefix sanitizes to an empty string, since anUses
ValueErroraddcallable
Source
View on GitHub
praisonaiagents/mcp/mcp.py at line 836
