load_mcp_server_info(
session: ClientSession | None,
*,
connection: Connection | None = None,
callbacks: | Name | Type | Description |
|---|---|---|
session* | ClientSession | None | An MCP client session that has not been initialized yet.
If provided, this function calls |
connection | Connection | None | Default: NoneConnection config to create a new session if |
callbacks | Callbacks | None | Default: NoneOptional |
server_name | str | None | Default: None |
Load server info from the MCP initialize handshake.
Returns the full InitializeResult from the MCP protocol, which includes
server instructions, capabilities, implementation details, and protocol
version.
Unlike load_mcp_tools,
load_mcp_prompt and
load_mcp_resources,
which expect an already-initialized session, this function performs the
initialize() handshake itself and therefore requires a session that has
not been initialized yet. MultiServerMCPClient.session() initializes
by default, so pass auto_initialize=False when obtaining a session for
this function. Passing an already-initialized session raises ValueError
rather than re-running the handshake.
There is no way to recover an InitializeResult from a session that is
already initialized: the MCP SDK caches only capabilities and discards
instructions, serverInfo and protocolVersion.
Name of the server, used for callback context. Ignored when
session is provided, for the same reason as callbacks.