Skip to content

[v1.x] fix: reject trailing newline in tool-name validation - #3086

Merged
maxisbey merged 2 commits into
v1.xfrom
fix/tool-name-trailing-newline-v1x
Jul 17, 2026
Merged

maxisbey merged 2 commits into
v1.xfrom
fix/tool-name-trailing-newline-v1x

fix: reject trailing newline in tool-name validation

c6b2fc0
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 10, 2026 in 8m 19s

Code review found 1 potential issue

Found 2 candidates, confirmed 1. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 0
🟣 Pre-existing 1
Severity File:Line Issue
🟣 Pre-existing src/mcp/shared/tool_name_validation.py:80 Same re.match + $ trailing-newline bug remains in ResourceTemplate.matches() on v1.x

Annotations

Check notice on line 80 in src/mcp/shared/tool_name_validation.py

See this annotation in the file changed.

@claude claude / Claude Code Review

Same re.match + $ trailing-newline bug remains in ResourceTemplate.matches() on v1.x

Pre-existing issue, not introduced by this PR: the same `$`-with-`re.match` trailing-newline bug fixed here for tool names also exists on v1.x in `ResourceTemplate.matches()` (src/mcp/server/fastmcp/resources/templates.py:89), where `'resource://user/123\n'` matches template `'resource://user/{id}'` with the newline captured into the extracted parameter. The wire path is protected by pydantic `AnyUrl` normalization, but `FastMCP.read_resource`/`Context.read_resource` accept raw `str`, so conside