Skip to content

[P29] tools: the tool name format (SEP-986) - #342

Merged
jeanmatthieu merged 4 commits into
rel/1.0.0from
conformance/p29-tool-names
Nov 25, 2026
Merged

jeanmatthieu merged 4 commits into
rel/1.0.0from
conformance/p29-tool-names

Conversation

@jeanmatthieu

@jeanmatthieu jeanmatthieu commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor
Part P29 of P0–P35, merged into rel/1.0.0 in order (previous: P28 (#343) · next: P30 (#341))
Branch conformance/p29-tool-names
Base conformance/p28-request-association-warning (stacked: GitHub retargets this PR to rel/1.0.0 when the previous part merges)
Commits 069d38c tools: the tool name format (SEP-986)
f6ffc28 tools: review fixes
046cb64 tools: second-pass review fixes
b4ca434 tools: test the tool-name warnings over a handshake restart
Size 9 files, +300 / -4

Summary

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, and ToolNameWarnings, which remembers the names already reported (at most 1000).
  • Sources/MCP/Server/Server.swift: after a tools/list handler, 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 every tools/list result, the client logs a warning once for each name that does not have the format.
  • Logged names are sanitized. Every tool stays in the result.
  • Server guide: the format and the warnings. CHANGELOG. ROADMAP: SEP-986 Implemented.

Test (069d38c)

  • Tests/MCPTests/TaskTests.swift, "A task lives for its ttlMs": the task had a ttl of 100 ms, and on Linux the first tasks/get came after 100 ms in about half of the runs. A ttl of 1000 ms keeps what the test checks.

API changes

Symbol Notes
Tool.isValidName(_:) true when the name has the format of the specification

Behavior 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. At 069d38c, swift test passes 1037 swift-testing tests in MCPTests and 108 snippet tests on macOS, and 1129 tests on Linux (scripts/ci-linux.sh build-test).

Review notes

  • The rules are the same at 2025-11-25 and 2026-07-28. The TypeScript SDK also only warns.

Verification

  • swift test; DocC with warnings as errors; doc coverage; swift scripts/weave.swift --check.
  • Every conformance leg for client and server; both tier scores.
  • scripts/run-interop.sh --check; Linux scripts/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.

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.
varun06
varun06 previously approved these changes Nov 25, 2026

@varun06 varun06 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
@jeanmatthieu
jeanmatthieu dismissed varun06’s stale review November 25, 2026 12:52

The base branch was changed.

@jeanmatthieu
jeanmatthieu merged commit 1767a7e into rel/1.0.0 Nov 25, 2026
@jeanmatthieu
jeanmatthieu deleted the conformance/p29-tool-names branch November 25, 2026 12:53
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