Skip to content

Conversation

polatengin
Copy link
Contributor

Fix Claude API Errors with Tool Name Validation

This PR fixes a problem where the Azure DevOps MCP server was getting error messages from Claude API because some tool names didn't follow the required format. Claude API is very strict about tool names, they can only contain letters, numbers, underscores, dots, and dashes, and must be 64 characters or less. When tool names don't follow these rules, Claude returns a 400 error and refuses to work.

To solve this, we added validation that checks all tool names before they get sent to Claude. The validation happens in three places: when you're writing code (through ESLint), when you build the project, and when tests run. We tested all 60+ existing tools in the project and they all pass the validation. The longest tool name is only 40 characters, so we're well within the limits.

The validation code is organized so there's no duplication, one shared module handles all the checking logic. We also added comprehensive tests to make sure the validation works correctly, and wrote documentation to help developers understand the naming rules. This prevents future API errors and makes the development process smoother since developers get immediate feedback when they use invalid tool names.

Example linter error while developing;

image

Output of validation for current tools;

image

GitHub issue number

Fixes #332

Associated Risks

None

PR Checklist

  • I have read the contribution guidelines
  • I have read the code of conduct guidelines
  • Title of the pull request is clear and informative.
  • 👌 Code hygiene
  • 🔭 Telemetry added, updated, or N/A
  • 📄 Documentation added, updated, or N/A
  • 🛡️ Automated tests added, or N/A

🧪 How did you test it?

Run npm run validate-tools command

@polatengin polatengin requested a review from a team as a code owner July 23, 2025 18:29
@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@d02900b). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #337   +/-   ##
=======================================
  Coverage        ?   98.45%           
=======================================
  Files           ?       11           
  Lines           ?      518           
  Branches        ?       66           
=======================================
  Hits            ?      510           
  Misses          ?        3           
  Partials        ?        5           
Flag Coverage Δ
unittests 98.45% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@kboom kboom left a comment

Choose a reason for hiding this comment

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

Great work!

@danhellem danhellem merged commit 08d2851 into microsoft:main Jul 24, 2025
3 checks passed
@polatengin polatengin deleted the polatengin/tool-name-validation branch July 24, 2025 13:06
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.

Schema validation error in v1.2.0: Property keys don't match required pattern

4 participants