-
Notifications
You must be signed in to change notification settings - Fork 18
fix: use ejson parsing for stdio messages #218
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 fixes the BSON type deserialization issue by switching to EJSON parsing for stdio messages, ensuring that BSON types like ObjectId, UUID, and Decimal128 are properly reconstructed from incoming messages.
- Added unit tests for EJSON transport behavior.
- Updated integration tests to verify find tool output with BSON type values.
- Replaced direct usage of StdioServerTransport with a custom EJSON-enabled transport.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/unit/EJsonTransport.test.ts | New unit tests to validate EJSON-based deserialization. |
tests/integration/tools/mongodb/read/find.test.ts | Added integration test to verify find tool with BSON types. |
tests/integration/helpers.ts | Enhanced expectDefined to check for null as well as undefined. |
src/index.ts | Modified to initialize the EJSON transport instead of the default. |
src/helpers/EJsonTransport.ts | Introduced EJsonReadBuffer and factory function for EJSON parsing. |
export function createEJsonTransport(): StdioServerTransport { | ||
const server = new StdioServerTransport(); | ||
server["_readBuffer"] = new EJsonReadBuffer(); |
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.
[nitpick] Accessing a private property via server["_readBuffer"] may lead to maintainability issues if the underlying implementation changes. Consider exposing a dedicated method or refactoring the transport to safely update the read buffer.
export function createEJsonTransport(): StdioServerTransport { | |
const server = new StdioServerTransport(); | |
server["_readBuffer"] = new EJsonReadBuffer(); | |
class EJsonStdioServerTransport extends StdioServerTransport { | |
setReadBuffer(buffer: EJsonReadBuffer): void { | |
(this as any)._readBuffer = buffer; // Accessing private property safely within the subclass | |
} | |
} | |
export function createEJsonTransport(): StdioServerTransport { | |
const server = new EJsonStdioServerTransport(); | |
server.setReadBuffer(new EJsonReadBuffer()); |
Copilot uses AI. Check for mistakes.
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 think for our situation it's an acceptable enough workaround.
* main: (40 commits) chore: add more details for some api errors (#219) fix: use ejson parsing for stdio messages (#218) docs: improve getting started experience (#217) feat: support flex clusters to atlas tools (#182) chore: enforce access list (#214) feat: add back the connect tool (#210) Update connection string app name if not present (#199) chore: update docs with more Service Accounts mentions (#209) chore(deps-dev): bump eslint-plugin-prettier from 5.2.6 to 5.4.0 (#205) chore(deps-dev): bump @types/node from 22.15.3 to 22.15.9 (#204) chore(deps-dev): bump typescript-eslint from 8.31.1 to 8.32.0 (#206) chore(deps-dev): bump eslint from 9.25.1 to 9.26.0 (#207) chore: add recommended extensions and settings (#200) fix: fork checks (#194) docs: correct the link for VSCode's MCP usage (#186) chore: switch to a matrix for forks (#191) chore: skip Atlas Tests and don't track coverage for fork contributions (#188) fix: db user test error (#187) fix: improve api error messages (#176) chore: update quickstart with mcpServers (#185) ...
Thank you! |
This works around the issue where we receive bson types serialized as ejson, but not converted into the corresponding types.
Fixes #211