Skip to content

feat: Propagate Context to eager connect via McpClientSession #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 26, 2025

Conversation

chemicL
Copy link
Member

@chemicL chemicL commented Jun 25, 2025

Motivation and Context

In order to allow the initial connection to have contextual information in the reactive chain, the McpClientSession should be able to transform the McpClientTransport#connect result, e.g. to attach Context items. This change introduces a new constructor for sessions that makes it possible.

How Has This Been Tested?

A new test specifically for validating the presence of a context item has been added.

Breaking Changes

Deprecating the old McpClientSession constructor.

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

N/A

In order to allow the initial connection to have contextual information
in the reactive chain, the McpClientSession should be able to transform
the McpClientTransport#connect result, e.g. to attach Context items.
This change introduces a new constructor for sessions that makes it
possible.

Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
@chemicL chemicL added this to the 0.11.0 milestone Jun 25, 2025
@chemicL chemicL added the enhancement New feature or request label Jun 25, 2025
@tzolov tzolov self-assigned this Jun 25, 2025
Copy link
Contributor

@tzolov tzolov left a comment

Choose a reason for hiding this comment

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

@chemicL Is there a way to verify that the context is being propagated through the reactive stream?

@chemicL
Copy link
Member Author

chemicL commented Jun 26, 2025

@tzolov Added a test to verify.

Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
@chemicL chemicL force-pushed the propagate-context-to-eager-connect branch from 6b001d2 to 3e1a889 Compare June 26, 2025 10:56
@tzolov
Copy link
Contributor

tzolov commented Jun 26, 2025

Thanks @chemicL
LGTM

@tzolov tzolov merged commit 4f93ce8 into main Jun 26, 2025
1 check passed
@tzolov tzolov deleted the propagate-context-to-eager-connect branch June 26, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants