Interface McpModernToolNamePrefixGenerator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Generates the name under which a tool of a modern MCP server is presented to the model.
- Since:
- 2.1.0
- Author:
- Christian Tzolov
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe longest tool name most model providers accept. -
Method Summary
Modifier and TypeMethodDescriptionNames a tool<connection>_<tool>.noPrefix()Keeps the tool's own name.prefixedToolName(McpModernConnectionInfo connectionInfo, io.modelcontextprotocol.modern.McpSchema.Tool tool) Generates the name the model sees for the given tool.
-
Field Details
-
MAX_TOOL_NAME_LENGTH
static final int MAX_TOOL_NAME_LENGTHThe longest tool name most model providers accept.- See Also:
-
-
Method Details
-
prefixedToolName
String prefixedToolName(McpModernConnectionInfo connectionInfo, io.modelcontextprotocol.modern.McpSchema.Tool tool) Generates the name the model sees for the given tool.- Parameters:
connectionInfo- the connection the tool belongs totool- the tool, as listed by the server- Returns:
- the tool name
-
connectionPrefix
Names a tool<connection>_<tool>. The name depends only on the connection name and the tool name, so a tool keeps its name when its definition changes. Characters that model providers reject are removed, and hyphens become underscores. A name longer thanMAX_TOOL_NAME_LENGTHkeeps its beginning, with the connection name, and ends in eight characters that are derived from the connection name and the tool name, so that two long names do not become the same one.- Returns:
- the generator
-
noPrefix
Keeps the tool's own name. Tools of different connections that share a name then collide, which the tool callback providers reject.- Returns:
- the generator
-