-
Notifications
You must be signed in to change notification settings - Fork 190
feat: allow session id to be passed externally MCP-369 #870
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
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 21407817722Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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 support for externally managed sessions in the MCP server's HTTP transport layer. The feature allows external systems (like Amazon Bedrock AgentCore) to manage session lifecycles by providing their own session IDs, while the server maintains backward compatibility with its existing session management.
Changes:
- Added
externallyManagedSessionsconfiguration flag to enable/disable external session management - Modified HTTP transport to accept session IDs via
mcp-session-idheader and create sessions on-demand - Added comprehensive integration tests covering both externally managed and internally managed session modes
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/common/config/userConfig.ts | Adds externallyManagedSessions boolean configuration flag |
| src/common/logger.ts | Adds new log ID for session-not-found events |
| src/transports/streamableHttp.ts | Refactors session handling to support external session IDs with on-demand session creation |
| tests/integration/transports/streamableHttp.test.ts | Adds comprehensive test coverage for both external and internal session management modes |
Proposed changes
Allows for clients to send requests with externally-generated session ids. This means that session initialization is skipped which additionally requires that we switch to pure json responses instead of SSE. Sessions are now going to be created on demand with the externally-supplied id and will not be cleaned up until
idleTimeoutMSfires.