[BUG] Tool search fails when MCP tool names exceed 64 chars

Resolved 💬 9 comments Opened Jan 21, 2026 by morluto Closed Mar 11, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Title: Tool search fails when MCP tool names exceed 64 chars

## Bug Description
When tool search runs, Claude Code queries each MCP server for its tool list. If any MCP server returns a tool name >64 characters, Claude Code sends those tool
names to the API and gets a 400 validation error before any tool can be selected. This makes Claude Code unusable even though tool search should defer actual
tool loading.

This seems related to existing 64‑char name issues, but the failure here happens during tool search discovery before tool selection.

## Steps to Reproduce

  1. Configure any MCP server that returns tool names longer than 64 characters.
  2. Ensure tool search is enabled (default ENABLE_TOOL_SEARCH=auto).
  3. Start Claude Code and send any prompt.

## Expected Behavior
Tool search should handle invalid tool names gracefully, e.g.:

  • Skip/ignore tools with invalid names and continue
  • Or surface a clear error with server + tool name + length
  • Or map long tool names to safe short aliases for tool search

## Actual Behavior
Claude Code returns API error 400 immediately:
"tools.X.custom.name: String should have at most 64 characters"
No tool can be selected or used.

## Environment

  • Claude Code version: [fill]
  • OS: [fill]
  • MCP server: [fill]
  • Tool search setting: ENABLE_TOOL_SEARCH=auto

What Should Happen?

Tool search should handle invalid tool names gracefully: skip or sanitize names longer than 64 characters (or skip only the offending tools) and continue loading tools from other MCP servers, or surface a clear, non‑fatal warning without breaking the session.

Error Messages/Logs

Tool search should handle invalid tool names gracefully: it should ignore or sanitize tool names longer than 64 characters (or skip only the offending tools) and continue loading tools from other MCP servers, or surface a clear, non‑fatal warning without breaking the session.

Steps to Reproduce

  1. Create a minimal MCP server that returns at least one tool name longer than 64 characters.

Example index.ts:

import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";

const server = new Server(
{ name: "long-name-mcp", version: "0.0.1" },
{
capabilities: {
tools: {
tools: [
{
name: "this_tool_name_is_deliberately_longer_than_sixty_four_characters",
description: "long name test",
inputSchema: z.object({}),
},
],
},
},
}
);

server.setRequestHandler("tools/call", async () => ({ content: [] }));

const transport = new StdioServerTransport();
await server.connect(transport);

  1. Register the MCP server in Claude Code’s config (e.g. ~/.config/claude/claude.config.json):

{
"mcpServers": {
"long-name-mcp": {
"command": "node",
"args": ["./index.ts"]
}
}
}

  1. Ensure tool search is enabled (default ENABLE_TOOL_SEARCH=auto).
  2. Run Claude Code and send any prompt.
  3. Observe that tool search fails with a 400 validation error:

"tools.X.custom.name: String should have at most 64 characters"

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.14

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

  • Error message appears during tool search before any tool selection.
  • Disabling tool search (ENABLE_TOOL_SEARCH=false) avoids the 400 but removes automatic tool discovery.
  • Related issues about 64‑char name limit exist (#2445, #2579, #2485), but this case is a tool‑search failure that blocks all MCP tools when a single server

returns an over‑length name.

View original on GitHub ↗

This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