René's URL Explorer Experiment


Title: Validate an explicit null structuredContent against the output schema by maxisbey · Pull Request #3621 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: Validate an explicit null structuredContent against the output schema by maxisbey · Pull Request #3621 · modelcontextprotocol/python-sdk

X Title: Validate an explicit null structuredContent against the output schema by maxisbey · Pull Request #3621 · modelcontextprotocol/python-sdk

Description: Fixes #3345. What was wrong When a tool declares an output schema and the server returns "structuredContent": null, the client raised Tool ... has an output schema but did not return structured content without checking the schema. An explicit null and a field that was left out were treated as the same thing. The 2026-07-28 schema lists null as a legal structuredContent value: "any JSON value (object, array, string, number, boolean, or null) that conforms to the tool's outputSchema" (schema.ts). A server returning null for a tool whose schema allows null is conformant, and the client rejected its result. 0, false and "" were already validated. Null was the only JSON value treated as "nothing". The TypeScript SDK treats the result as missing only when the field is undefined, and validates null (client.ts). The Go and Rust SDKs also keep null distinct from absent. What changes One condition in ClientSession.validate_tool_result: structured content counts as missing only when the value is None and the field was not set on the result (model_fields_set). An explicit null now reaches the existing schema validation like any other value. No new names, parameters or defaults. Nothing changes on the wire. What users will notice Only results with an explicit null structuredContent, for a tool that declares an output schema, behave differently: The schema allows null: the call used to raise and now returns the result. The schema does not constrain the top-level type ({}, or properties without type): the call used to raise and now returns the result, because null is valid against such a schema. The schema does not allow null: the call still raises RuntimeError, with a different message. Before: Tool ... has an output schema but did not return structured content After: Invalid structured content returned by tool ...: None is not of type ... This also applies on sessions using earlier protocol versions. A CallToolResult built in code with structured_content=None passed explicitly counts as an explicit null too. This applies when it is passed to validate_tool_result directly, or returned by an extension's result resolver. CallToolResult(content=[...]) without the argument is still "missing". Unchanged: A result with no structuredContent field still raises the "did not return structured content" error, whatever the schema allows. isError results and tools without an output schema are still not validated. Not included A server built on this SDK still leaves a null structuredContent off the wire, so it cannot return a top-level null result itself. That is a separate change on the sending side. How it was checked Three new tests in tests/client/test_session.py drive ClientSession.call_tool on a 2026-07-28 session against scripted wire results, since an SDK server cannot produce the null: null against a schema that allows it is returned null against a schema that does not is a schema mismatch an absent field against a schema that allows null is still "missing" The first two fail on main and pass with the change; the third passes on both. ./scripts/test passes with 100% coverage; ruff and pyright are clean. AI Disclaimer

Open Graph Description: Fixes #3345. What was wrong When a tool declares an output schema and the server returns "structuredContent": null, the client raised Tool ... has an output schema but did not return stru...

