Skip to content

Conversation

@kxbnb
Copy link

@kxbnb kxbnb commented Jan 23, 2026

Summary
Stores server_info from the init response on ClientSession so you can grab the server's name and version without manually extracting from the result.

Changes

  • Added _server_info field to ClientSession.__init__
  • Store result.server_info during initialize()
  • Added get_server_info() getter (mirrors existing get_server_capabilities())
  • Added test for the new method

Before

server = await session.initialize()
name = server.serverInfo.name  # had to grab manually

After

await session.initialize()
info = session.get_server_info()
name = info.name  # available directly

Testing

  • All existing tests pass
  • Added test_get_server_info covering None-before-init and populated-after

Closes #1018

Adds `_server_info` field to ClientSession that gets populated during
`initialize()` with the server's name and version from the response.

This follows the existing pattern for `_server_capabilities` and lets
clients access server info without manually extracting it from the
init result.

Closes modelcontextprotocol#1018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update _client_info on the ClientSession upon initialization with serverInfo

1 participant