-
Notifications
You must be signed in to change notification settings - Fork 109
chore: extend library interfaces to allow injecting a custom connection error handler MCP-132 #502
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: extend library interfaces to allow injecting a custom connection error handler MCP-132 #502
Conversation
@@ -0,0 +1,81 @@ | |||
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; |
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.
This entire file is a cut of existing logic in MongodbToolBase.
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 extends the MongoDB MCP library to support custom connection error handlers, allowing consumers to inject their own error handling logic for connection-related errors instead of relying solely on the default implementation.
Key changes include:
- Refactored transport runners to accept configuration objects with optional connection error handlers
- Created a new
ConnectionErrorHandler
interface and default implementation - Modified the
Server
class to use injected connection error handlers - Updated MongoDB tools to delegate connection error handling to the injected handler
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/common/connectionErrorHandler.ts |
New file defining the connection error handler interface and default implementation |
src/common/errors.ts |
Made MongoDBError generic to support type-safe error code handling |
src/transports/base.ts |
Added TransportRunnerConfig type and updated base class to support connection error handlers |
src/transports/stdio.ts |
Updated constructor to use new configuration object pattern |
src/transports/streamableHttp.ts |
Updated constructor to use new configuration object pattern |
src/server.ts |
Added connection error handler to server options and implementation |
src/tools/mongodb/mongodbTool.ts |
Refactored to use injected connection error handler instead of hardcoded logic |
src/index.ts |
Updated transport runner instantiation to use new configuration objects |
tests/integration/transports/streamableHttp.test.ts |
Updated test instantiation to use new configuration pattern |
tests/integration/tools/mongodb/mongodbTool.test.ts |
Added comprehensive tests for connection error handler functionality |
tests/integration/helpers.ts |
Updated test helper to include default connection error handler |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Pull Request Test Coverage Report for Build 17429932259Details
💛 - Coveralls |
We're expanding the transport runner interface to accept a custom connection error handler so that library consumers can provide their own mechanism of handling connection error and have an opportunity to act on them.
Co-authored-by: Copilot <[email protected]>
90304fd
to
2b725e7
Compare
* main: feat: add more details about atlas connect flow - MCP-124 (#500) chore: extend library interfaces to allow injecting a custom connection error handler MCP-132 (#502) fix: start mcp even if connection fails - [MCP-140] (#503) fix: allow connect tool on readOnly mode (#499) chore: warn about the usage of deprecated cli arguments MCP-107 (#493) ci: add ipAccessList after creating project (#496)
Proposed changes
We're expanding the transport runner and server's interface to accept a custom connection error handler so that library consumers can provide their own mechanism of handling connection error and have an opportunity to act on them.
This will allow VSCode to provide its own ConnectionErrorHandler and thus modify the tool responses in case of connection problems.
Checklist