René's URL Explorer Experiment


Title: find_context_parameter() fails to detect Context parameter in callable class instances · Issue #1974 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: find_context_parameter() fails to detect Context parameter in callable class instances · Issue #1974 · modelcontextprotocol/python-sdk

X Title: find_context_parameter() fails to detect Context parameter in callable class instances · Issue #1974 · modelcontextprotocol/python-sdk

Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue Description When registering a cal...

Open Graph Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...

X Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening t...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"find_context_parameter() fails to detect Context parameter in callable class instances","articleBody":"### Initial Checks\n\n- [x] I confirm that I'm using the latest version of MCP Python SDK\n- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue\n\n### Description\n\nWhen registering a callable class instance as an MCP tool via FastMCP.add_tool(), the ctx: Context parameter is incorrectly exposed as an externally visible tool parameter instead of being injected by the framework. This is because find_context_parameter() uses typing.get_type_hints() which doesn't introspect the __call__ method of callable class instances.\n\nSuggested Fix\nUpdate find_context_parameter() to handle callable class instances:\n```\ndef find_context_parameter(fn: Callable[..., Any]) -> str | None:\n    from mcp.server.fastmcp.server import Context\n\n    # Handle callable class instances by using __call__ method\n    target = fn\n    if not (inspect.isfunction(fn) or inspect.ismethod(fn)):\n        if callable(fn) and hasattr(fn, \"__call__\"):\n            target = fn.__call__\n\n    try:\n        hints = typing.get_type_hints(target)\n    except Exception:\n        return None\n\n    # ... rest of function unchanged\n```\n\n### Example Code\n\n```Python\nfrom typing import Annotated, Any\nfrom mcp.server.fastmcp import Context, FastMCP\nfrom mcp.server.session import ServerSession\nfrom starlette.requests import Request\nimport pydantic\n\nclass MyTool:\n    def __init__(self, name: str):\n        self.__name__ = name\n\n    async def __call__(\n        self,\n        query: Annotated[str, pydantic.Field(description=\"Search query\")],\n        ctx: Context[ServerSession, Any, Request],\n    ) -> str:\n        \"\"\"Performs a search.\"\"\"\n        return f\"Results for: {query}\"\n\nmcp = FastMCP(name=\"Test Server\")\nmcp.add_tool(MyTool(name=\"my_search\"), name=\"my_search\", description=\"Search tool\")\n\n# When listing tools, 'ctx' appears as a required parameter in the schema\n```\n\n### Python & MCP Python SDK\n\n```Text\n1.26.0\n```","author":{"url":"https://github.com/mjahr","@type":"Person","name":"mjahr"},"datePublished":"2026-01-30T01:24:08Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/1974"}

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:8df69407-d392-af40-f05f-cb95ca2956a8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD318:29EEB8:CC430:11B67D:6B056B9D
html-safe-noncefe52251dc2e195e41c8f75de79c7d67f70ee34803f6c489f68c9e519ceff512c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzE4OjI5RUVCODpDQzQzMDoxMUI2N0Q6NkIwNTZCOUQiLCJ2aXNpdG9yX2lkIjoiOTAyNDI2MTUzODEwNTg3OTQ1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacff13d28ad1eebc8b75387bff64cb10badb9f241c6caf9ca926b0e7d1e687d47d
hovercard-subject-tagissue:3873365288
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/1974/issue_layout
twitter:imagehttps://opengraph.githubassets.com/755a13a86d4a377b98b4d4408a9c5ed301840bcc6fb0d0825746d58c5df286fa/modelcontextprotocol/python-sdk/issues/1974
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/755a13a86d4a377b98b4d4408a9c5ed301840bcc6fb0d0825746d58c5df286fa/modelcontextprotocol/python-sdk/issues/1974
og:image:altInitial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemjahr
hostnamegithub.com
expected-hostnamegithub.com
None9b4256ac5f3e310e7945ef5b71c9cb9e264357b1eb20e91d369ed6502a4c486c
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
releasef089e689ad324655ac44bf6cdbc04d976105b374
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/1974#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F1974
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%2F1974
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/1974
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/1974
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/1974
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
https://github.com/modelcontextprotocol/python-sdk
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/1974
New issuehttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/1974
#2623https://github.com/modelcontextprotocol/python-sdk/pull/2623
find_context_parameter() fails to detect Context parameter in callable class instanceshttps://github.com/modelcontextprotocol/python-sdk/issues/1974#top
#2623https://github.com/modelcontextprotocol/python-sdk/pull/2623
P3https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P3%22
bughttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v2https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
https://github.com/mjahr
mjahrhttps://github.com/mjahr
on Jan 30, 2026https://github.com/modelcontextprotocol/python-sdk/issues/1974#issue-3873365288
https://github.com/modelcontextprotocol/python-sdk/issueshttps://github.com/modelcontextprotocol/python-sdk/issues
maxisbeyhttps://github.com/maxisbey
bughttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
P3https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P3%22
v2https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22v2%22
on Feb 10, 2026https://github.com/modelcontextprotocol/python-sdk/issues/1974#event-22679313492
https://github.com/maxisbey
maxisbeyhttps://github.com/maxisbey
on Feb 10, 2026https://github.com/modelcontextprotocol/python-sdk/issues/1974#issuecomment-3879029697
#1684https://github.com/modelcontextprotocol/python-sdk/issues/1684
AI Disclaimerhttps://gist.github.com/maxisbey/6123d132484e4c533eab519a2800693d
hashwnathhttps://github.com/hashwnath
on Feb 12, 2026https://github.com/modelcontextprotocol/python-sdk/issues/1974#event-22726305131
fix: handle callable class instances in find_context_parameter()https://github.com/hashwnath/python-sdk/commit/2ed8c3ffc25ac93613cf74d247657f2d8b90c507
https://docs.github.com/articles/closing-issues-via-commit-messages
2ed8c3fhttps://github.com/hashwnath/python-sdk/commit/2ed8c3ffc25ac93613cf74d247657f2d8b90c507
Sign up for freehttps://github.com/signup?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/1974
Sign in to commenthttps://github.com/login?return_to=https://github.com/modelcontextprotocol/python-sdk/issues/1974
P3https://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22P3%22
bughttps://github.com/modelcontextprotocol/python-sdk/issues?q=state%3Aopen%20label%3A%22bug%22
v2https://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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.