Skip to content

Conversation

@gagik
Copy link
Collaborator

@gagik gagik commented Nov 19, 2025

Add a new async hook for library consumers to provide a configuration right before establishing an MCP session.

@gagik gagik requested a review from a team as a code owner November 19, 2025 14:50
Copilot AI review requested due to automatic review settings November 19, 2025 14:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new createSessionConfig hook that allows library consumers to asynchronously provide or modify configuration before establishing an MCP session. This enables use cases like fetching connection strings from secrets managers or modifying settings dynamically at session initialization time.

Key Changes:

  • Added a new createSessionConfig optional hook to TransportRunnerConfig
  • Modified setupServer() to call this hook before session initialization
  • Exported TransportRunnerConfig type for library consumers

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/transports/base.ts Added createSessionConfig hook to TransportRunnerConfig and modified setupServer() to use the hook's result for session initialization
src/lib.ts Exported TransportRunnerConfig type to make it available to library consumers
tests/integration/transports/createSessionConfig.test.ts Added comprehensive integration tests covering basic functionality, connection string modification, server integration with read-only mode, and error handling scenarios

* Hook which allows library consumers to fetch configuration from external sources (e.g., secrets managers, APIs)
* or modify the existing configuration before the session is created.
*/
createSessionConfig?: CreateSessionConfigFn;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not too sure if I understood the usecase for this correctly so let me know if this should be used differently.

Add a new async hook for library consumers to provide a configuration right before establishing an MCP session.
@gagik gagik force-pushed the gagik/library-session-hook branch from 979a07d to f895766 Compare November 19, 2025 14:57
@coveralls
Copy link
Collaborator

coveralls commented Nov 19, 2025

Pull Request Test Coverage Report for Build 19532221561

Details

  • 10 of 10 (100.0%) changed or added relevant lines in 1 file are covered.
  • 34 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.2%) to 80.12%

Files with Coverage Reduction New Missed Lines %
src/tools/mongodb/mongodbTool.ts 5 84.09%
src/common/session.ts 6 85.08%
src/tools/atlas/connect/connectCluster.ts 23 71.56%
Totals Coverage Status
Change from base Build 19504196088: -0.2%
Covered Lines: 6388
Relevant Lines: 7881

💛 - Coveralls

@gagik gagik marked this pull request as draft November 19, 2025 15:18
@gagik gagik force-pushed the gagik/library-session-hook branch from 0c7e6ae to ce72c96 Compare November 19, 2025 15:59
@gagik gagik marked this pull request as ready for review November 20, 2025 09:34
Copy link
Collaborator

@himanshusinghs himanshusinghs left a comment

Choose a reason for hiding this comment

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

Yea that's precisely it. Thanks for getting it it 🚀

@gagik gagik merged commit 8acd47b into main Nov 20, 2025
20 checks passed
@gagik gagik deleted the gagik/library-session-hook branch November 20, 2025 09: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.

5 participants