-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Implement SEP-986: Tool name validation #1655
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
Merged
felixweinberger
merged 4 commits into
main
from
fweinberger/sep-986-tool-name-validation
Nov 24, 2025
Merged
Implement SEP-986: Tool name validation #1655
felixweinberger
merged 4 commits into
main
from
fweinberger/sep-986-tool-name-validation
Nov 24, 2025
+334
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add validation for tool names according to SEP-986 specification. Tool names are now validated at registration time in both FastMCP and low-level server: - Names must be 1-128 characters - Only A-Za-z0-9._- characters allowed - Warnings issued for non-conforming names (doesn't block registration) - Leading/trailing dots or dashes trigger advisory warnings Validation is implemented in mcp.shared.tool_name_validation module with comprehensive test coverage. Github-Issue:#1537
pcarleton
reviewed
Nov 24, 2025
Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>
pcarleton
reviewed
Nov 24, 2025
| TOOL_NAME_REGEX = re.compile(r"^[A-Za-z0-9._-]{1,128}$") | ||
|
|
||
| # SEP reference URL for warning messages | ||
| SEP_986_URL = "https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986" |
Member
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.
Suggested change
| SEP_986_URL = "https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986" | |
| SEP_986_URL = "https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool-names" |
pcarleton
reviewed
Nov 24, 2025
| digits (0-9), underscore (_), dash (-), and dot (.). | ||
| Tool names SHOULD NOT contain spaces, commas, or other special characters. | ||
|
|
||
| See: https://modelcontextprotocol.io/specification/draft/server/tools#tool-names |
Member
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.
Suggested change
| See: https://modelcontextprotocol.io/specification/draft/server/tools#tool-names | |
| See: https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool-names |
pcarleton
approved these changes
Nov 24, 2025
Member
pcarleton
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.
approved w/ url fix
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
modelcontextprotocol/modelcontextprotocol#986
Implements tool name validation according to SEP-986 specification. Tool names are validated at registration time in both FastMCP and low-level server paths, issuing warnings for non-conforming names without blocking registration.
Taking similar approach to reference implementation in TS: modelcontextprotocol/typescript-sdk#900
How Has This Been Tested?
Unit tests - 29 new tests for the validation module covering:
All existing tests continue to pass.
Breaking Changes
None, but console warnings may appear for SDK users who have tool names that do not satisfy the SEP.
Types of changes
Checklist