Skip to content

Conversation

@crondinini-ant
Copy link
Contributor

Motivation and Context

Adds get_server_capabilities() method to ClientSession to provide access to server capabilities after initialization, matching the TypeScript SDK implementation.

Currently, the Python SDK returns InitializeResult from the initialize() method, but there's no way to access server capabilities later without storing that result manually. The TypeScript SDK provides getServerCapabilities() for this purpose, and this change brings the Python SDK to parity.

Changes

Implemented get_server_capabilities() method that:

  • Returns None before the session has been initialized
  • Returns the ServerCapabilities received during the MCP initialization handshake after initialize() completes
  • Allows clients to query available server features (logging, prompts, resources, tools, etc.) at any point during the session lifecycle

This enables clients to make runtime decisions based on server capabilities without needing to store the initialization result separately.

How Has This Been Tested?

Local tests

Breaking Changes

No breaking changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Copy link
Contributor

@felixweinberger felixweinberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@felixweinberger felixweinberger merged commit 9eae96a into main Nov 6, 2025
21 checks passed
@felixweinberger felixweinberger deleted the crondinini/add-get-server-capabilities branch November 6, 2025 20:44
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.

3 participants