How do I export MongoDB query results to JSON in mongodb-mcp-server?
Does mongodb-mcp-server support exporting large MongoDB query results to a JSON file instead of sending the full result set to the LLM? A GitHub issue requested an
export_to_jsontool to avoid token waste and keep reusable outputs for visualization or further processing, and it was closed as completed in August 2025. The thread has no client, OS, version, or error details.Originally asked on GitHub: https://github.com/mongodb-js/mongodb-mcp-server/issues/220
1 answer
Status: fixed. A maintainer confirmed on 2025-08-19 that the request was addressed in PR #424 of mongodb-js/mongodb-mcp-server.
The issue proposed an
export_to_jsontool that streams query results directly to the filesystem and returns only minimal metadata to the LLM: a success flag, the output file path, the document count, and a 3-document sample. The goal was to avoid token waste, reduce performance problems with large result sets, and keep reusable outputs for visualization, later MCP processing, or human verification.During triage, a maintainer raised two design questions that the thread does not record as answered:
- Export format: "Relaxed Extended JSON" loses precision for BSON values, and the maintainer asked whether the Default Extended EJSON and Canonical Extended EJSON formats are also needed.
- CSV alternative: since most visualization tools cannot work with EJSON, the maintainer asked whether CSV export would serve the visualization and analytical workflows better.
The thread contains no client, OS, tool version, error messages, or final configuration. As general advice: check PR #424 or the project README for the actual tool name, parameters, and supported export formats before relying on this feature.
Security note: an export tool writes query results to disk outside the LLM context, so choose the output location based on how sensitive the data is.
Did this work for you?
Related questions
- mongodb-mcp-server count tool ignores filter and returns total collection count in Cursor
- mongodb-mcp-server fails to start with nvm in Claude, Cursor, or VS Code: how to fix?
- mongodb-mcp-server Docker container doesn't exit — fixed in v0.1.2?
- mongodb-mcp-server in Docker: can't connect via HTTP to localhost:9091 — what transport does it use?
- Can mongodb-mcp-server be hosted as a remote MCP server over HTTP?