René's URL Explorer Experiment


Title: ClientSession.call_tool issues a tools/list after every tools/call when the output-schema cache is empty — no opt-out; doubles round-trips on per-call sessions · Issue #3513 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: ClientSession.call_tool issues a tools/list after every tools/call when the output-schema cache is empty — no opt-out; doubles round-trips on per-call sessions · Issue #3513 · modelcontextprotocol/python-sdk

X Title: ClientSession.call_tool issues a tools/list after every tools/call when the output-schema cache is empty — no opt-out; doubles round-trips on per-call sessions · Issue #3513 · modelcontextprotocol/python-sdk

Description: Summary ClientSession.call_tool() issues a tools/list request after every successful tools/call whenever the called tool is not in the session's output-schema cache. On a short-lived session — one ClientSession per tools/call, the patter...

Open Graph Description: Summary ClientSession.call_tool() issues a tools/list request after every successful tools/call whenever the called tool is not in the session's output-schema cache. On a short-lived session — one ...

X Description: Summary ClientSession.call_tool() issues a tools/list request after every successful tools/call whenever the called tool is not in the session's output-schema cache. On a short-lived session — ...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3513

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ClientSession.call_tool issues a tools/list after every tools/call when the output-schema cache is empty — no opt-out; doubles round-trips on per-call sessions","articleBody":"### Summary\n\n`ClientSession.call_tool()` issues a **`tools/list` request after every successful `tools/call`** whenever the called tool is not in the session's output-schema cache. On a short-lived session — one `ClientSession` per `tools/call`, the pattern gateways and proxies use when the downstream caller is stateless — the cache is empty on every call, so every `call_tool` costs two round-trips instead of one (`initialize` + `notifications/initialized` + `tools/call` + **`tools/list`** = 4 POSTs on Streamable HTTP instead of 3).\n\nWhen the server behind the session is itself an aggregator whose `tools/list` fans out to N backends, the extra request is N upstream calls, and the slowest backend's `tools/list` latency is added to *every* `call_tool` — including calls to tools that declare no `outputSchema` and have nothing to validate.\n\nThere is no way to opt out short of subclassing `ClientSession` or patching the method.\n\n### Where\n\n`mcp` 1.29.1, `src/mcp/client/session.py`:\n\n```python\n# :386-415\nasync def call_tool(self, name, arguments=None, read_timeout_seconds=None, progress_callback=None, *, meta=None):\n    ...\n    result = await self.send_request(...)\n    if not result.isError:\n        await self._validate_tool_result(name, result)\n    return result\n\n# :417-421\nasync def _validate_tool_result(self, name: str, result: types.CallToolResult) -> None:\n    \"\"\"Validate the structured content of a tool result against its output schema.\"\"\"\n    if name not in self._tool_output_schemas:\n        # refresh output schema cache\n        await self.list_tools()\n    ...\n```\n\nStill present on `main` @ `6affe5c0` (2026-09-16) as the public `validate_tool_result`, `:1118-1127` — the cache is populated only by `list_tools()` (`_absorb_tool_listing`), and `_tool_output_schemas` is per-`ClientSession`, so a fresh session always pays the refresh.\n\n### Reproduction\n\n```python\nimport anyio\nfrom mcp import ClientSession\nfrom mcp.client.streamable_http import streamablehttp_client\n\nasync def main():\n    async with streamablehttp_client(\"http://127.0.0.1:8000/mcp\") as (r, w, _):\n        async with ClientSession(r, w) as s:\n            await s.initialize()\n            await s.call_tool(\"echo\", {\"text\": \"hi\"})   # server access log: POST initialize, POST initialized, POST tools/call, POST tools/list\n\nanyio.run(main)\n```\n\nAny FastMCP server with a tool that returns unstructured content shows the fourth POST. Measured against a proxy whose `tools/list` fans out to six backends: `call_tool` wall time p50 ≈ 3 s / p99 ≈ 36 s through the proxy vs p99 0.24 s calling the backend directly — the gap is entirely the post-result `tools/list` waiting on the slowest backend.\n\n### Proposed change (any of these would do)\n\n1. **A constructor opt-out**, e.g. `ClientSession(..., validate_tool_results: bool = True)`; when `False`, `call_tool` returns the result without calling `validate_tool_result`. Callers that already validate structured output elsewhere (a gateway with its own schema plugin, a server that validates before responding) can turn the client-side re-validation off.\n2. **Do not refresh on an empty cache.** If the session has never listed tools, `validate_tool_result` cannot know whether the tool has an `outputSchema`; today it spends a round-trip to find out. Skipping the refresh when `not self._tool_output_schemas` (and keeping it when the cache is populated but lacks the tool — a tool added since the last listing) removes the cost on per-call sessions while leaving long-lived sessions unchanged. A DEBUG log line on the skip keeps it observable.\n3. **Validate only when the result carries `structuredContent`.** A result with no `structuredContent` from a tool with no cached schema has nothing to check; the refresh then only serves to raise `RuntimeError(\"… has an output schema but did not return structured content\")` for a tool the client never listed — a stricter contract than the server side enforces.\n\nOption 2 is what we are running as a build-time patch on a vendored 1.29.1 (one three-line hunk in `_validate_tool_result`); happy to open a PR for whichever shape the maintainers prefer.\n\n### Environment\n\n- `mcp` 1.29.1 (Python 3.12); also reproduces on `main` @ `6affe5c0`\n- Transport: Streamable HTTP, stateless server (no `Mcp-Session-Id`), one `ClientSession` per call\n","author":{"url":"https://github.com/godwinbw-egm","@type":"Person","name":"godwinbw-egm"},"datePublished":"2026-09-16T21:03:09Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3513"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:469ca47f-405c-33a3-5552-62144c0dddfd
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8CA8:65478:136D6F9:19D3759:6B0123A4
html-safe-nonce17f9c3558bf27c3a45220d1896f86ab9f3dfcf84af8a4f197ab3760dec7e0d2f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0E4OjY1NDc4OjEzNkQ2Rjk6MTlEMzc1OTo2QjAxMjNBNCIsInZpc2l0b3JfaWQiOiIzMzcwNzQ5Mzc0MzE2NDg3NTg4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacc897e2fa25e0d574d8920cb41247c3711c55a300c14eaaf80c6bb43e5eaa9960
hovercard-subject-tagissue:5479896193
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/3513/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a963533547cec64570ee39e7d23c65a65b9538fad1de05fd2f7c252509934901/modelcontextprotocol/python-sdk/issues/3513
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a963533547cec64570ee39e7d23c65a65b9538fad1de05fd2f7c252509934901/modelcontextprotocol/python-sdk/issues/3513
og:image:altSummary ClientSession.call_tool() issues a tools/list request after every successful tools/call whenever the called tool is not in the session's output-schema cache. On a short-lived session — one ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegodwinbw-egm
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/3513#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F3513
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%2Fissues%2F3513
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3513
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3513
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/3513
modelcontextprotocolhttps://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Codehttps://github.com/modelcontextprotocol/python-sdk
Issues310 (310)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
https://github.com/modelcontextprotocol/python-sdk
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3513
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3513
ClientSession.call_tool issues a tools/list after every tools/call when the output-schema cache is empty — no opt-out; doubles round-trips on per-call sessionshttps://github.com/modelcontextprotocol/python-sdk/issues/3513#top
enhancementRequest for a new feature that's not currently supportedhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22enhancement%22
v1Affects the v1.x maintenance linehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
https://github.com/godwinbw-egm
godwinbw-egmhttps://github.com/godwinbw-egm
on Sep 16, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3513#issue-5479896193
claudehttps://github.com/apps/claude
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
v1Affects the v1.x maintenance linehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
on Sep 16, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3513#event-31277893372
https://github.com/AdhamKhalifa
AdhamKhalifahttps://github.com/AdhamKhalifa
on Sep 19, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3513#issuecomment-5745846999
claudehttps://github.com/apps/claude
enhancementRequest for a new feature that's not currently supportedhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22enhancement%22
on Oct 8, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3513#event-32781147698
timothybrushhttps://github.com/timothybrush
on Nov 6, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3513#event-35389090410
fix(mcp): skip redundant tools/list fetch on individual tool calls [e…https://github.com/timothybrush/onyx/commit/d25642418bcca41b8c10ff41809f164513fe9db5
d256424https://github.com/timothybrush/onyx/commit/d25642418bcca41b8c10ff41809f164513fe9db5
Weveshttps://github.com/Weves
on Nov 7, 2026https://github.com/modelcontextprotocol/python-sdk/issues/3513#event-35428691803
fix(mcp): skip redundant tools/list fetch on individual tool calls [e…https://github.com/onyx-dot-app/onyx-foss/commit/7f01dfbe13dedb17cfe8a2ee134ef1a1258eb36b
7f01dfbhttps://github.com/onyx-dot-app/onyx-foss/commit/7f01dfbe13dedb17cfe8a2ee134ef1a1258eb36b
Sign up for freehttps://github.com/signup?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3513
Sign in to commenthttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/3513
enhancementRequest for a new feature that's not currently supportedhttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22enhancement%22
v1Affects the v1.x maintenance linehttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v1%22
v2Affects the v2 line (2.x on main)https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
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.