Skip to content

fix(mcp): Mongo maxTimeMS and a total response size cap (#1776) - #1808

Merged
ZhuchkaTriplesix merged 2 commits into
devfrom
fix/mcp-mongo-maxtime
Oct 25, 2026
Merged

ZhuchkaTriplesix merged 2 commits into
devfrom
fix/mcp-mongo-maxtime

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #1776 (the rest of it; the socket host, controller, access store and guard items went in #1802).

  • find sends maxTimeMS (the MCP timeout) with the find command, count adds maxTimeMS to the count command. The server now stops a heavy $regex or $expr itself; before, the Dart future was dropped and the session closed, but the query could keep running. The find command needs MongoDB 3.6+ (OP_MSG); older servers get the plain find as before.
  • McpMongoService.maxTotalChars (200000): the documents of a result together, as JSON, are capped; more are cut and the result is marked truncated. Each field was already capped at 4096 characters, but 100 documents of many such fields were not.
  • Tests: the timeout reaches the session for find and count; a small total cap cuts the result and marks it truncated; a result under the cap is returned whole.

Not done: masking the connection's own secrets for non-tool exceptions in _guarded; the redaction by pattern (URL user info, password=, keys) still applies there. Not run locally (the analyzer is clean on the changed files), CI will run the tests.

@github-actions github-actions Bot added bug Something isn't working P3 Low priority / Polish & Enhancements security Security related labels Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working P3 Low priority / Polish & Enhancements security Security related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant