Skip to content

Conversation

@kentcdodds
Copy link
Contributor

Motivation and Context

modelcontextprotocol/modelcontextprotocol#986

How Has This Been Tested?

Unit tests

Breaking Changes

None, but console warnings may appear for SDK users who have names that do not satisfy the SEP.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

FYI, I used Cursor background agents for this.

Very open to feedback to adjust this implementation.

@kentcdodds
Copy link
Contributor Author

kentcdodds commented Aug 22, 2025

Sorry about all the changes after I opened the PR. I thought it was ready, but I guess it wasn't 😅

Should be ready to go now.

kentcdodds and others added 3 commits November 11, 2025 14:59
- Add comprehensive tool name validation utility with regex patterns
- Validate tool names against SEP-0001 specification requirements
- Support valid characters: lowercase letters, numbers, hyphens, underscores
- Enforce length limits (1-64 characters) and naming conventions
- Generate appropriate warnings for non-compliant tool names
- Add extensive test coverage with Jest spies for console methods
- Integrate validation into McpServer.registerTool() method
- Update test suite to cover all validation scenarios
- Add documentation and examples for tool name validation

This ensures all registered tools comply with the Model Context Protocol
specification for tool naming, improving interoperability and consistency.
- Remove forward slash (/) from allowed characters
- Keep 128 character limit and other restrictions
- Align with final merged specification
@felixweinberger felixweinberger force-pushed the cursor/validate-tool-name-format-and-add-tests-beb1 branch from d489d41 to 674827d Compare November 11, 2025 15:17
@felixweinberger felixweinberger requested a review from a team as a code owner November 11, 2025 15:17
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 11, 2025

Open in StackBlitz

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/sdk@900

commit: 5c3ceb3

@felixweinberger felixweinberger force-pushed the cursor/validate-tool-name-format-and-add-tests-beb1 branch from e3e2d3f to 5cabbe7 Compare November 11, 2025 15:20
@felixweinberger
Copy link
Contributor

Hi @kentcdodds thanks for this - took the liberty of rebasing and updating the implementation to match the final version of modelcontextprotocol/modelcontextprotocol#986 (e.a. / isn't allowed in the shipped spec change: https://github.com/modelcontextprotocol/modelcontextprotocol/pull/1603/files)

@felixweinberger felixweinberger linked an issue Nov 11, 2025 that may be closed by this pull request
callback: ToolCallback<ZodRawShape | undefined>
): RegisteredTool {
// Validate tool name according to SEP specification
validateAndWarnToolName(name);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is the core change

update: updates => {
if (typeof updates.name !== 'undefined' && updates.name !== name) {
if (typeof updates.name === 'string') {
validateAndWarnToolName(updates.name);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is the core change

felixweinberger and others added 2 commits November 11, 2025 17:31
Reduce test file size by 46% (109 lines) using parameterized tests.
This improves readability while maintaining the same test coverage.
@felixweinberger felixweinberger merged commit 29cb080 into modelcontextprotocol:main Nov 11, 2025
6 checks passed
@kentcdodds
Copy link
Contributor Author

Cool improvements. Thanks @felixweinberger!

@kentcdodds kentcdodds deleted the cursor/validate-tool-name-format-and-add-tests-beb1 branch November 11, 2025 18:59
GoBeromsu added a commit to GoBeromsu/X32-MCP that referenced this pull request Nov 12, 2025
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.

Implement SEP-986: Tool Name Guidance

4 participants