Skip to content

feat: add tool name aliasing for Bedrock compatibility#1185

Closed
NickNYU wants to merge 2 commits intoChromeDevTools:mainfrom
NickNYU:feat/bedrock-tool-name-aliasing
Closed

feat: add tool name aliasing for Bedrock compatibility#1185
NickNYU wants to merge 2 commits intoChromeDevTools:mainfrom
NickNYU:feat/bedrock-tool-name-aliasing

Conversation

@NickNYU
Copy link
Copy Markdown

@NickNYU NickNYU commented Mar 15, 2026

Summary

  • Add --max-tool-name-length CLI option that enables deterministic, collision-safe shortening of MCP tool names
  • Implements a ToolNameAliaser class using a human-readable abbreviation dictionary (e.g., performanceperf, consolecons) with progressive truncation fallback
  • Solves AWS Bedrock's 64-character toolSpec.name limit when MCP client prefixes (e.g., mcp__plugin_chrome-devtools-mcp_chrome-devtools__, 49 chars) push tool names over the limit

Problem

When used via MCP clients that add prefixes, several tool names exceed Bedrock's 64-char limit:

Original Name Prefixed Length
performance_analyze_insight 76
performance_start_trace 72
list_console_messages 70
list_network_requests 70
take_memory_snapshot 69

Solution

With --max-tool-name-length 15, all names are shortened to fit:

Original Alias Full Length
performance_analyze_insight perf_anlz_ins 62
performance_start_trace perf_star_trace 64
list_console_messages list_cons_msgs 63
take_memory_snapshot take_mem_snap 62

Design

  • Opt-in: No behavior change without the flag
  • Deterministic: Same tool list always produces the same aliases
  • Collision-safe: Numeric suffixes appended on collision
  • Internal names preserved: Logging and telemetry use original names

Files changed

File Change
src/tools/tool-name-aliaser.ts New ToolNameAliaser class
src/index.ts Integrate aliaser at tool registration boundary
src/bin/chrome-devtools-mcp-cli-options.ts Add --max-tool-name-length CLI option
tests/tools/tool-name-aliaser.test.ts 21 tests covering shortening, collisions, round-trips, determinism

Test plan

  • All 21 unit tests pass (node --test build/tests/tools/tool-name-aliaser.test.ts)
  • Type-check passes (tsc --noEmit)
  • Verify no regression on existing tests
  • Manual test with Bedrock via Claude Code with --max-tool-name-length 15

🤖 Generated with Claude Code

@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 15, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

NickNYU added 2 commits March 16, 2026 09:37
Some LLM providers (e.g., AWS Bedrock) enforce a 64-character limit
on tool names. When MCP clients add prefixes like
`mcp__plugin_<pkg>_<server>__`, the full tool name can exceed this
limit.

Add a `--max-tool-name-length` CLI option that enables deterministic,
collision-safe shortening of tool names using human-readable
abbreviations. Internal handler dispatch, logging, and telemetry
continue using the original names.
The `has all tools` e2e test dynamically imports all files in
build/src/tools/ and invokes exported functions as tool factories.
The ToolNameAliaser class export needs to be skipped like
ToolDefinition.
@NickNYU NickNYU force-pushed the feat/bedrock-tool-name-aliasing branch from f983747 to 0062a8f Compare March 16, 2026 01:38
Copy link
Copy Markdown
Collaborator

@Lightning00Blade Lightning00Blade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tentatively blocking this, reasoning:

  1. MCP spec clearly states max tool name is 128, this is only for the name not prefixed.
  2. Claude should fix this on their end, as tomorrow they may break it even with this fix.
  3. There may drop in quality due to the new naming:
    For instance ins is confused with HTML <ins> Tag. Or inst is confused with instance.

@OrKoN
Copy link
Copy Markdown
Collaborator

OrKoN commented Apr 1, 2026

Agree with #1185 (review)

@OrKoN OrKoN closed this Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants