Skip to content

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

Description

@morluto

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:mcparea:toolsbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOSstaleIssue is inactive

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions