-
Notifications
You must be signed in to change notification settings - Fork 402
Implementation of SEP-986: Specify Format for Tool Names #551
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
base: main
Are you sure you want to change the base?
Implementation of SEP-986: Specify Format for Tool Names #551
Conversation
Adds validation for MCP tool naming conventions as specified in SEP-986. Ensures Rust SDK enforces standardized tool name formats, provides clear errors for invalid names, and improves consistency across implementations. Signed-off-by: tanish111 <[email protected]>
Update doctest examples to use the correct module path rmcp::handler::server::tool_name_validation instead of rmcp::model::tool_name_validation. Signed-off-by: tanish111 <[email protected]>
alexhancock
left a comment
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.
LGTM other than the one comment. I also prefer to remove most of the comments for code that is already clear.
| let result = validate_tool_name(name); | ||
|
|
||
| // Always issue warnings for any validation issues (both invalid names and warnings) | ||
| issue_tool_name_warning(name, &result.warnings); |
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.
I would check if there are warnings here and only call the method if there are warnings as opposed to having that check internally
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.
@alexhancock I have updated the code with this suggestion.
(This would definitely save unnecessary stack calls)
Also I have remove most of comments just kept the one which are needed
Prevent empty warnings array from triggering warning output. Signed-off-by: tanish111 <[email protected]>
Signed-off-by: tanish111 <[email protected]>
Signed-off-by: tanish111 <[email protected]>
Motivation and Context
modelcontextprotocol/modelcontextprotocol/issues/986
How Has This Been Tested?
Manual testing in examples/servers: added name to existing #[tool] attributes in common/counter.rs with valid and invalid names. Rebuilding and running showed expected warnings. Unit tests (11) cover validation scenarios; integration tests are planned.
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
All design decisions, names, and other aspects follow the TypeScript implementation for consistency across SDKs.
Related issue #518