René's URL Explorer Experiment


Title: Python: Add models for the MCP server SDKs (`mcp`, `fastmcp`) by Alex-Hofer · Pull Request #22703 · github/codeql · GitHub

Open Graph Title: Python: Add models for the MCP server SDKs (`mcp`, `fastmcp`) by Alex-Hofer · Pull Request #22703 · github/codeql

X Title: Python: Add models for the MCP server SDKs (`mcp`, `fastmcp`) by Alex-Hofer · Pull Request #22703 · github/codeql

Description: Implements the proposal in #22702. The observation there about py/xxe, py/xml-bomb and py/nosql-injection taking only RemoteFlowSource has since been fixed by #22822. MCP servers expose tools to LLM agents. Every parameter of a tool, resource or prompt handler is chosen by the client, that is by a model that prompt injection can steer, or by anyone who can reach the server over HTTP. This PR models that input for the two Python SDKs as Models-as-Data next to the existing Stdlib.model.yml sources: the handler parameters as sources of the opt-in ai threat model (#22810), the transport headers and the bearer token as sources of the remote threat model. Covered: mcp 1.x FastMCP and 2.x MCPServer: tool(), resource(), prompt(), add_tool(fn). The low-level Server: the 1.x decorators call_tool(), read_resource(), get_prompt(), and the 2.x constructor handlers on_call_tool, on_read_resource, on_get_prompt, where params.arguments / params.uri is the source. fastmcp 2.x to 4.x: tool and prompt bare, called or as a plain call, resource(), add_tool, add_prompt, Tool.from_function, fastmcp.tools.tool, the transport headers via get_http_headers() and get_http_request().headers. Both SDKs: the bearer token of the Authorization header, in verify_token of TokenVerifier (and AuthProvider) subclasses and from get_access_token().token. typeModel rows for the re-exported import paths of the classes. Tests: library-tests/frameworks/mcp and library-tests/frameworks/fastmcp use MaDTest (mad-source__ai, mad-source__remote); every row has a handler with an inline expectation, and classes with the same method name but no SDK base class have none. Evidence: with these rows (as a model pack) CodeQL 2.27.1 finds 13 of 28 real, publicly disclosed MCP server vulnerabilities in mcp-vulnbench instead of 1; on the half of the cases that was held out while writing the rows, 9 of 16 instead of 0, at 0.27 to 1.09 alarms per KLOC. Known limits of this form (handlers behind project decorators, Pydantic-typed parameters, headers read through the Context object) are documented there and in the issue. The measurement used the rows as remote, which is on by default; with ai the same sources apply once that threat model is enabled.

Open Graph Description: Implements the proposal in #22702. The observation there about py/xxe, py/xml-bomb and py/nosql-injection taking only RemoteFlowSource has since been fixed by #22822. MCP servers expose tools to LL...

X Description: Implements the proposal in #22702. The observation there about py/xxe, py/xml-bomb and py/nosql-injection taking only RemoteFlowSource has since been fixed by #22822. MCP servers expose tools to LL...

