Problem/Motivation

McpPluginBase::generateToolId() enforces a 64-character limit on tool names for MCP client compatibility. However, MCP clients add their own prefix to tool names. For example, Claude Code prepends mcp__{server-name}__ (10-19+ characters), causing the final tool name to exceed 64 characters and triggering API errors:

messages.2.content.0.tool_result.content.1.tool_reference.tool_name:
String should have at most 64 characters

The longest names come from the ToolApi plugin, which replaces : with ___ (triple underscore). For example:

- Tool API name: ai_agent_agent:add_default_information_tool
- After ToolApi.php:108: ai_agent_agent___add_default_information_tool
- After generateToolId(): tools_ai_agent_agent___add_default_information_tool (52 chars)
- After Claude Code prefix: mcp__drupal-local__tools_ai_agent_agent___add_default_information_tool (69 chars — over
limit)

Steps to reproduce

- Install MCP
- Install Tool API
- Set up the binary MCP server
- Try and use the default information tool.

https://www.drupalforge.org/template/visual-flow-builder-agents-flowdrop... - example.

Proposed resolution

Suggested fixes

1. Reduce the internal character limit in generateToolId() from 64 to ~50, leaving headroom for the client-side prefix.
The docblock already notes this is for client compatibility — a lower limit would account for the prefix clients add.

2. Use single underscore instead of triple for colon replacement in ToolApi.php:108. Changing str_replace(':', '___',
$name) to str_replace(':', '_', $name) saves 2 characters per colon and is still unambiguous since tool names don't
naturally contain colons.

Workaround

Shorten the MCP server name in the client configuration (e.g., dl instead of drupal-local in .mcp.json).

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork mcp-3569862

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

yautja_cetanu created an issue. See original summary.

yautja_cetanu’s picture

Initial Issue created with help of Claude Code Opus 4.5

gagosha’s picture

Thanks Jamie, merged.

gagosha’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.