Skip to content

Fix #366: Add "Tool names must be unique" error rule#367

Merged
ding113 merged 2 commits intodevfrom
fix/issue-366-tool-names-unique
Dec 19, 2025
Merged

Fix #366: Add "Tool names must be unique" error rule#367
ding113 merged 2 commits intodevfrom
fix/issue-366-tool-names-unique

Conversation

@ding113
Copy link
Owner

@ding113 ding113 commented Dec 18, 2025

Summary

  • Add new default error rule to detect "Tool names must be unique" validation error
  • This error occurs in Claude Code when MCP servers have duplicate tool names
  • Prevents unnecessary provider failover for this non-retryable client-side error

Problem

Fixes #366

When Claude Code encounters duplicate tool names from MCP servers, it returns:

{"type":"error","error":{"type":"invalid_request_error",
   "message":"tools: Tool names must be unique."},
   "request_id":"req_011CW9cz13pCHJv2SC8NPCaq"}

This is a validation error that should not trigger retry or provider switching.

Related Issues:

Solution

Added a new entry to DEFAULT_ERROR_RULES in src/repository/error-rules.ts:

  • Pattern: Tool names must be unique
  • Match Type: contains
  • Category: validation_error
  • Priority: 89 (consistent with other tool validation errors)
  • Override Response: Chinese localized message guiding users to check MCP server configuration

Changes

Core Changes

  • src/repository/error-rules.ts: Added new error rule for tool name uniqueness validation (+18 lines)

Testing

  • Rule pattern matches the error message format
  • After deployment, run syncDefaultErrorRules() or restart with AUTO_MIGRATE=true to sync

Checklist

  • Code follows project conventions
  • Self-review completed
  • Tests pass locally
  • Documentation updated (if needed)

Description enhanced by Claude AI

github-actions bot and others added 2 commits December 18, 2025 17:59
Add new default error rule to match the Claude Code error when MCP servers
have duplicate tool names. This is a non-retryable validation error that
should not trigger provider failover.

Pattern: "Tool names must be unique"
Category: validation_error
Priority: 89 (same as other tool validation errors)

Closes #366

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ding113, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a specific issue where duplicate tool names from MCP servers lead to a 'Tool names must be unique' validation error in Claude Code. The primary goal is to enhance error handling by adding a new default error rule. This rule ensures that such client-side configuration problems are correctly identified and communicated with a clear, localized message, thereby preventing the system from attempting futile retries or initiating provider failovers.

Highlights

  • New Error Rule Added: A new default error rule has been introduced to specifically detect the "Tool names must be unique" validation error.
  • Error Categorization: The new rule categorizes this specific issue as a validation_error, aligning its priority with other tool validation errors.
  • Localized Override Response: An override response has been configured to provide a Chinese localized message, guiding users to inspect their MCP server configuration.
  • Improved Error Handling: This change prevents unnecessary provider failover or retries for a non-retryable, client-side configuration error.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new error rule to handle the "Tool names must be unique" validation error from the Claude API. This is a valuable addition that prevents unnecessary retries on a non-retryable client-side error. The implementation is clean and consistent with the existing error rule definitions. I have one suggestion to make the pattern matching slightly more specific to enhance its robustness.

},
// Issue #366: Tool names must be unique (MCP server configuration error)
{
pattern: "Tool names must be unique",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve the specificity of the match and reduce the risk of false positives with other potential error messages, consider making the pattern more precise. The error message in the PR description is tools: Tool names must be unique.. Including the tools: prefix in the pattern will create a more targeted match.

Suggested change
pattern: "Tool names must be unique",
pattern: "tools: Tool names must be unique",

@github-actions github-actions bot added bug Something isn't working area:Error Rule labels Dec 18, 2025
@github-actions
Copy link
Contributor

🧪 测试结果

测试类型 状态
代码质量
单元测试
集成测试
API 测试

总体结果: ✅ 所有测试通过

@github-actions github-actions bot added the size/XS Extra Small PR (< 50 lines) label Dec 18, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

No significant issues identified in this PR. The change adds a new error rule for "Tool names must be unique" validation error, following established patterns in the codebase.

PR Size: XS

  • Lines changed: 18 additions, 0 deletions
  • Files changed: 1

Review Analysis

The new error rule:

  • ✅ Uses appropriate matchType: "contains" for static string matching
  • ✅ Priority 89 is consistent with other tool validation errors
  • overrideResponse structure correctly follows the ClaudeErrorResponse interface
  • ✅ Comment accurately references the upstream issue (#366)
  • ✅ Category validation_error is appropriate for this type of client error
  • ✅ Will be correctly inserted via syncDefaultErrorRules() for new deployments

Review Coverage

  • Logic and correctness - Clean
  • Security (OWASP Top 10) - Clean
  • Error handling - Clean
  • Type safety - Clean
  • Documentation accuracy - Clean
  • Test coverage - Adequate (covered by existing integration tests)
  • Code clarity - Good

Automated review by Claude AI

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

No significant issues identified in this PR. The change adds a new error rule for "Tool names must be unique" validation error, following established patterns in the codebase.

PR Size: XS

  • Lines changed: 18 additions, 0 deletions
  • Files changed: 1

Review Analysis

The new error rule:

  • ✅ Uses appropriate matchType: "contains" for static string matching
  • ✅ Priority 89 is consistent with other tool validation errors
  • overrideResponse structure correctly follows the ClaudeErrorResponse interface
  • ✅ Comment accurately references the upstream issue (#366)
  • ✅ Category validation_error is appropriate for this type of client error
  • ✅ Will be correctly inserted via syncDefaultErrorRules() for new deployments

Review Coverage

  • Logic and correctness - Clean
  • Security (OWASP Top 10) - Clean
  • Error handling - Clean
  • Type safety - Clean
  • Documentation accuracy - Clean
  • Test coverage - Adequate (covered by existing integration tests)
  • Code clarity - Good

Automated review by Claude AI

@ding113 ding113 merged commit c17fbfd into dev Dec 19, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in Claude Code Hub Roadmap Dec 19, 2025
@github-actions github-actions bot mentioned this pull request Dec 19, 2025
12 tasks
@ding113 ding113 deleted the fix/issue-366-tool-names-unique branch December 23, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Error Rule bug Something isn't working size/XS Extra Small PR (< 50 lines)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant

Comments