Mongodb Mcp — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Mongodb Mcp (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Also available in Russian: README-ru.md
Note: This project is designed for my personal needs. I do not plan to expand its functionality with features I don't use or cannot verify. You are free to submit suggestions and pull requests, but I make no guarantee that everything will be accepted.
MCP server for comprehensive MongoDB integration with the following capabilities:
MONGODB_MCP_CONNECTION_STRING — MongoDB connection string (mongodb:// or mongodb+srv:// format)MONGODB_MCP_DEFAULT_DATABASE — optional default database name for operationsMONGODB_MCP_TIMEZONE — optional timezone for date operations (default: Europe/Moscow), must be a valid IANA timezone identifier (e.g., Europe/London, America/New_York, Asia/Tokyo)To use this MCP server with Qwen Code, add to ~/.qwen/settings.json:
{
"mcpServers": {
"mongodb-mcp": {
"command": "npx",
"args": ["-y", "@vitalyostanin/mongodb-mcp@latest"],
"env": {
"MONGODB_MCP_CONNECTION_STRING": "mongodb://localhost:27017"
}
}
}
}Note: This configuration uses npx to run the published package. For local development, use "command": "node" with "args": ["/absolute/path/to/mongodb-mcp/dist/index.js"]. The MONGODB_MCP_TIMEZONE environment variable is optional.
To use this MCP server with Cline extension in VS Code:
cline_mcp_settings.json:{
"mcpServers": {
"mongodb-mcp": {
"command": "npx",
"args": ["-y", "@vitalyostanin/mongodb-mcp@latest"],
"env": {
"MONGODB_MCP_CONNECTION_STRING": "mongodb://localhost:27017"
}
}
}
}Note: This configuration uses npx to run the published package. For local development, use "command": "node" with "args": ["/absolute/path/to/mongodb-mcp/dist/index.js"]. The MONGODB_MCP_TIMEZONE environment variable is optional.
| Tool | Description | Main Parameters |
|---|---|---|
service-info | Get MongoDB service information, environment configuration, version, and current timezone | — |
connect | Establish connection to MongoDB using connection string | — |
disconnect | Disconnect from MongoDB | — |
list_databases | List all databases in the MongoDB instance | — |
db_stats | Get statistics for a specific database | database — database name |
list_collections | List all collections for a given database | database — database name |
collection_schema | Analyze the schema for a collection | database — database name, collection — collection name, optionally sampleSize (default 50) |
collection_indexes | Describe the indexes for a collection | database — database name, collection — collection name |
collection_storage_size | Get the size of a collection | database — database name, collection — collection name |
find | Run find queries against a MongoDB collection | database — database name, collection — collection name, optionally filter, limit (default 10), projection, sort |
count | Count documents in a MongoDB collection | database — database name, collection — collection name, optionally query — filter for counting |
explain | Returns statistics describing the execution of the winning plan chosen by the query optimizer | database — database name, collection — collection name, method — method object with name and arguments, optionally verbosity (default 'queryPlanner') |
mongodb_logs | Returns the most recent logged mongod events | optionally limit (default 50), type (default 'global', or 'startupWarnings') |
| Tool | Description | Main Parameters |
|---|---|---|
aggregate | Run an aggregation against a MongoDB collection | database — database name, collection — collection name, pipeline — array of aggregation stages, noLimit — disable the automatic $limit stage (useful for pipelines ending with $out or $merge) |
insert | Insert one or multiple documents into a MongoDB collection | database — database name, collection — collection name, document — single document to insert, documents — array of documents to insert (use instead of single document) |
update | Update one or multiple documents in a MongoDB collection | database — database name, collection — collection name, filter — filter to match documents for update, update — update operations to perform, upsert — if true, creates a new document if no documents match the filter (default: false), multi — if true, updates all matching documents (updateMany), otherwise updates only one (updateOne) (default: false) |
delete | Delete one or multiple documents from a MongoDB collection | database — database name, collection — collection name, filter — filter to match documents for deletion, multi — if true, deletes all matching documents (deleteMany), otherwise deletes only one (deleteOne) (default: false) |
create-index | Create an index on a MongoDB collection | database — database name, collection — collection name, keys — index specification document (e.g., { field: 1 } for ascending, { field: -1 } for descending), options — additional index options (e.g., { unique: true, sparse: true }) |
drop-index | Drop an index from a MongoDB collection | database — database name, collection — collection name, index — index name or index specification document to drop |
create-collection | Create a new collection in a MongoDB database | database — database name, collection — collection name to create, options — additional collection options (e.g., { capped: true, size: 1024 }) |
drop-collection | Drop a collection from a MongoDB database | database — database name, collection — collection name to drop |
Note: The server runs in read-only mode by default to prevent accidental data modifications. In read-only mode, all write operations are blocked including:
insertOne, insertMany, updateOne, updateMany, deleteOne, deleteMany, createIndex, dropIndex, dropDatabase, renameCollection, etc.insertOne, insertMany, updateOne, updateMany, deleteOne, deleteMany, findOneAndReplace, findOneAndUpdate, findOneAndDelete, bulkWrite, createIndex, dropIndex, drop, etc.$out, $mergeThe following aggregation stages are restricted in read-only mode: $out, $merge. These stages are only available when the server is running in read-write mode.
Recommendations for safe production use of the MCP server:
mongodb+srv:// (TLS is implied) or set tls=true explicitly in a regular mongodb:// connection string. Plaintext connections expose credentials and query payloads to anyone on the network path.root, dbAdmin, or any role that grants eval / scripting privileges. Default to read-only mode unless write tools are required.MONGODB_MCP_CONNECTION_STRING via environment variables (e.g., .env file) rather than passing it through args of the MCP host configuration — args are typically logged when the host launches the server, leaking the password.$where, $function, and $accumulator operators in queries. For defence in depth, run the MongoDB server itself with --javascriptEnabled=false (or the equivalent security.javascriptEnabled: false in mongod.conf).MONGODB_MCP_EXPORT_DIR to a directory accessible only to the MCP user (chmod 700). Other users on the machine should not be able to read the dumps that write tools produce.The MCP server does not provide transactional or ordering guarantees beyond what MongoDB itself enforces. Plan multi-step interactions accordingly:
ClientSession across calls. Design atomic multi-step flows by encoding preconditions into the filter of the same update / delete call, rather than chaining a separate find followed by a mutating call.MongoClient is shared across all tool calls. Only connect / disconnect are serialised through an internal mutex; ordinary operations (find, aggregate, insert, etc.) execute concurrently against the cluster, with no cross-tool ordering imposed by the MCP server.getConnectionInfo() returns the state at the moment of the call. For decisions that depend on connectivity, rely on the result of the next operation rather than a preceding isConnected check — the connection may drop between the two.wx flag and will not overwrite an existing file. Concurrent calls targeting the same filePath will fail with EEXIST; callers must pick a fresh path (e.g., include a timestamp or per-call suffix).Quick reference for working with the source.
Prerequisites:
.nvmrc (current LTS, ≥ 22). With nvm: nvm use.Setup:
git clone https://github.com/VitalyOstanin/mongodb-mcp.git
cd mongodb-mcp
npm installCommon scripts:
| Script | Purpose |
|---|---|
npm run build | Compile TypeScript to dist/ (tsconfig.build.json) and chmod the CLI entrypoint |
npm run dev | Run index.ts directly via tsx watch for iterative work |
npm start | Run the compiled server from dist/ |
npm run typecheck | Type-check sources + tests (tsconfig.json, no emit) |
npm run typecheck:tests | Type-check with extra strict flags (tsconfig.test.json) |
npm run lint | Run ESLint |
npm run lint:fix | Run ESLint with --fix |
npm test | Run the Vitest test suite once |
npm run test:watch | Run Vitest in watch mode |
npm run test:coverage | Run Vitest with v8 coverage (opt-in; threshold gate enforced) |
npm run test:debug | Run Vitest sequentially (--no-file-parallelism) |
Local connection example:
export MONGODB_MCP_CONNECTION_STRING="mongodb://localhost:27017"
npm run devLayout:
index.ts — CLI entry point.src/server.ts — MCP server bootstrap.src/mongodb-client.ts — singleton MongoDB client with read-only Proxy.src/tools/ — one MCP tool per file plus its *.test.ts.src/utils/ — shared helpers (streaming exports, schema fragments, date handling, redaction).~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.