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.

}
console.warn("Tool registration will proceed, but this may cause compatibility issues.");
console.warn("Consider updating the tool name to conform to the MCP tool naming standard.");
console.warn("See SEP: Specify Format for Tool Names for more details.");
Copy link
Member

Choose a reason for hiding this comment

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

Consider including a URL to this SEP here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea 👍 Done.

- 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.
@kentcdodds kentcdodds force-pushed the cursor/validate-tool-name-format-and-add-tests-beb1 branch from 0546db5 to f807421 Compare September 9, 2025 17:29
- Adjusted validation logic and regex to accept tool names between 1 and 64 characters
- Updated test cases to reflect new character length requirements
- Modified warnings to align with the updated maximum length

modelcontextprotocol/modelcontextprotocol#986 (comment)
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.

2 participants