feat: support session context config#19
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds per-session context support to enable multi-tenant use cases where each client session can have its own context values (API tokens, user IDs, etc.) passed to module loaders via query parameters.
Changes:
- New
SessionContextResolverclass to parse, filter, and merge session-specific context from query parameters - Configuration validation for session context settings with support for base64/JSON encoding and whitelist-based key filtering
- Integration with HTTP transport layer to extract query parameters and generate per-session cache keys
- Comprehensive test coverage including unit tests, integration tests, and E2E tests
- Documentation updates in README, CLAUDE.md, and AGENTS.md
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/session/SessionContextResolver.ts |
Core resolver implementation with query parameter parsing, key filtering, context merging (shallow/deep), and cache key generation |
src/session/validateSessionContextConfig.ts |
Runtime validation for session context configuration with detailed error messages |
src/http/FastifyTransport.ts |
HTTP transport integration to resolve session context per request and generate cache keys |
src/server/createMcpServer.ts |
Server factory integration to pass merged context to module loaders |
src/server/createPermissionBasedMcpServer.ts |
Validation and warning for limited session context support in permission-based servers |
src/types/index.ts |
Type definitions for SessionContextConfig and SessionRequestContext |
src/index.ts |
Export session context types and resolver class |
tests/validateSessionContextConfig.test.ts |
Comprehensive validation tests for all config fields and error cases |
tests/sessionContextResolver.test.ts |
Unit tests for resolver logic including parsing, filtering, merging, and cache key generation |
tests/sessionContext.integration.test.ts |
Integration tests for HTTP transport with session context |
tests/e2e/dynamicMode.e2e.test.ts |
E2E tests verifying session context works end-to-end with real client connections |
tests/e2e/helpers.ts |
Test catalog and module loaders for session context E2E tests |
README.md |
User-facing documentation with usage examples and security considerations |
CLAUDE.md |
Developer documentation describing session context architecture |
AGENTS.md |
API documentation noting query parameter support for session config |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.