{"record":{"id":"f2a274557c330592","repo":"PrefectHQ/fastmcp","slug":"method-not-found","errorCode":"METHOD_NOT_FOUND","errorMessage":"Method {binding.method!r} is not available at protocol version {ctx.protocol_version!r}.","messagePattern":"Method (.+?) is not available at protocol version (.+?)\\.","errorType":"error_code","errorClass":"MCPError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/server/extensions.py","lineNumber":265,"sourceCode":"\n\ndef build_method_handler(binding: MethodBinding) -> ExtensionRequestHandler:\n    \"\"\"Wrap a `MethodBinding` into a low-level request handler.\n\n    The adapter enforces `protocol_versions` gating (rejecting other versions as\n    `METHOD_NOT_FOUND`, since `add_request_handler` registers unconditionally)\n    and binds the FastMCP request context so the handler can use `get_context()`,\n    auth, and other request-scoped dependencies.\n    \"\"\"\n\n    async def handler(\n        ctx: ServerRequestContext[Any, Any], params: Any\n    ) -> BaseModel | dict[str, Any] | None:\n        if (\n            binding.protocol_versions is not None\n            and ctx.protocol_version not in binding.protocol_versions\n        ):\n            raise MCPError(\n                code=METHOD_NOT_FOUND,\n                message=(\n                    f\"Method {binding.method!r} is not available at protocol \"\n                    f\"version {ctx.protocol_version!r}.\"\n                ),\n            )\n        with bind_request_context(ctx):\n            return await binding.handler(ctx, params)\n\n    return handler\n\n\ndef wrap_tool_call_interceptor(\n    extension: ServerExtension,\n    call_next: Callable[[Any], Awaitable[Any]],\n) -> Callable[[Any], Awaitable[Any]]:\n    \"\"\"Fold one extension's `intercept_tool_call` around a middleware `call_next`.\n","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/extensions.py#L247-L283","documentation":"When an extension method binding declares an explicit protocol_versions set, the dispatcher raises MCPError with code METHOD_NOT_FOUND if the current request's negotiated protocol version is not in that set. This mimics standard JSON-RPC 'method not found' semantics for version-gated extension methods.","triggerScenarios":"A client connected at a protocol version (ctx.protocol_version) outside binding.protocol_versions invokes the extension method; e.g. binding declared frozenset({'2025-06-18'}) but client negotiated '2024-11-05'.","commonSituations":"Older clients (or older SDKs) calling a new extension method gated to a newer spec version; servers narrowing protocol_versions during a version migration.","solutions":["Add the client's protocol version to the binding's protocol_versions set if the handler supports it.","Remove protocol_versions (None) to make the method available at all versions if there is no version-specific behavior.","Upgrade the client to a protocol version the binding supports.","Handle MCPError code METHOD_NOT_FOUND on the client and degrade gracefully."],"exampleFix":"// before\nMethodBinding(method=\"myext/export\", handler=h, params_type=P, protocol_versions=frozenset({\"2025-06-18\"}))\n// after\nMethodBinding(method=\"myext/export\", handler=h, params_type=P, protocol_versions=frozenset({\"2024-11-05\", \"2025-06-18\"}))","handlingStrategy":"try-catch","validationCode":"def supports_version(binding, version: str) -> bool:\n    return binding.protocol_versions is None or version in binding.protocol_versions","typeGuard":"def is_supported(binding, ctx) -> bool:\n    return binding.protocol_versions is None or ctx.protocol_version in binding.protocol_versions","tryCatchPattern":"try:\n    result = await call_extension_method(binding, ctx, params)\nexcept MCPError as e:\n    if e.code == METHOD_NOT_FOUND:\n        result = fallback_result()  # degrade gracefully\n    else:\n        raise","preventionTips":["Gate the client-side feature on the negotiated protocol version before calling","Omit protocol_versions if the handler works across versions","Keep client and server MCP SDK versions aligned"],"tags":["protocol-version","extensions","method-not-found"],"backgroundTag":"method-not-found","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}