-
Notifications
You must be signed in to change notification settings - Fork 164
chore: add createSessionConfig hook MCP-294 #740
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
Conversation
There was a problem hiding this 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
createSessionConfigoptional hook toTransportRunnerConfig - Modified
setupServer()to call this hook before session initialization - Exported
TransportRunnerConfigtype 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; |
There was a problem hiding this comment.
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.
979a07d to
f895766
Compare
Pull Request Test Coverage Report for Build 19532221561Details
💛 - Coveralls |
0c7e6ae to
ce72c96
Compare
Co-authored-by: Anna Henningsen <[email protected]>
himanshusinghs
left a comment
There was a problem hiding this 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 🚀
Add a new async hook for library consumers to provide a configuration right before establishing an MCP session.