X Description: Fixes #3345. What was wrong When a tool declares an output schema and the server returns "structuredContent": null, the client raised Tool ... has an output schema but did not ret...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.4

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:afd2062a-191a-f967-a234-eb745a6c39a3
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idCDAA:FCC28:11AE2F7:1837F5A:6B056647
html-safe-nonce6793912c7edfddcea4c0ce79a3a5c12bfe49f97a1316b1256740886e5a1b48c7
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDREFBOkZDQzI4OjExQUUyRjc6MTgzN0Y1QTo2QjA1NjY0NyIsInZpc2l0b3JfaWQiOiIxNTg0ODY1NDQzOTQzMTE0MzExIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac8440b6f7625ca2c4563e7c723a6bfc50bc245f5663136d4da632b31b178c1860
hovercard-subject-tagpull_request:4716303121
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/3621/files
twitter:imagehttps://avatars.githubusercontent.com/u/224885523?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/224885523?s=400&v=4
og:image:altFixes #3345. What was wrong When a tool declares an output schema and the server returns "structuredContent": null, the client raised Tool ... has an output schema but did not return stru...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None1be5cc09efdd4833c24a4ffa71d698e3999fa09071e159fe14c2c08e41c98331
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
releasef6d69234e682c947a48074340e69d45d5901de31
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/3621/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3621%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%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3621%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=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3621/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3621/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3621/files
modelcontextprotocolhttps://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Codehttps://github.com/modelcontextprotocol/python-sdk
Issues320 (320)https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests112 (112)https://github.com/modelcontextprotocol/python-sdk/pulls
Actionshttps://github.com/modelcontextprotocol/python-sdk/actions
Projectshttps://github.com/modelcontextprotocol/python-sdk/projects
Security and quality12 (12)https://github.com/modelcontextprotocol/python-sdk/security
Insightshttps://github.com/modelcontextprotocol/python-sdk/insights
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
mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
3345-null-structured-contenthttps://github.com/modelcontextprotocol/python-sdk/tree/3345-null-structured-content
Conversation 5 https://github.com/modelcontextprotocol/python-sdk/pull/3621
Commits 1 https://github.com/modelcontextprotocol/python-sdk/pull/3621/commits
Checks 37 https://github.com/modelcontextprotocol/python-sdk/pull/3621/checks
Files changed 2 https://github.com/modelcontextprotocol/python-sdk/pull/3621/files
Validate an explicit null structuredContent against the output schema https://github.com/modelcontextprotocol/python-sdk/pull/3621/files#top
Show all changes 1 commit https://github.com/modelcontextprotocol/python-sdk/pull/3621/files
9026b41 Validate an explicit null structuredContent against the output schema maxisbey Oct 2, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/3621/commits/9026b4138894c58482188e2410921e7c00d2e200
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/3621/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3621/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3621/files
session.py https://github.com/modelcontextprotocol/python-sdk/pull/3621/files#diff-634d1abcb8bda1a784f31e3431a10124e387f487dd243a54244515b4972aa0ee
test_session.py https://github.com/modelcontextprotocol/python-sdk/pull/3621/files#diff-623490a9c2dd576cc59e89f8d51f64acfffdeaad940e0bd4a0a51a50bc30d92d
src/mcp/client/session.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3621/files#diff-634d1abcb8bda1a784f31e3431a10124e387f487dd243a54244515b4972aa0ee
View file https://github.com/modelcontextprotocol/python-sdk/blob/9026b4138894c58482188e2410921e7c00d2e200/src/mcp/client/session.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3621/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3621/files#diff-634d1abcb8bda1a784f31e3431a10124e387f487dd243a54244515b4972aa0ee
claudehttps://github.com/apps/claude
Oct 2, 2026https://github.com/modelcontextprotocol/python-sdk/pull/3621/files#r4165634523
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3621/files
claudehttps://github.com/apps/claude
Oct 2, 2026https://github.com/modelcontextprotocol/python-sdk/pull/3621/files#r4165634529
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
449070chttps://github.com/modelcontextprotocol/python-sdk/commit/449070c15656a8d8c0fe75e2790e71f1033689a5
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3621/files
https://github.com/modelcontextprotocol/python-sdk/pull/3621/files#diff-634d1abcb8bda1a784f31e3431a10124e387f487dd243a54244515b4972aa0ee
tests/client/test_session.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3621/files#diff-623490a9c2dd576cc59e89f8d51f64acfffdeaad940e0bd4a0a51a50bc30d92d
View file https://github.com/modelcontextprotocol/python-sdk/blob/9026b4138894c58482188e2410921e7c00d2e200/tests/client/test_session.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3621/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3621/files#diff-623490a9c2dd576cc59e89f8d51f64acfffdeaad940e0bd4a0a51a50bc30d92d
https://github.com/modelcontextprotocol/python-sdk/pull/3621/files#diff-623490a9c2dd576cc59e89f8d51f64acfffdeaad940e0bd4a0a51a50bc30d92d
https://github.com/modelcontextprotocol/python-sdk/pull/3621/files#diff-623490a9c2dd576cc59e89f8d51f64acfffdeaad940e0bd4a0a51a50bc30d92d
claudehttps://github.com/apps/claude
Oct 2, 2026https://github.com/modelcontextprotocol/python-sdk/pull/3621/files#r4165634521
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3621/files
https://github.com/modelcontextprotocol/python-sdk/pull/3621/files#diff-623490a9c2dd576cc59e89f8d51f64acfffdeaad940e0bd4a0a51a50bc30d92d
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3621/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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.