[BUG] MCP tool name exceeds 64-char limit once prefixed with server name, aborting agent init
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
SDK Language
TypeScript
Strands Version
0.1.0
Language Runtime Version
Node.js v24.15.0
Operating System
macOS 26.6.2 (25G83)
Installation Method
npm
Steps to Reproduce
Have a global MCP config that the Strands CLI auto-discovers (
~/.claude.json,~/.kiro/settings/mcp.json, or~/.codex/config.toml) containing a server whose name is long enough that, once its key is combined with one of its tool names, the prefixed tool name exceeds 64 characters.Real-world trigger: AWS
awslabs.aws-iac-mcp-server, which exposes a toolget_cloudformation_pre_deploy_validation_instructions.{ "mcpServers": { "awslabs.aws-iac-mcp-server": { "command": "uvx", "args": ["awslabs.aws-iac-mcp-server@latest"] } } }
2. Launch the interactive CLI (MCP discovery on) so the agent fully initializes:
`strands`
3. See the error: error: Tool name must be between 1 and 64 characters
Minimal reproducible example (no CLI, just the harness factory):
```tsx
import { createHarness } from '@strands-agents/harness'
const agent = await createHarness({
model: 'bedrock/global.anthropic.claude-opus-5',
mcpServers: {
'awslabs.aws-iac-mcp-server': {
command: 'uvx',
args: ['awslabs.aws-iac-mcp-server@latest'],
},
},
skills: false,
memory: false,
})
// createHarness() itself does NOT throw (MCP tools are lazy).
// The throw happens when the agent initializes and expands MCP tools into the registry:
await agent.initialize()
// ToolValidationError: Tool name must be between 1 and 64 charactersExpected Behavior
Constructing/initializing the harness should not be aborted by a single auto-discovered MCP server whose prefixed tool name overflows the 64-character registry limit. Any one of these would resolve it (in order of preference):
Fit the name to the limit automatically. When
prefixWithServerNameis on, truncate or hash-suffix the agent-facing prefixed name so it is always ≤ 64 chars, deterministically and collision-safely. The server-side name is already stored separately (_serverToolNames) and used for the actualcallTool, so the display/registry name is free to be shortened without breaking invocation.Skip + warn instead of throw. An individual tool whose prefixed name exceeds the limit should be dropped with a warning (honoring
continue_on_error), not abort initialization of every other server and built-in tool.Make the error actionable. Name the offending server, the original tool, the derived prefixed name, and its length, e.g.:
Tool name 'awslabs_aws-iac-mcp-server_get_cloudformation_pre_deploy_validation_instructions' (80 chars) from server 'awslabs.aws-iac-mcp-server' exceeds the 64-character limit; set a shorter "prefix" for this server.
Actual Behavior
Agent initialization throws and the entire session fails to start:
error: Tool name must be between 1 and 64 characters
The message names neither the offending server, nor the tool, nor the actual length, so there is no way to tell which of the auto-discovered MCP servers is at fault without tracing the SDK source.
Root cause — a hard-limit collision across three layers with no guard in between:
McpClient.loadServers(..., { prefixWithServerName: true })derives the prefix from the server key by sanitizing non-alphanumerics to underscores —strands-ts/src/mcp/config.node.ts:128:opts.prefix = name.replace(/[^A-Za-z0-9_-]/g, '_')So keyawslabs.aws-iac-mcp-server→ prefixawslabs_aws-iac-mcp-server(26 chars).Each tool is renamed to
`${prefix}_${toolSpec.name}`—strands-ts/src/mcp/client.ts:375. Forget_cloudformation_pre_deploy_validation_instructions(53 chars) the result is 80 chars:awslabs_aws-iac-mcp-server_get_cloudformation_pre_deploy_validation_instructionsToolRegistry._validateProperties()enforces1 ≤ length ≤ 64and throws —strands-ts/src/registry/tool-registry.ts:134-135.
Nothing between step 1 and step 3 accounts for prefix.length + 1 + toolName.length exceeding the registry's own maximum. The server-side name is preserved separately in _serverToolNames (client.ts:190,396) and used for invocation (client.ts:477), so the prefixed name is a display/registry concern only.
awslabs.aws-iac-mcp-server has three tools that overflow once prefixed:
| prefixed tool name | length |
|---|---|
awslabs_aws-iac-mcp-server_get_cloudformation_pre_deploy_validation_instructions |
80 |
awslabs_aws-iac-mcp-server_check_cloudformation_template_compliance |
67 |
awslabs_aws-iac-mcp-server_troubleshoot_cloudformation_deployment |
65 |
Additional Context
Impact / severity
- Blocks startup entirely. The throw happens during agent init, so it takes down the whole interactive session — not just the one offending server.
- Auto-discovery makes it a landmine. The server was never explicitly added to the harness config; it was silently merged from a foreign tool's config (
~/.claude.json/~/.kiro/settings/mcp.json/~/.codex/config.toml). A server that works fine in Claude Code / Kiro breaks the Strands CLI. continue_on_errordoes not save you here.createHarnessdefaults MCP servers tocontinueOnError: true, but the failing op is the synchronousToolRegistry.add()during init, not the server connection — so it still throws and aborts. (A short-livedstrands -pcan appear to survive only because it may answer before a slowuvxserver finishes connecting; a full interactive launch consistently throws.)
Workaround
Give the server a short key in the harness's own MCP config so the derived prefix leaves room under 64 (for awslabs.aws-iac-mcp-server the longest bare tool is 53 chars, so the key must be ≤ 10 chars, e.g. aws-iac), and/or disable global MCP auto-discovery and pass an explicit scoped --mcp-config:
{
"mcpServers": {
"aws-iac": {
"command": "uvx",
"args": ["awslabs.aws-iac-mcp-server@latest"]
}
}
}With key aws-iac (7 chars) the longest prefixed name is 61 chars — under the limit.
Related
Distinct from #3710 (Agent.initialize() not retry-safe; MCP re-registration masking) — that produces ... already registered on a retry. This is a first-registration length-limit failure producing ... must be between 1 and 64 characters, and reproduces on the very first initialize().
Possible Solution
No response
Related Issues
No response
Source: strands-agents/harness-sdk