-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Implementation of SEP-986: Specify Format for Tool Names #900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of SEP-986: Specify Format for Tool Names #900
Conversation
|
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. |
0546db5 to
f807421
Compare
0845a57 to
c94ba4b
Compare
- 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
d489d41 to
674827d
Compare
commit: |
e3e2d3f to
5cabbe7
Compare
|
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. |
| callback: ToolCallback<ZodRawShape | undefined> | ||
| ): RegisteredTool { | ||
| // Validate tool name according to SEP specification | ||
| validateAndWarnToolName(name); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
Reduce test file size by 46% (109 lines) using parameterized tests. This improves readability while maintaining the same test coverage.
|
Cool improvements. Thanks @felixweinberger! |
…ype schemas for input and output (modelcontextprotocol#900)
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
Checklist
Additional context
FYI, I used Cursor background agents for this.
Very open to feedback to adjust this implementation.