René's URL Explorer Experiment


Title: fix: reject trailing newline in tool-name validation by Otis0408 · Pull Request #3076 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: fix: reject trailing newline in tool-name validation by Otis0408 · Pull Request #3076 · modelcontextprotocol/python-sdk

X Title: fix: reject trailing newline in tool-name validation by Otis0408 · Pull Request #3076 · modelcontextprotocol/python-sdk

Description: Closes #3084 Summary TOOL_NAME_REGEX in src/mcp/shared/tool_name_validation.py is end-anchored with $: TOOL_NAME_REGEX = re.compile(r"^[A-Za-z0-9._-]{1,128}$") In Python's default (non-MULTILINE) mode, $ matches at end-of-string or immediately before a single trailing \n. So a tool name ending in exactly one newline passes validation: >>> validate_tool_name("evil_tool\n").is_valid True # expected: False (newline is not an allowed SEP-986 character) >>> validate_and_warn_tool_name("evil_tool\n") True # no warning logged The length guard uses len() (which counts the \n), so "a" * 127 + "\n" (length 128) also slips past both the length and the character check. Embedded and non-\n trailing control chars are already rejected correctly — only the single-trailing-newline case leaks. Fix Anchor the end with \Z (strict end-of-string) instead of $. No valid name is affected — re.match(r"^[A-Za-z0-9._-]{1,128}\Z", "abc") still matches; only "abc\n" now correctly fails. Tests Adds test_validate_tool_name_rejects_trailing_newline (parametrized over a trailing-newline name and a 128-char name whose last char is \n). Verified it fails on main (is_valid=True) and passes with the fix; the file's existing 29 tests are unchanged (no valid-name fixture ends in a newline).

Open Graph Description: Closes #3084 Summary TOOL_NAME_REGEX in src/mcp/shared/tool_name_validation.py is end-anchored with $: TOOL_NAME_REGEX = re.compile(r"^[A-Za-z0-9._-]{1,128}$") In Python's default (no...

