Repository navigation
[P29] tools: the tool name format (SEP-986) - #342
Merged
Merged
Conversation
The specification recommends tool names of 1 to 128 characters, each an ASCII letter, a digit, `_`, `-` or `.`, case-sensitive and unique within a server. It says SHOULD, so nothing is refused: Tool.isValidName(_:) checks the format, and the SDK logs. The server logs a warning once for each name in a tools/list result that does not have the format, and for each name a result has more than once. The client logs a warning once for each listed name without the format. Logged names are sanitized, and at most 1000 are remembered. Tests: the examples of the specification, names that break each rule, the problem text, one warning for each name at both eras, and listings that keep every tool. The task test "A task lives for its ttlMs" uses a ttl of 1000 ms: with 100 ms, the first tasks/get came after the ttl in about half of the Linux runs.
- Check a tool name's length before its characters: a name longer than 128 bytes is reported for its length without listing its characters, and at most 8 invalid characters are listed, collected in a set. The check was quadratic in the name, so one tools/list result with a long name of distinct characters held the client (or server) actor for seconds to minutes. - Remember logged tool names by a bounded key (a prefix, the length and a hash for long names), and look the key up before checking the name, so that the set of logged names does not keep long names.
- Put the SEP-2243 doc comment back on droppingInvalidHeaderTools; it had ended up above warnAboutToolNames. - Reset the tool-name warnings (SEP-986) on Client.connect(transport:) and Server.stop(), with the other per-connection tool state: after a reconnect or restart, names already logged were silent and the 1000-entry cap stayed used up.
The restart test of the SEP-986 warnings used a 2026-07-28 client only, because a restarted server refused a second `initialize`. With "ci: reset the handshake state when the server stops" (p21-stability) it serves one, so the test also runs with a handshake client.
This was referenced Nov 25, 2026
varun06
previously approved these changes
Nov 25, 2026
varun06
left a comment
Contributor
There was a problem hiding this comment.
Already reviewed and still looking good.
Base automatically changed from
conformance/p28-request-association-warning
to
rel/1.0.0
November 25, 2026 12:52
varun06
approved these changes
Nov 25, 2026
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
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.
rel/1.0.0in order (previous: P28 (#343) · next: P30 (#341))conformance/p29-tool-namesconformance/p28-request-association-warning(stacked: GitHub retargets this PR torel/1.0.0when the previous part merges)069d38ctools: the tool name format (SEP-986)f6ffc28tools: review fixes046cb64tools: second-pass review fixesb4ca434tools: test the tool-name warnings over a handshake restartSummary
The specification recommends a format for tool names: 1 to 128 characters, each an ASCII letter, a digit,
_,-or., case-sensitive and unique within a server. It says SHOULD, so the SDK refuses nothing.Tool.isValidName(_:)checks the format, and server and client log a warning for each listed name that does not have it. A second commit makes a task test stable on Linux.Changes
Tool names (
069d38c)Sources/MCP/Server/Tools.swift:Tool.isValidName(_:)(public). Internal:Tool.nameProblem(_:), the text of the first rule a name breaks, andToolNameWarnings, which remembers the names already reported (at most 1000).Sources/MCP/Server/Server.swift: after atools/listhandler, the server logs a warning once for each name that does not have the format, and once for each name that the result has more than once.Sources/MCP/Client/Client.swift: on everytools/listresult, the client logs a warning once for each name that does not have the format.Test (
069d38c)Tests/MCPTests/TaskTests.swift, "A task lives for its ttlMs": the task had a ttl of 100 ms, and on Linux the firsttasks/getcame after 100 ms in about half of the runs. A ttl of 1000 ms keeps what the test checks.API changes
Tool.isValidName(_:)truewhen the name has the format of the specificationBehavior changes
Server and client log a warning, once for each name, for a listed tool name without the format, and the server for a name listed more than once. Nothing is refused.
Conformance
Baselines unchanged (empty on every leg). Tier scores 100% at both revisions.
Tests
Tests/MCPTests/ToolNameTests.swift: the examples of the specification, names that break each rule, the problem text, one warning for each name at both eras, and listings that keep every tool. At069d38c,swift testpasses 1037 swift-testing tests inMCPTestsand 108 snippet tests on macOS, and 1129 tests on Linux (scripts/ci-linux.sh build-test).Review notes
Verification
swift test; DocC with warnings as errors; doc coverage;swift scripts/weave.swift --check.scripts/run-interop.sh --check; Linuxscripts/ci-linux.sh build-test, twice.AI usage disclosure: the changes, the tests, the commit messages and this description were written with Claude Opus 5.5 and reviewed by the authors.