MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / _handle_discover

Method _handle_discover

src/mcp/server/lowlevel/server.py:403–419  ·  view source on GitHub ↗

Default `server/discover` handler. Auto-derived from server state at call time, so capabilities reflect whatever has been registered (constructor `on_*` kwargs and later `add_request_handler` calls). Operators can replace it wholesale via `add_request_handler("server

(
        self, ctx: ServerRequestContext[LifespanResultT], params: types.RequestParams | None
    )

Source from the content-addressed store, hash-verified

401 )
402
403 async def _handle_discover(
404 self, ctx: ServerRequestContext[LifespanResultT], params: types.RequestParams | None
405 ) -> types.DiscoverResult:
406 """Default `server/discover` handler.
407
408 Auto-derived from server state at call time, so capabilities reflect
409 whatever has been registered (constructor `on_*` kwargs and later
410 `add_request_handler` calls). Operators can replace it wholesale via
411 `add_request_handler("server/discover", ...)`. Reachability for legacy
412 peers is decided at the boundary (`types.methods`), not here.
413 """
414 return types.DiscoverResult(
415 supported_versions=list(MODERN_PROTOCOL_VERSIONS),
416 capabilities=self.get_capabilities(),
417 server_info=self.server_info,
418 instructions=self.instructions,
419 )
420
421 @property
422 def session_manager(self) -> StreamableHTTPSessionManager:

Callers

nothing calls this directly

Calls 1

get_capabilitiesMethod · 0.95

Tested by

no test coverage detected