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.

@FunctionalInterface public interface McpModernToolNamePrefixGenerator
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 Details

    • MAX_TOOL_NAME_LENGTH

      static final int MAX_TOOL_NAME_LENGTH
      The 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 to
      tool - the tool, as listed by the server
      Returns:
      the tool name
    • connectionPrefix

      static McpModernToolNamePrefixGenerator 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 than MAX_TOOL_NAME_LENGTH keeps 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