X Description: Closes #3084 Summary TOOL_NAME_REGEX in src/mcp/shared/tool_name_validation.py is end-anchored with $: TOOL_NAME_REGEX = re.compile(r"^[A-Za-z0-9._-]{1,128}$") In Python's...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/3076

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:d4e47aa5-7991-d84d-c0f9-db3ece75474a
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC57A:390ECE:61C95EF:89A1520:6A57416B
html-safe-nonce61581b0551f15d0727601d3cdcd108d00d64ee7c7e4a920ac307f2bb8b10dada
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTdBOjM5MEVDRTo2MUM5NUVGOjg5QTE1MjA6NkE1NzQxNkIiLCJ2aXNpdG9yX2lkIjoiNjc2MDA1OTA3ODYyOTA4MTQ1MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacc4d8a76593644badab45954c7d441ce2283a776baab8e4cc2250891b7d95d7ad
hovercard-subject-tagpull_request:4013943323
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/3076/files
twitter:imagehttps://avatars.githubusercontent.com/u/75174115?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/75174115?s=400&v=4
og:image:altCloses #3084 Summary TOOL_NAME_REGEX in src/mcp/shared/tool_name_validation.py is end-anchored with $: TOOL_NAME_REGEX = re.compile(r"^[A-Za-z0-9._-]{1,128}$") In Python's default (no...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id862584018
octolytics-dimension-repository_nwomodelcontextprotocol/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id862584018
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/python-sdk
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2576d1f0198cf1588faf2edf27f1ed120903be10
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/3076/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3076%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3076%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3076/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3076/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3076/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3076/files
modelcontextprotocol https://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Notifications https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Fork 3.6k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Star 23.6k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Code https://github.com/modelcontextprotocol/python-sdk
Issues 251 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 289 https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality 6 https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
Code https://github.com/modelcontextprotocol/python-sdk
Issues https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
maxisbeyhttps://github.com/maxisbey
modelcontextprotocol:mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
Otis0408:fix/tool-name-regex-trailing-newlinehttps://github.com/Otis0408/python-sdk/tree/fix/tool-name-regex-trailing-newline
Conversation 1 https://github.com/modelcontextprotocol/python-sdk/pull/3076
Commits 2 https://github.com/modelcontextprotocol/python-sdk/pull/3076/commits
Checks 31 https://github.com/modelcontextprotocol/python-sdk/pull/3076/checks
Files changed 4 https://github.com/modelcontextprotocol/python-sdk/pull/3076/files
fix: reject trailing newline in tool-name validation https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#top
Show all changes 2 commits https://github.com/modelcontextprotocol/python-sdk/pull/3076/files
e04b721 fix: reject trailing newline in tool-name validation Otis0408 Jul 8, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/3076/commits/e04b721502bde6873d1b26e3ae4d7039001594e1
23102e3 fix: validate whole strings with re.fullmatch maxisbey Jul 10, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/3076/commits/23102e3e330a84a98602170c12f62e16e4e50a5e
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/3076/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3076/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3076/files
tool_name_validation.py https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-ee98b692d3d3ee905be8642f9a4be9eeea73ce339a436324950ae7c25f9983e6
uri_template.py https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-fed1ff9188bc03dbe6438f057a8a14e0836709fbe492ce2f5b1f1e07a828ca31
test_tool_name_validation.py https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-ee3024885b2fe2a87eaf68675bf5d91ce2587cffce960398438dcf5e2edd62c2
test_uri_template.py https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-4e3a447efa9eb14dbebca06f141da49ed4759667d30c414d01631162351412c6
src/mcp/shared/tool_name_validation.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-ee98b692d3d3ee905be8642f9a4be9eeea73ce339a436324950ae7c25f9983e6
View file https://github.com/Otis0408/python-sdk/blob/23102e3e330a84a98602170c12f62e16e4e50a5e/src/mcp/shared/tool_name_validation.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3076/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-ee98b692d3d3ee905be8642f9a4be9eeea73ce339a436324950ae7c25f9983e6
https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-ee98b692d3d3ee905be8642f9a4be9eeea73ce339a436324950ae7c25f9983e6
src/mcp/shared/uri_template.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-fed1ff9188bc03dbe6438f057a8a14e0836709fbe492ce2f5b1f1e07a828ca31
View file https://github.com/Otis0408/python-sdk/blob/23102e3e330a84a98602170c12f62e16e4e50a5e/src/mcp/shared/uri_template.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3076/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-fed1ff9188bc03dbe6438f057a8a14e0836709fbe492ce2f5b1f1e07a828ca31
https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-fed1ff9188bc03dbe6438f057a8a14e0836709fbe492ce2f5b1f1e07a828ca31
tests/shared/test_tool_name_validation.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-ee3024885b2fe2a87eaf68675bf5d91ce2587cffce960398438dcf5e2edd62c2
View file https://github.com/Otis0408/python-sdk/blob/23102e3e330a84a98602170c12f62e16e4e50a5e/tests/shared/test_tool_name_validation.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3076/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-ee3024885b2fe2a87eaf68675bf5d91ce2587cffce960398438dcf5e2edd62c2
https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-ee3024885b2fe2a87eaf68675bf5d91ce2587cffce960398438dcf5e2edd62c2
tests/shared/test_uri_template.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-4e3a447efa9eb14dbebca06f141da49ed4759667d30c414d01631162351412c6
View file https://github.com/Otis0408/python-sdk/blob/23102e3e330a84a98602170c12f62e16e4e50a5e/tests/shared/test_uri_template.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3076/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-4e3a447efa9eb14dbebca06f141da49ed4759667d30c414d01631162351412c6
https://github.com/modelcontextprotocol/python-sdk/pull/3076/files#diff-4e3a447efa9eb14dbebca06f141da49ed4759667d30c414d01631162351412c6
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3076/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.