-
Notifications
You must be signed in to change notification settings - Fork 108
chore: allows ConnectionManager to be injected via TransportRunner MCP-131 #481
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
chore: allows ConnectionManager to be injected via TransportRunner MCP-131 #481
Conversation
6298977
to
998140f
Compare
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 refactors the ConnectionManager interface to allow injection of custom ConnectionManager implementations via TransportRunner constructors. This enables VSCode integration by allowing the VSCode extension to provide its own ConnectionManager implementation that shares connection state with existing VSCode connections.
- Extracts an abstract ConnectionManager base class with
connect
anddisconnect
as abstract methods - Moves the existing ConnectionManager implementation to MCPConnectionManager
- Modifies TransportRunner classes to accept a factory function for creating ConnectionManager instances
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/common/connectionManager.ts | Creates abstract base ConnectionManager with interface definitions |
src/common/mcpConnectionManager.ts | Implements concrete MCPConnectionManager with existing connection logic |
src/transports/base.ts | Adds CreateConnectionManagerFn type and modifies constructor to accept factory function |
src/transports/stdio.ts | Updates constructor to use ConnectionManager factory function |
src/transports/streamableHttp.ts | Updates constructor to use ConnectionManager factory function |
src/index.ts | Creates factory function for MCPConnectionManager in main entry point |
src/lib.ts | Exports new ConnectionManager interface and related types |
tests/* | Updates test files to use MCPConnectionManager and new event interface |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
51f2fdf
to
8258b3e
Compare
This commit extracts an abstract class ConnectionManager out of MCPConnectionManager and modifies the TransportRunner interface to have the ConnectionManager implementation injected through a factory function. Contains a small drive by fix for making the ConnectionManager event emitting internal to the class itself.
33b85d4
to
71680ab
Compare
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.
Mostly nits from me, otherwise it's good.
Proposed changes
This PR modifies the interface for our TransportRunners to allow injecting a ConnectionManager implementation. This will enable VSCode integration by allowing VSCode extension to pass its own implementation of ConnectionManager.
To allow subclassing, an abstract ConnectionManager is extracted out from existing implementation with
connect
,disconnect
as the abstract methods.The VSCode implementation of ConnectionManager differs slightly from our implementation of ConnectionManager (MCPConnectionManager) which is why this interface modification was called for. The
VSCodeMCPConnectionManager.connect
is not as involved as our implementation, we literally borrow the connect options from an existing connection in VSCode extension and use those to create a new instance of NodeServiceProvider which essentially shares the connection state. Additionally that implementation also implements logic to switch to different connections on demand(when active connection in extension changes).The VSCode PR is here for reference.
Checklist