Opengraph URL: https://github.com/github/codeql/pull/22703

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:f97743f9-75b6-fb6c-b824-78fdedb99d67
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8234:1CA2FE:265070B:31E433B:6AF9917B
html-safe-nonce4c944b1a262124052cedf92e8e796953963a37ac781542f01ae07cbb5cfeea6b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjM0OjFDQTJGRToyNjUwNzBCOjMxRTQzM0I6NkFGOTkxN0IiLCJ2aXNpdG9yX2lkIjoiMTM0MzAwOTg5NTU2NDgwODU3MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4b0d4351fb3cd7f51737d633476cd47b4dba080584b8c79bf7c033394704b6ac
hovercard-subject-tagpull_request:4685133580
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/github/codeql/pull/22703/files
twitter:imagehttps://avatars.githubusercontent.com/u/62021660?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/62021660?s=400&v=4
og:image:altImplements the proposal in #22702. The observation there about py/xxe, py/xml-bomb and py/nosql-injection taking only RemoteFlowSource has since been fixed by #22822. MCP servers expose tools to LL...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/github/codeql git https://github.com/github/codeql.git
octolytics-dimension-user_id9919
octolytics-dimension-user_logingithub
octolytics-dimension-repository_id143040428
octolytics-dimension-repository_nwogithub/codeql
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id143040428
octolytics-dimension-repository_network_root_nwogithub/codeql
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
release072e34035c13c31543fba9f025cbbbda4210dae4
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/github/codeql/pull/22703/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgithub%2Fcodeql%2Fpull%2F22703%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgithub%2Fcodeql%2Fpull%2F22703%2Ffiles
Sign uphttps://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=github%2Fcodeql
Reloadhttps://github.com/github/codeql/pull/22703/files
Reloadhttps://github.com/github/codeql/pull/22703/files
Reloadhttps://github.com/github/codeql/pull/22703/files
githubhttps://github.com/github
codeqlhttps://github.com/github/codeql
Codehttps://github.com/github/codeql
Issues1k (1k)https://github.com/github/codeql/issues
Pull requests516 (516)https://github.com/github/codeql/pulls
Discussionshttps://github.com/github/codeql/discussions
Actionshttps://github.com/github/codeql/actions
Projectshttps://github.com/github/codeql/projects
Security and qualityhttps://github.com/github/codeql/security
Insightshttps://github.com/github/codeql/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fgithub%2Fcodeql%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fgithub%2Fcodeql%2Fissues%2Fnew%2Fchoose
owen-mchttps://github.com/owen-mc
github:mainhttps://github.com/github/codeql/tree/main
Alex-Hofer:python-mcp-modelshttps://github.com/Alex-Hofer/codeql/tree/python-mcp-models
Conversation 35 https://github.com/github/codeql/pull/22703
Commits 7 https://github.com/github/codeql/pull/22703/commits
Checks 9 https://github.com/github/codeql/pull/22703/checks
Findings https://github.com/github/codeql/pull/22703/findings
Files changed https://github.com/github/codeql/pull/22703/files
Please reload this pagehttps://github.com/github/codeql/pull/22703/files
Python: Add models for the MCP server SDKs (mcp, fastmcp) https://github.com/github/codeql/pull/22703/files#top
Show all changes 7 commits https://github.com/github/codeql/pull/22703/files
c971b01 Python: Add models for the MCP server SDKs (mcp, fastmcp) Alex-Hofer Sep 30, 2026 https://github.com/github/codeql/pull/22703/commits/c971b0147f2a817da73137ae604f3eb62c7153b8
1c9b296 Python: Use the ai threat model for MCP handler input Alex-Hofer Oct 15, 2026 https://github.com/github/codeql/pull/22703/commits/1c9b2968ede3ed7455c15f90d93f4b87d9a50b58
8933961 Merge branch 'main' into python-mcp-models Alex-Hofer Nov 2, 2026 https://github.com/github/codeql/pull/22703/commits/8933961051f6d6b3918985fe9dcdca13a5b0dcd4
f215487 Python: Model MCP handler parameters in QL Alex-Hofer Nov 4, 2026 https://github.com/github/codeql/pull/22703/commits/f215487ce76132a8426f573a89a2184e0a3d33f2
3c696d2 Python: Refine the MCP Context and receiver exclusions Alex-Hofer Nov 5, 2026 https://github.com/github/codeql/pull/22703/commits/3c696d21b28de3a78975a8c9270fb8f292a95983
9f19700 Python: Resolve MCP Context names and typing wrappers through imports Alex-Hofer Nov 5, 2026 https://github.com/github/codeql/pull/22703/commits/9f19700417d07cdb56e929f06651155d011b9095
ee09e6e Python: Resolve quoted typing wrappers of MCP Context through imports Alex-Hofer Nov 9, 2026 https://github.com/github/codeql/pull/22703/commits/ee09e6eaae88bffa4e32560166fc37270768c124
Clear filters https://github.com/github/codeql/pull/22703/files
Please reload this pagehttps://github.com/github/codeql/pull/22703/files
Please reload this pagehttps://github.com/github/codeql/pull/22703/files
2026-09-30-mcp-models.md https://github.com/github/codeql/pull/22703/files#diff-866da422b16da235b99873c016fb2892874c9c981ed7187fe3bf8f1e093ab4d9
Frameworks.qll https://github.com/github/codeql/pull/22703/files#diff-29692e4114f44187490ab5c3a2b9c937ffd91123fc3bbd9298aae38a09a2e256
Mcp.qll https://github.com/github/codeql/pull/22703/files#diff-daaccb2759cc0d3e13a2adc46b0459b93d5ae6459eef3f58163226253f8666a9
fastmcp.model.yml https://github.com/github/codeql/pull/22703/files#diff-b11be957058e16a16cee58982dfbdddbe1f7195ac18a17656a287c05bceda7c1
mcp.model.yml https://github.com/github/codeql/pull/22703/files#diff-e04c639f6cf2c359598042dac0609cddd16b409c581a5cd20bcef4b2917aec20
ConceptsTest.expected https://github.com/github/codeql/pull/22703/files#diff-145dd5fbec67348c6b9908568bdb2a7cfcca30afc4a6cef6d4808d76462e3921
ConceptsTest.ql https://github.com/github/codeql/pull/22703/files#diff-554936c47c94d79a51d75095aacb0932630f1109b2940842e084818921a28b50
MaDTest.expected https://github.com/github/codeql/pull/22703/files#diff-0aab1c44d14c8fc0a09e737af1a277219de37be6690f1f37ed9ffae45f79526d
MaDTest.ql https://github.com/github/codeql/pull/22703/files#diff-3c71a61752b28dd00f0444248d91584cd13461d9ca3cb6d56dfa627487725b95
aliases.py https://github.com/github/codeql/pull/22703/files#diff-b5f205c80b04fae260ed67fa49fc8eedbcdf47e0788be515f562e0e12e955005
shadowed.py https://github.com/github/codeql/pull/22703/files#diff-95220cc273d13b011cad074ee918063f923652f5a10d39eae2adcab7e60fc7a3
test.py https://github.com/github/codeql/pull/22703/files#diff-fb7d5f8b4d83d62a8e27dfdb537d1abbc7d6ab5b1e79aed82dcad7133e21c58a
ConceptsTest.expected https://github.com/github/codeql/pull/22703/files#diff-14aba265411593b7b2dde861ebdd0009fa3356ea3b92bddb6aa5a2ed334aad06
ConceptsTest.ql https://github.com/github/codeql/pull/22703/files#diff-77cd6091f704b408cf978d5fb34546d99549e28c9f22842735a212a2965e17bb
MaDTest.expected https://github.com/github/codeql/pull/22703/files#diff-3bfc8ac13d93968df86376afe95b4477422195c47a992bcfd2d75b574e676bd6
MaDTest.ql https://github.com/github/codeql/pull/22703/files#diff-9685cc3ca9e5737ee2018f3bc40b5612ed3c68590994ad2cbedb3d3f52125e5f
auth.py https://github.com/github/codeql/pull/22703/files#diff-eafc7484cd2a393752591b87f2d42097251747e84610ead2be2395ff38f75c7f
fastmcp_v1.py https://github.com/github/codeql/pull/22703/files#diff-e3065dbee50ed5e778818ff186c57bc3a72f9a8b7e3e2e1314a520e04137feb3
lowlevel_v1.py https://github.com/github/codeql/pull/22703/files#diff-5459526714478f2ac518dcfad19cd8b73b62b0763a45fefe254890e9029fb20f
lowlevel_v2.py https://github.com/github/codeql/pull/22703/files#diff-69b4fef77fc8aa567af107a6608661435d25484c4a994a2e123e9bb9ead62bb3
mcpserver_v2.py https://github.com/github/codeql/pull/22703/files#diff-58c237e8af8a1f80270fc0c020702c0041e9f82810da3a2e711c9626fad0631f
https://github.com/github/codeql/blob/main/CODEOWNERS#L18
python/ql/lib/change-notes/2026-09-30-mcp-models.mdhttps://github.com/github/codeql/pull/22703/files#diff-866da422b16da235b99873c016fb2892874c9c981ed7187fe3bf8f1e093ab4d9
View file https://github.com/Alex-Hofer/codeql/blob/ee09e6eaae88bffa4e32560166fc37270768c124/python/ql/lib/change-notes/2026-09-30-mcp-models.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/github/codeql/pull/22703/{{ revealButtonHref }}
https://github.com/github/codeql/blob/main/CODEOWNERS#L18
python/ql/lib/semmle/python/Frameworks.qllhttps://github.com/github/codeql/pull/22703/files#diff-29692e4114f44187490ab5c3a2b9c937ffd91123fc3bbd9298aae38a09a2e256
View file https://github.com/Alex-Hofer/codeql/blob/ee09e6eaae88bffa4e32560166fc37270768c124/python/ql/lib/semmle/python/Frameworks.qll
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/github/codeql/pull/22703/{{ revealButtonHref }}
https://github.com/github/codeql/pull/22703/files#diff-29692e4114f44187490ab5c3a2b9c937ffd91123fc3bbd9298aae38a09a2e256
https://github.com/github/codeql/pull/22703/files#diff-29692e4114f44187490ab5c3a2b9c937ffd91123fc3bbd9298aae38a09a2e256
https://github.com/github/codeql/blob/main/CODEOWNERS#L18
python/ql/lib/semmle/python/frameworks/Mcp.qllhttps://github.com/github/codeql/pull/22703/files#diff-daaccb2759cc0d3e13a2adc46b0459b93d5ae6459eef3f58163226253f8666a9
View file https://github.com/Alex-Hofer/codeql/blob/ee09e6eaae88bffa4e32560166fc37270768c124/python/ql/lib/semmle/python/frameworks/Mcp.qll
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/github/codeql/pull/22703/{{ revealButtonHref }}
https://github.com/github/codeql/blob/main/CODEOWNERS#L18
python/ql/lib/semmle/python/frameworks/fastmcp.model.ymlhttps://github.com/github/codeql/pull/22703/files#diff-b11be957058e16a16cee58982dfbdddbe1f7195ac18a17656a287c05bceda7c1
View file https://github.com/Alex-Hofer/codeql/blob/ee09e6eaae88bffa4e32560166fc37270768c124/python/ql/lib/semmle/python/frameworks/fastmcp.model.yml
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/github/codeql/pull/22703/{{ revealButtonHref }}
https://github.com/github/codeql/blob/main/CODEOWNERS#L18
python/ql/lib/semmle/python/frameworks/mcp.model.ymlhttps://github.com/github/codeql/pull/22703/files#diff-e04c639f6cf2c359598042dac0609cddd16b409c581a5cd20bcef4b2917aec20
View file https://github.com/Alex-Hofer/codeql/blob/ee09e6eaae88bffa4e32560166fc37270768c124/python/ql/lib/semmle/python/frameworks/mcp.model.yml
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/github/codeql/pull/22703/{{ revealButtonHref }}
https://github.com/github/codeql/blob/main/CODEOWNERS#L18
python/ql/test/library-tests/frameworks/fastmcp/ConceptsTest.expectedhttps://github.com/github/codeql/pull/22703/files#diff-145dd5fbec67348c6b9908568bdb2a7cfcca30afc4a6cef6d4808d76462e3921
View file https://github.com/Alex-Hofer/codeql/blob/ee09e6eaae88bffa4e32560166fc37270768c124/python/ql/test/library-tests/frameworks/fastmcp/ConceptsTest.expected
Open in desktop https://desktop.github.com
https://github.com/github/codeql/blob/main/CODEOWNERS#L18
python/ql/test/library-tests/frameworks/fastmcp/ConceptsTest.qlhttps://github.com/github/codeql/pull/22703/files#diff-554936c47c94d79a51d75095aacb0932630f1109b2940842e084818921a28b50
View file https://github.com/Alex-Hofer/codeql/blob/ee09e6eaae88bffa4e32560166fc37270768c124/python/ql/test/library-tests/frameworks/fastmcp/ConceptsTest.ql
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/github/codeql/pull/22703/{{ revealButtonHref }}
https://github.com/github/codeql/blob/main/CODEOWNERS#L18
python/ql/test/library-tests/frameworks/fastmcp/MaDTest.expectedhttps://github.com/github/codeql/pull/22703/files#diff-0aab1c44d14c8fc0a09e737af1a277219de37be6690f1f37ed9ffae45f79526d
View file https://github.com/Alex-Hofer/codeql/blob/ee09e6eaae88bffa4e32560166fc37270768c124/python/ql/test/library-tests/frameworks/fastmcp/MaDTest.expected
Open in desktop https://desktop.github.com
https://github.com/github/codeql/blob/main/CODEOWNERS#L18
python/ql/test/library-tests/frameworks/fastmcp/MaDTest.qlhttps://github.com/github/codeql/pull/22703/files#diff-3c71a61752b28dd00f0444248d91584cd13461d9ca3cb6d56dfa627487725b95
View file https://github.com/Alex-Hofer/codeql/blob/ee09e6eaae88bffa4e32560166fc37270768c124/python/ql/test/library-tests/frameworks/fastmcp/MaDTest.ql
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/github/codeql/pull/22703/{{ revealButtonHref }}
Please reload this pagehttps://github.com/github/codeql/pull/22703/files
Please reload this pagehttps://github.com/github/codeql/pull/22703/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.