Mongoster
A VS Code extension for working with MongoDB: open collections in a table, write queries and aggregations, edit documents, analyze schemas, indexes and relations, and keep an eye on the server. Filters can also be built by dragging cells and columns.
It works with MongoDB 4.2 or later (standalone, replica set, sharded cluster, Atlas): older servers are refused by the MongoDB driver it uses.
Mongoster also runs without VS Code, as a desktop app with the same features.
Features
- Connections in the sidebar (leaf icon): connection → database → collections. Connection strings are stored in VS Code's SecretStorage.
- Filter: the filter icon in the tree's title shows only the databases and collections whose name contains what you type (
orders, shop, or shop.ord for database and collection), ignoring case; the tree follows while you type. Under each connected connection, the databases that match, or that have a collection that matches, open with just those collections. Escape keeps the previous filter, an empty one shows everything, and the filled icon clears it.
Edit Connection… changes the connection string and the name (a new connection string is tested before it is saved); Copy Connection String copies it to the clipboard.
- Folders:
Move to Folder… groups connections (in an existing or a new folder); on a folder, + adds a connection inside it, Rename Folder… renames it and Remove Folder removes it, keeping its connections.
- Color:
Set Color… (red, orange, yellow, green, blue, purple) marks everything of that connection, for example red for production: its name and icon in the tree, the icons of its databases, collections and buckets (their names keep the usual color), the icon of its tabs (collections, monitor, users, watch, search, advisor, diagram, GridFS, compare, playground result) with a colored stripe at the top of their content, and the name of the tabs of its documents, definitions and playgrounds. In the desktop app its tabs also have a line of its color above them.
- Read-only:
Make Read-Only stops Mongoster from writing anything through that connection (edits, insert, delete, update/delete many, import, generated documents, indexes, $out/$merge, creating/renaming/dropping databases and collections); queries, aggregations, schema, explain and export stay available. Allow Changes turns writing back on after a confirmation. This is a safeguard of the extension: the real permissions are still those of the MongoDB user.
- Name, color and read-only apply right away to tabs that are already open.
- TLS and SSH tunnel:
Connection Settings (TLS / SSH)… on a connection, or Add Connection with TLS / SSH… in the view's … menu (and on folders), opens a form with the name, the connection string and:
- TLS / SSL: CA certificate (for a private authority), client certificate with key (PEM, also password-encrypted) and, only if really needed,
Allow invalid certificates / Allow invalid host names;
- SSH tunnel: SSH server (bastion), port, user and authentication with a password, a private key (also with a passphrase) or the SSH agent. The tunnel leads to the first host of the connection string with a direct connection to that server (
mongodb+srv:// connection strings can't be used); with TLS, the certificate is checked against the real server name.
Test Connection tries the connection and shows the server version; Save saves it. Passwords and passphrases are kept in SecretStorage and never sent back to the form: leaving the field empty keeps the saved one.
- The first time you connect to an SSH server, its key fingerprint (
SHA256:…) is shown for you to confirm; if it changes later, Mongoster warns you and asks again.
- In the tree, SSH connections are labeled
SSH; the tooltip shows the tunnel and TLS.
- redis-oplog: for Meteor apps using
cultofcoders:redis-oplog, which only see the writes announced on Redis, the redis-oplog section of the same form publishes the writes made in Mongoster as the package does, so that the apps' publications update right away:
- Redis URL (
redis://user:password@host:6379, rediss:// for TLS; kept in SecretStorage), Channel prefix (the app's globalRedisPrefix, if set), Namespaces (the events also go to namespace::collection) and Databases and collections, one per line: app for a whole database, app.users, app.*, *.logs; empty, all of them. Test Connection checks Redis too.
- Published: inline edits,
Edit / Insert / Delete of documents (also of the selected rows), Update many / Delete many, the column actions (Rename field…, Remove field…, Convert type…), undo, and in the playground insertOne, insertMany, updateOne, updateMany, replaceOne, deleteOne, deleteMany, findOneAndUpdate / Replace / Delete and bulkWrite (in a transaction, all of them in order once it commits; nothing if it aborts or the commit fails). Each document gets its event ({ e, d: { _id }, f }) on the collection's channel, on its namespaces and on the document's dedicated channel, with the fields the update changed; the app then reads the document from MongoDB. As redis-oplog does, a write of one document in the playground first finds its _id and then runs only on it.
- Not published: import, generated documents, copy, restore, the comparison, GridFS,
$out / $merge, runCommand and dropping collections, and documents whose _id can't be a Meteor id (only strings, ObjectIds and numbers can). Writes made outside Mongoster need oplogtoredis or the app itself.
- A Redis error doesn't stop the write: a warning says it couldn't be published, at most every 30 seconds. In the tree, these connections are labeled
redis-oplog.
- Import and export:
Import Connections… and Export Connections… in the view's … menu, the Command Palette and on folders:
Import Connections… reads a file or the clipboard: a MongoDB Compass export (Export saved connections, also with a passphrase, which is asked for: leave it empty to import without the passwords), a Mongoster export, or a list of connection strings, one per line, also name = mongodb://… or name<Tab>mongodb://… (blank lines and # comments are skipped; without a name, the host). From Compass come the name, the color (the closest of the six), the connection string, the SSH tunnel and the TLS certificate files of the connection string (tlsCAFile, tlsCertificateKeyFile), which go to the TLS settings; In-Use Encryption settings are left out, and so is an SSH tunnel with a mongodb+srv:// connection string.
- A list shows what was found, with the host, the settings,
✓ already exists and what's missing (no password): those already there with the same connection string start unchecked. For names already used you choose Skip, Replace (the existing connection takes the imported settings, but stays read-only if it was) or Keep Both (name (2)), then the folder: none, an existing or new one, or Folders from the File (on a folder, its own). Passwords go to SecretStorage.
Export Connections… asks for the connections (all, or those of the folder it was opened on), the format — Mongoster (JSON with everything: folders, colors, read-only, TLS, SSH, redis-oplog), MongoDB Compass (JSON for Compass's Import saved connections: name, color, connection string with the TLS options, SSH tunnel) or connection strings (name = mongodb://… per line, TLS in the connection string, no SSH) — and the passwords: Without passwords (the default: removed from the connection strings, SSH and Redis passwords and passphrases left out), With passwords, encrypted with a passphrase (AES-256-GCM with a key derived with PBKDF2, the same encryption as Compass, so Compass reads them too) or With passwords in clear text, after a warning.
- Filtering the tree:
Filter Databases and Collections… (the filter icon in the tree's title) shows only the databases and collections whose name contains the text, ignoring case, while you type. Database and collection can be written together: shop.ord finds shop.orders. Matching databases open by themselves under the connected connections; Filter: … above the tree says what's filtered, and Clear Filter shows everything again.
- Managing databases and collections from the tree's context menu:
Create Database… on a connection asks for the name of the database and of its first collection (MongoDB only creates a database together with a collection) and opens it.
Create Collection… (also + on a database) accepts optional options, for example { capped: true, size: 1048576 } or { timeseries: { timeField: "ts" } }.
Rename Collection… renames within the same database; the open tab, the query history and the expanded columns follow the new name. Views can't be renamed.
Drop… on collections and views, Drop Database… on a database: for collections and databases you type the name to confirm, and the message says how many documents, indexes or collections will be deleted. The tabs of dropped collections are closed.
- Table for each collection: one column per field, values colored by type, paging, total count. Values take the syntax colors of the active color theme, as in a JSON file in the editor (strings, numbers, booleans, keys; ObjectId, dates and regexes take the colors of keywords, types and regexes), including
editor.tokenColorCustomizations, and change with the theme. The same colors are used by the playground results, the server monitor, the global search and the index advisor.
- Filter / Sort / Project in mongosh syntax:
{ _id: ObjectId("…"), name: /mario/i, createdAt: { $gte: ISODate("2024-01-01") } }. Ctrl+Enter runs the query. What you type takes the syntax colors of the theme too: field names, operators, strings, numbers, ObjectId(…), dates, regexes and comments, also in the pipeline stages, in Update many and in the index dialog.
- Visual query builder:
Builder next to the filter opens a list of conditions below it, each with a field, an operator and a value, for those who don't want to write mongosh syntax:
- operators
=, ≠, >, ≥, <, ≤, in / not in (comma-separated values or an array), matches (regular expression, /^mario/i or just the text), exists, missing, type (BSON type from a list) and size (arrays with that number of elements);
- the field is picked from the collection's fields (nested ones too), the value from the field's most frequent values; values are written as in mongosh (
42, true, "text", ISODate("2024-01-01"), ObjectId("…")), and a word without quotes is a string;
Match all combines all the conditions (those on the same field become a single range, e.g. { age: { $gte: 20, $lte: 30 } }), Match any combines them with $or;
- the text filter updates as you fill in the rows (incomplete rows, shown dashed, don't count) and, the other way round, a filter written by hand, dragged or taken from the history fills the rows. If it uses operators the rows can't show (
$elemMatch, $expr, nested $or…), the builder says so and leaves the filter as it is. Enter in a row runs the query; the builder stays open or closed per tab.
- Autocomplete while you type in Filter, Sort, Project, in pipeline stages (also as text), in
Update many and in the keys and the partial filter of an index:
- field names, nested ones too (
address.city, quoted when needed), taken from a sample of 500 documents, with the type and the percentage of documents that have them; from the second stage on, if the table shows the output of the previous stage, the fields are those of that output;
- operators that fit where you are:
$and/$or/$expr at the top of the filter, $gte/$in/$elemMatch/$exists… inside a field, pipeline stages, accumulators in $group, expressions and "$field" references in $project/$addFields, update operators ($set, $inc, $push…);
- the field's most frequent values (
status: → "active", "pending"…), also inside $in: [...], plus 1/-1 for sorting and the types for $type;
Tab or Enter insert the suggestion (operators come with a skeleton of the value, e.g. $in: [|]), ↑/↓ move through the list, Esc closes it, Ctrl+Space opens the suggestions where you are.
- Drag & drop into the filter, sort and projection:
- drag a cell →
= equals, ≠ not equal, and for numbers/dates/strings ≥ from / ≤ to (they combine into a range on the same field); for arrays ∈ in;
- drag a column header →
exists, missing, is null on the filter; ▲ ascending / ▼ descending on Sort (a new field sorts after those already there, one already there keeps its place); include / exclude on Project (entries that can't go with it, the opposite kind or a path above or below it, are dropped). A field already in Sort or Project can be dropped on ✕ remove.
- Query history:
History in the toolbar shows the saved queries and the last 50 that ran successfully on that collection (without duplicates, remembered after closing VS Code too). Click or Enter to run one again; search, ☆ to save it with a name, ✕ to remove it, Clear to empty the recent ones.
- Saved queries, for you or in the project:
☆ Save current (or ☆ on a recent query) asks for a name, then where: For me keeps the query in Mongoster, for that connection only; In the project writes it as a JSON file in .mongoster/queries of the workspace folder (asked when there are several), to share it with the team and version it with git. The last choice is offered first. Mongoster: Save Query in the Project… in the Command Palette saves the query of the active tab directly in the project.
- Each saved query is marked
Me or Project; ⋯ has Rename…, Move to the Project / Move to My Queries and, for the project's, Open File. Deleting or moving a project query out of the project deletes its file, after a confirmation.
- The files: one per query,
.mongoster/queries/<database>/<collection>/<name>.json, with name, an optional description, database, collection and the filter, sort and projection (or the pipeline stages) as written in mongosh syntax; text on several lines is an array of lines, so changes are easy to read in a diff. A query shows on every connection that has that database and collection; add "connection": "<connection name>" to show it on that connection only. Nothing secret is written. Files pulled from git or edited by hand appear in the open tabs at once; invalid ones are skipped with a warning and Open File.
- The folder is the setting
mongoster.savedQueries.folder: relative to each workspace folder (default .mongoster/queries) or absolute. In the desktop app, which has no workspace, the first save in the project asks for the project folder and remembers it; Mongoster: Choose the Project Folder for Saved Queries… changes it.
- Global search: right-click a connection, a database, a collection or a view →
Search Documents… opens a tab that searches for a text in any field of the documents, nested or inside arrays too, across all collections:
Contains finds the text inside strings (case-insensitive, unless Match case), but also an _id or a reference: pasting an ObjectId (or part of it, or ObjectId("…")) finds the document and the ones that refer to it; the same goes for UUIDs and dates (2024-03-15). Numbers and booleans are compared as whole values: 42 finds 42, NumberLong(42) and NumberDecimal("42.0"), not 420. Regex searches with a regular expression (^mario or /^ma/i);
Field names also searches field names; Views includes views (usually left out, because they show documents of collections that are already searched); Read limits the documents read per collection (all, or the first 1,000 / 10,000 / 100,000). The admin, local and config databases, system.* collections and the contents of GridFS files (*.chunks) are skipped;
- MongoDB has no "any field" query: Mongoster reads and checks the documents itself, three collections at a time, with the progress of each collection (read / estimated).
Stop (or Esc) interrupts the search;
- results are grouped by collection: for each document, its
_id and the matching fields with the text highlighted. Click a document to open it in the editor; Open in Collection opens the collection filtered on the documents found ({ _id: { $in: [...] } }, up to 1,000). The first 50 documents of each collection are listed and the others are counted; collections that can't be read (permissions) are reported.
- Sorting: click a header (▲ → ▼ → none).
- Custom columns, remembered for each collection (also after a rename):
- hide: right-click a header →
Hide, or the checkboxes of the Columns panel in the bar above the table (with search, Show all and Reset);
- reorder: drag a header onto another one (the column goes before or after it, among those of the same level), or drag the rows in the
Columns panel;
- resize: drag the right edge of a header; double-click the edge to go back to the automatic width;
- pin to the left: right-click →
Pin, or 📌 in the panel: the column stays visible while scrolling horizontally.
- CSV export uses the visible columns in the chosen order.
- Actions on a column: right-click a header (in
Find, on a collection that can be changed) to change that field in the documents matching the filter (with an empty filter, the whole collection, after the same extra confirmation as Update many). The confirmation says how many documents change; afterwards the table is refreshed, and the change is recorded for undo and published to redis-oplog as Update many.
Rename field…: a new name with $rename, also a dotted path (address.city → address.town, or into another sub-document). Its hidden, pinned, ordered or resized column follows the new name. If some documents already have the new name, the confirmation says that value is replaced. Documents where the field (or the new name) goes through an array are left out and counted: $rename can't go inside arrays, so fields of array elements (items[].sku) are refused, with a hint for Update many with $map.
Remove field…: $unset; for a field of the elements of an expanded array (items[].sku), from every element (items.$[].sku).
Convert type…: to string, int, long, double, decimal, bool, date or objectId (the list shows the field's current types), with an update pipeline and $convert. Values that can't be converted keep their value and type, null and arrays are left as they are; at the end it says how many documents changed and how many values couldn't be converted. Not for fields of array elements.
- Aggregate: the
Find / Aggregate switch at the top opens the pipeline editor.
- Each stage is a card: operator (with suggestions and a template for common stages), body in mongosh syntax, a checkbox to disable it,
‹ › to move it, ✕ to remove it. Ctrl+Enter in a stage runs the pipeline.
- Clicking a stage number shows the output up to that stage (with paging and count); the following stages are dimmed.
Run runs the whole pipeline.
- Drag & drop works here too: the condition goes into the
$match shown, or into a new $match right after the stage shown. Clicking a header adds or changes a $sort at the same point.
Edit as text to paste or edit the whole pipeline ([ { $match: … }, … ]), Copy to copy it.
- Stages that write (
$out, $merge) ask for confirmation before running; previewing an earlier stage writes nothing.
- Errors point to the stage that caused them. Pipelines go into the same history as queries.
- Aggregation results can't be edited: to edit a document, go back to
Find.
- Atlas Search:
$search, $searchMeta and $vectorSearch have templates, and suggestions for their options (index, path, queryVector, numCandidates, limit, filter, exact), the operators of $search with a skeleton (text, compound with must / should / filter, autocomplete, phrase, range, …, also inside compound) and the collection's search indexes of the right type in index (vector fields first in the path of $vectorSearch). Such a stage anywhere but first is marked must be first, and the pipeline isn't sent. { $meta: "searchScore" } and { $meta: "vectorSearchScore" } are suggested in $project / $addFields.
Save as view… creates a view on the collection with the pipeline up to the stage shown (without $out/$merge) and offers to open it.
- Nested columns: columns with sub-documents have a
▸ button that expands them into dotted columns (address → address.city, address.zip, …), one level at a time; Alt+click expands all levels. Click the prefix (address.) to collapse the group again. Filters, ranges and sorting work on nested fields too ({ "address.city": "Milano" }). If the field isn't an object in a document, the value spans the whole group. Expansions are remembered for each collection.
- Arrays of objects: columns with arrays of sub-documents have
▸[] too: they expand into the fields of the elements (items[].sku, items[].qty, …) and each element becomes a sub-row of the document, so the fields of the same element stay aligned (up to 20 elements per document, then … N more).
- Dragging the value of an element builds a filter with
$elemMatch: { items: { $elemMatch: { sku: "A1", qty: { $gte: 4 } } } }. Several conditions on the same array go into the same $elemMatch, so they apply to the same element.
- Dragging the header and sorting use the dotted path (
items.sku).
- Sub-documents inside the elements can be expanded (
items[].options.color); arrays inside arrays stay as a value.
- Update many / Delete many: the buttons next to
Explain act on all the documents matching the filter.
- The dialog shows the filter and how many documents match before writing; the table behind it shows those documents.
- For updates you write operators (
{ $set: { status: "archived" }, $inc: { version: 1 } }) or a pipeline ([ { $set: { total: { $add: ["$a", "$b"] } } } ]); a document without operators is refused, because it would replace whole documents. Ctrl+Enter applies it.
- With an empty filter, an extra confirmation is asked, because the whole collection would be changed or deleted.
- At the end, the number of documents changed or deleted is shown. Not available for views.
- Inline editing: double-click a cell (or
F2 on the selected cell) to edit its value in mongosh syntax; Enter saves it with $set, Shift+Enter adds a new line, Esc (or a click elsewhere) cancels.
- It also works on nested fields, on the elements of expanded arrays (
items.2.qty) and on empty cells (it adds the field).
- Numeric types stay the original ones;
NumberLong(...) and similar force a type.
- If the value has changed in the database in the meantime, you are asked whether to overwrite it. Not available for
_id, for views and in Aggregate mode.
- JSON document: clicking the row number (or
Enter on the selected cell) opens a dialog with an expandable JSON tree; ↑/↓ to move through the documents.
- Copying a document:
Copy ▾ in the document dialog, or right-click a row, copies it as:
mongosh (ObjectId(…), ISODate(…)) or Extended JSON ({ "$oid": … }, as mongoexport writes it): both keep the types and can be pasted into Insert, a query or the playground;
JSON: plain JSON for other tools, with ids, dates and decimals as strings;
YAML: ids as strings, dates as YAML timestamps, multi-line text as | blocks;
insertOne command: db.getCollection("…").insertOne({ … }), ready for mongosh.
- The right-click menu also has
Open document, Copy value, Duplicate… and Delete document.
- Selecting rows:
Ctrl+click (Cmd+click on macOS) adds or removes a document, Shift+click selects the rows from the last one clicked, Ctrl+A selects the page; a plain click or Esc ends the selection. Selected rows are highlighted and 3 selected · Clear appears next to the paging. The selection is by _id (a sub-row of an expanded array selects its document): it survives a refresh and ends when the query or the page changes.
- Right-click a selected row:
Copy 3 documents as mongosh (an array), Extended JSON, JSON Lines, JSON, YAML, insertMany command or CSV (the visible columns, as Export writes them); Export 3 documents… (JSON, JSON Lines or CSV, with the query's sort and projection, or the pipeline's output); Update 3 documents… opens Update many with the filter { _id: { $in: [...] } }; Delete 3 documents… (also the Delete key) deletes them after a confirmation, with undo and redis-oplog as Delete many.
- Updating and deleting need
Find on a collection that can be changed; in Aggregate, results can be copied, and exported when they have an _id.
- Editing:
Edit opens the document in an editor tab; Ctrl+S saves it to MongoDB.
- Numeric types stay the original ones (Double, Int32, Long), even when the value changes;
NumberLong(...) and similar force an explicit type.
- The editor also accepts mongosh syntax (
ObjectId(...), ISODate(...)).
- If the document was changed or deleted in the database after it was opened, you are asked whether to overwrite / insert it again.
_id can't be changed: use Duplicate.
- Insert:
Insert in the toolbar (or + on the collection in the tree) opens a dialog where you type or paste the documents and press Insert (Ctrl+Enter); nothing to save.
- It takes one document
{ … }, an array [ { … }, { … } ] (inserted with insertMany), one document per line (mongoexport's JSON Lines) or a pasted db.coll.insertOne(…) / insertMany(…), in mongosh syntax or Extended JSON, with autocomplete of the field names and values and syntax colors. While you type it says how many documents it found, or what's wrong.
Template starts from the fields most documents of the collection have (ISODate() for dates); without _id, MongoDB generates one. A pasted _id that already exists is pointed out, with the hint to remove it.
- If one of several documents is refused (duplicate key, validation), the ones before it are inserted and it says how many, and the text stays in the dialog.
Keep open stays open after inserting, to insert more; closing without inserting keeps the text for the next time.
Open in Editor moves the text to an editor tab instead, inserted with Ctrl+S as before.
- Inserts are published to redis-oplog and can be undone.
- Duplicate / Delete:
Duplicate opens Insert with a copy of the document without _id; Delete (or the Delete key on a cell, or on the selected rows) deletes it after a confirmation.
- Document history:
History… (in the document dialog, in the row's right-click menu, or on an open document's editor tab) shows the writes to a document that are still in the oplog, newest first: insert, update with the fields set and unset, replace, delete, also those inside transactions, with the time and who wrote them (a transaction or retryable write with its session, a chunk migration, or Mongoster itself, recognized from the undo history). Click a write to see the document after it and a field-by-field diff with the version before.
- The oplog keeps the new values of an update but not the old ones, so a version is known in full only when it can be rebuilt from an insert or a replacement still in the oplog, or when it is the current document. The others are marked
partial, with ? where a value isn't known.
Restore this version… replaces the document with a complete version, or Insert again… brings back a deleted one, after a confirmation: like other edits it can be undone from the Undo History and is published to redis-oplog. Not on read-only connections.
- The oplog exists only on replica sets (a single-node one is enough), and reading it needs a role such as
clusterMonitor or readAnyDatabase; through a mongos the tab explains that the shards' oplogs can't be read. The tab says how far back the oplog goes. It reads up to 100 writes or 8 seconds at a time, and Load older reads further back.
- Export: the
Export button exports what the table shows (the query, or the pipeline up to the stage shown): all the results or just the current page. Also from the tree: right-click a collection or view → Export Collection….
- JSON: a readable array (relaxed Extended JSON).
- JSON Lines: one document per line in canonical Extended JSON, which keeps all the types; it's the right format to import again.
- CSV: the visible columns (expanded ones too); expanded arrays give one row per element with the other values repeated. With a UTF-8 BOM, so Excel reads accented characters.
- Pipelines ending with
$out/$merge can't be exported: select an earlier stage.
- Import: right-click a collection →
Import Documents… accepts JSON (an array or a single document), JSON Lines, CSV and also mongosh syntax (ObjectId(...), ISODate(...)). It asks for confirmation, inserts in batches of 1000 and reports the documents that were skipped (e.g. an existing _id) without stopping.
- In CSV, headers with a dot create sub-documents (
address.city), empty cells are left out, and numbers, booleans, null, ISO dates (…Z), JSON and hexadecimal _ids are recognized.
- Generating test documents: right-click a collection or view →
Generate Test Documents… (it analyzes a random sample of 1,000 documents), or Generate… in the Schema tab (it uses the analysis shown, of the filter and sample chosen), creates fake documents that look like the collection's:
- each field is there as often as in the analysis, with the same mix of BSON types (
int, double, long and decimal stay apart). Fields with few distinct values (a status, a rating, the few ObjectIds a reference points to) re-use the values seen, as often as they were seen; numbers and dates fall between the minimum and the maximum following the histogram (doubles with as many decimals, dates at midnight if they all were); booleans keep their ratio, arrays their lengths and elements; sub-documents are generated the same way;
- strings follow the field name and the values seen: emails (with the domains seen), URLs (same host, the path segments that don't change), UUIDs, phone numbers, first, last and full names, usernames, cities, countries, streets, hexadecimal ids, ISO dates in strings, codes like
ORD-2024-000123 (the characters that are the same in all the values stay), otherwise words of the values seen with a similar length. Other ObjectIds are new ones within the time span of those seen;
_id: new ObjectIds; integer _ids continue after the largest one in the destination; string, UUID and binary _ids get new values of the same shape. Values aren't related across fields (an email doesn't match the name in the same document);
- you choose how many (100 by default, up to 1,000,000), the destination (this collection, or another one, new or existing, on any connection, as with
Copy Collection To…) and an optional seed: the same seed and analysis give the same documents (new ObjectId _ids still differ). The confirmation shows 3 of the documents in mongosh syntax; they are inserted in batches of 1000 with the progress in the notification and Cancel, then Open opens the collection;
- read-only connections and views can be imitated but not written to. As with import, the inserted documents can be undone from the history (up to 10,000) and aren't published to Redis for redis-oplog.
- Copying collections: right-click a collection or view →
Copy Collection To… copies it to another database, also on another connection (e.g. from production to local). You choose the connection, the database (also a new one) and the collection name, then:
- if the target collection exists:
Append (documents with an _id that is already there are skipped), Replace matching (replaced by _id) or Drop and recreate;
- an optional filter in mongosh syntax, to copy only part of the documents;
- whether to also copy the indexes and the collection options (validation rules, capped, collation, time series…).
- After a confirmation with the number of documents, the copy proceeds in batches of 1000 with the progress in the notification;
Cancel stops it after the current batch (documents already copied stay). BSON types stay identical (Int32, Double, Long, Decimal128, regex…). At the end, Open opens the copied collection.
- Read-only connections can be the source but not the target; a view is copied as a collection with its documents.
- Backup and restore, in the
mongodump formats (compatible both ways with mongodump / mongorestore): a single archive file (.agz) or a folder:
Back Up… (right-click a connection, a database, a collection or a view) saves the chosen databases, the chosen collections of a database or a single collection. You choose the format:
Archive (.agz): a single gzipped file, as written by mongodump --archive --gzip, saved where you choose (shop_2026-10-08_16-45-12.agz is suggested);
Folder, compressed (gzip) or Folder, uncompressed: in the folder you choose, a folder with a name and date is created (shop_2026-10-08_16-45-12) and, for each database, a subfolder with <collection>.bson (the documents, byte for byte as they are in the database) and <collection>.metadata.json (options such as validation rules, and indexes; views only have this one), or .bson.gz / .metadata.json.gz;
- the backup shows its progress in the notification and can be cancelled (the incomplete archive or folder is deleted). At the end,
Copy mongorestore Command copies the command to restore it with the MongoDB tools (mongorestore --gzip --archive="…" or mongorestore --gzip --dir "…"), and Reveal File / Reveal Folder shows it. Time series collections aren't supported and are left out (they need mongodump);
Restore from Backup… on a connection or a database (not read-only) first asks whether the backup is an Archive or a Folder, then for the file or the folder: an archive created by Mongoster or by mongodump --archive (.agz gzipped or .archive uncompressed, recognized from their content), or a folder created by Mongoster or by mongodump --out (with a subfolder per database), or the folder of a single database. On a connection you choose the databases (a single one can be restored under another name), on a database which database of the backup to restore into it; then the collections. On a collection you choose a single .bson / .bson.gz file (with its .metadata.json next to it, if there is one) or an archive, and then which of its collections;
- an archive is read once from start to end, also when
mongodump wrote several collections alternating; each collection's checksum is checked, and a damaged archive stops the restore with an error;
Add documents adds the documents and keeps the existing ones (those with an _id that is already there are skipped, as mongorestore does); Drop and restore drops the collections first (like mongorestore --drop). New collections are created with their options, then the indexes are rebuilt; documents are inserted unchanged, without applying the validation rules. With Add documents, the added documents can be undone from the history (one operation per collection, up to 10,000 documents).
- Scheduled tasks: backups and exports that run by themselves, periodically.
Show Scheduled Tasks (Command Palette, the connections view's … menu) opens the tab with the tasks: when they run, the next run, the last one with its result (duration, size, or the error), and, clicking a row, the last 20 runs with their files (Reveal shows them). Schedule… on a connection, a database or a collection (right-click) opens a new task for it.
New Task… / Edit: a backup of the connection (all its databases except admin, local and config), of a database (all its collections) or of a collection, in the formats of Back Up… (Archive (.agz), Folder, compressed (gzip), Folder, uncompressed); or an export of a collection to JSON, JSON Lines or CSV (the columns of the collection's tab), with an optional filter and projection in mongosh syntax;
- the folder, and the name of what each run writes:
{name}_{date}_{time} by default (shop_2026-11-12_02-00-00.agz), also with {connection}, {database}, {collection}, {YYYY}, {MM}, {DD}, {HH}, {mm}, {ss}, {weekday}; the extension is added, and a number if the name exists. The form shows an example name and the next three runs;
- when, in local time: every 1, 2, 3, 4, 6, 8 or 12 hours (every 6 hours at 02:30 is 02:30, 08:30, 14:30, 20:30), daily at a time, or on chosen days of the week at a time. On the day daylight saving starts, a time that doesn't exist runs an hour later; on the day it ends, a time that happens twice runs once;
Keep the last N: after each successful run, the older files or folders written by this task are deleted; nothing else in the folder is touched, and 0 keeps them all;
Run a missed run when Mongoster starts: if VS Code or the app was closed (or the computer asleep) at the time of a run, it runs once when it is open again; otherwise the run shows as missed in the log;
- the checkbox on each row enables or disables a task;
Run Now runs it once (the schedule stays as it is), Cancel stops a run and deletes what it wrote so far, ✕ deletes the task (the files it wrote stay);
- tasks run while VS Code or the app is open. With several VS Code windows open, a task runs in only one of them: the window that starts it records the run, so the others skip it, and a task never runs twice at the same time (a run due while the previous one is still going is skipped). The tasks and their run logs are in the extension's folder (
globalStorage, scheduledTasks); passwords stay where the connections keep them;
- a failed run, or one skipped because the connection was unavailable or removed, shows an error or a warning with
Show Scheduled Tasks; a successful one only if Notify after successful runs too is on. A folder that doesn't exist (a drive that isn't connected) makes the run fail rather than being created.
- Comparing collections: right-click a collection or view →
Compare With… compares it with another one, also on another connection (e.g. staging and production): you choose the connection, the database and the collection (the same name is suggested). Documents are paired by _id and split into identical, different, left only and right only.
Filter (mongosh syntax) limits the comparison to the matching documents, on both sides; Ignore leaves fields out (updatedAt, __v, also nested ones like address.zip or fields of array elements like items.price).
Ignore field order (on) treats documents with the same fields in a different order as equal; Compare numbers by value (on) treats 1 (int), 1.0 (double) and NumberLong(1) as equal. Turning them off shows these differences too, with the BSON type next to the value.
- The counts at the top filter the list by kind of difference. For different documents, the list shows the changed fields; click a row for a field-by-field comparison (left / right,
— if the field is missing); for documents on one side only, the whole document. Open Left / Open Right open the document in the editor.
→ Right / ← Left on a row copy the document from one side to the other (insert or replace, with identical BSON types) or, if it's missing on the other side, Delete deletes it. Make right like left… / Make left like right… do the same for all the differences: after a confirmation they copy the missing or different documents and, if chosen, delete those found only on the target side. Then the comparison runs again.
⇄ swaps the sides. Read-only connections and views can be compared but not changed. The comparison reads one side at a time, keeping only a fingerprint per document in memory (up to 1,000,000 documents per side); the list shows the first 300 differences of each kind.
- Comparing database structures: right-click a database →
Compare Structure With… (or the Command Palette, which asks for both databases) compares it with another database, also on another connection (e.g. development and production before a release): you choose the connection and the database (the same name is suggested). The left database is the model; the script and Apply… change the right one.
- Compared: collections and views on one side only; the options of collections (validation rules with their level and action, capped size and maximum, time series, clustered index, collation, change stream pre- and post-images) and the definition of views (
viewOn, pipeline, collation); indexes, paired by their keys (with collation and partial filter) and not only by name, so the list says which are missing, which are only on the right, which have the same keys with other options or another name, and which have the same name with other keys (v, ns, background, the generated name and the default options don't count); Atlas Search and Vector Search indexes, when both servers have search (a server without search is only mentioned); shard keys, when both are sharded clusters.
- The list is grouped by collection, with counts that filter it by kind of difference;
Only differences / All also shows what is the same. Click a row for what differs, field by field, both definitions side by side and the commands that align it.
Copy Script and Open in Playground (a new playground on the right connection) give a mongosh script that makes the right database like the left one: createCollection / createView with the options, collMod for validation rules, views, TTLs and hidden indexes, createIndex, createSearchIndex / updateSearchIndex. Steps that drop something (a collection or index only on the right, an index rebuilt with other options, convertToCapped) are commented out unless Include drops in the script is on. What no command can change (collation, clustered, uncapping, most time series options, resharding) is explained in a comment.
Apply… on a row, on a collection or Apply All… makes the changes in the right database after a confirmation that lists them; Apply All… offers Apply (without drops) and Apply Including Drops. Then the comparison runs again. A read-only right connection can be compared but not changed, and these changes can't be undone from the undo history. ⇄ swaps the sides.
- The playground also runs
createSearchIndex, updateSearchIndex, dropSearchIndex and getSearchIndexes, as in mongosh.
- Undo changes: before every change Mongoster makes to documents, it saves how they were, so the change can be undone even after restarting VS Code:
- inline edits,
Edit / Insert / Delete of documents (also of the selected rows), Update many / Delete many, the column actions, import, generated documents, copying collections (Append and Replace matching; not Drop and recreate) and the comparison's Make … like … are recorded. The playground, $out / $merge, indexes, users, GridFS files and dropping collections and databases can't be undone;
Show Undo History (clock icon in the view's title bar) opens the tab with the operations, newest first: when, connection and collection, what was done, how many documents were inserted, changed or deleted and how much space they take. Click a row to see what undoing would do to each document (the current value and the value after the undo, field by field);
Undo puts the documents back as they were: it deletes the inserted ones, restores the changed ones and inserts the deleted ones again, with identical BSON types. If some of the documents changed in the meantime, it says so and you choose whether to overwrite those changes too (Undo All) or undo only the others (Undo Unchanged Only). The undo is recorded too, so it can itself be undone (redo). Undo is also in the notification of Update many, Delete many, import, copy and document deletion, and Undo Last Change (the view's … menu or the command palette) undoes the last operation;
- Disk space: operations are compressed (gzip) files in the extension's folder (
globalStorage, on Windows %APPDATA%\Code\User\globalStorage\riccardofilippozzi.mongoster\history), holding only the documents involved (only the _id for inserts). By default at most 100 MB, 7 days and 200 operations are kept, deleting the oldest first; operations on more than 10,000 documents or more than 20 MB aren't recorded, and the confirmation says so (can't be undone). The limits are in the mongoster.history.* settings, where the history can also be turned off (mongoster.history.enabled); Clear History… (or Clear Undo History from the palette) empties it, ✕ removes a single operation;
- for a single connection: right-click →
Stop Keeping Undo History (and Keep Undo History to turn it back on). Removing a connection also deletes its saved operations. With a read-only connection nothing is recorded or undone.
- Schema: the
Schema tab analyzes the documents matching the filter (all of them, or a random sample of 100 / 1,000 / 10,000) and shows, for each field:
- how often it's there and with which BSON types (
int, double, long, decimal, date, objectId, …), with percentages;
- the most frequent values, or a histogram for numbers and dates with minimum and maximum; for arrays, the length and the values of the elements.
- Sub-documents and the fields of objects in arrays (
items[].sku) expand with ▸; ⊞ / ⊟ expand or collapse everything.
- Click a value, a histogram bar or a type to add it to the filter (
{ status: "active" }, { age: { $gte: 25, $lt: 30 } }, { name: { $type: "string" } }): the analysis runs again on the filtered documents.
Generate… creates fake documents that look like the ones analyzed (see Generating test documents above).
- Charts: the
Chart tab draws the documents matching the filter, or the output of the Aggregate tab's pipeline (up to the stage shown): the Data selector chooses Filter or Pipeline, and when opened it follows the tab you came from. The computations run on the server with an aggregation pipeline, so they also work on large collections.
- Bar and Pie: for each value of the
Category field, the number of documents, or the sum / average / minimum / maximum of a numeric field; the largest categories (Top, 20 for bars and 10 for pies). Arrays count each element (tags); with grouped dates, the bars are in time order.
- Line: like bars, but ordered along the category, usually a date; dates can be grouped by hour, day, week, month or year.
- Scatter: two numeric or date fields of a random sample of documents (
Sample, 1,000).
- Histogram: the distribution of a numeric or date field in
Bins equal intervals (also long and decimal).
Series splits bars, lines and points by the values of another field (up to 12 series, the largest ones).
- Clicking a bar, a slice or a point of the line opens
Find with the matching filter ({ status: "active", "address.city": "Milano" }, a date or value range) to see those documents.
Code shows the chart's pipeline as code (mongosh, Node.js, Python, Java, C#, Go); Export PNG saves the image. Colors follow the VS Code theme.
- Views: right-click a view →
Edit View Definition… opens viewOn and pipeline as JSON in a tab; Ctrl+S applies the changes (collMod) and refreshes the view's tab.
- Validation rules: right-click a collection →
Edit Validation Rules… (or Validation rules… in the Schema tab) opens validator, validationLevel and validationAction as JSON; Ctrl+S applies them.
- If the collection has no rules, a
$jsonSchema generated from a sample of 1,000 documents is proposed: the BSON types of each field (nested and in arrays too) and, as required, the fields that are always present. Review it before saving; validationAction: "warn" logs invalid documents without rejecting them.
validator: {} removes the rules. With a read-only connection the rules can only be read.
- Relationship diagram: right-click a database, a collection or a view →
Relationship Diagram opens a tab with the database's collections as boxes (fields, types, number of documents) and arrows for the references between them:
- MongoDB doesn't declare relations: Mongoster reads a sample of documents from each collection (100 / 500 / 2,000, random with
$sample in large collections) and looks for fields that look like references. An ObjectId or a UUID can point to the _id of any collection with the same _id type; strings and numbers only to collections with a similar name (categoryId → categories, customerEmail → customers.email), on _id or on a field with a unique index. Up to 20 values of each field are actually looked up in the target collection (one $in per collection): the relation exists if at least 20% (ObjectId/UUID) or 60% (strings and numbers) of them are found. DBRefs are recognized directly; views are linked to their source collection;
N on an arrow marks an array of references (items[].productId, productIds), a many-to-many relation; PK, UK and FK mark _id, unique fields and fields that point elsewhere. Up to 14 fields are shown per box, in document order; Keys only keeps only keys and references;
- collections are laid out in columns following the references, those without relations in a grid below. Boxes can be dragged (their position is kept while the tab is open), the background can be panned and the wheel zooms;
Fit fits the diagram to the tab, Reset Layout goes back to the automatic layout;
- clicking a box or a relation in the
Relations list (at the bottom, with how many sampled values were found) highlights its links; double-click or Enter on a box opens the collection;
Copy Mermaid copies the diagram as a Mermaid erDiagram (to paste into a README or a wiki); Save SVG… saves an SVG image with the current layout.
- Follow references: in a collection's tab, the cells of fields that reference another collection are underlined on hover:
- Ctrl+click (Cmd+click on macOS), Ctrl+Enter on the selected cell, or
Open referenced document in the cell's right-click menu opens the referenced collection with the filter { _id: … }. For an array of references it is { _id: { $in: [...] } } (Open referenced documents), and for a reference to a unique field it is that field. When a field references several collections, a menu asks which one. Fields of sub-documents and the columns of expanded arrays are links too; DBRefs open the collection they name. On a reference cell Ctrl/Cmd+click follows the link instead of selecting the row: select it from the row number or another cell;
Find referencing documents ▸ in the right-click menu of a row lists the collections and fields that reference its collection (orders.userId, posts.tagIds[]) and opens the one you pick, filtered on the row's _id ({ userId: … }; an array field matches the documents whose array contains it);
- the references are found as in the relationship diagram, but in the background, the first time a collection of the database is opened. Mongoster reads 100 documents of each collection once per session, and the links appear when the analysis is done.
Refresh in the tree finds them again, and a Relationship Diagram of the database replaces them with its own (larger sample). A view has the references of its source collection. The setting mongoster.references.detect turns the background analysis off: the table then follows only the references of a diagram opened on the database.
- Indexes: the
Indexes tab (next to Find / Aggregate; also right-click a collection → Indexes) lists the collection's indexes with keys, properties (unique, sparse, TTL, partial, text, wildcard, collation, hidden, …), size on disk compared with the largest one, and number of uses and uses per day since the server started. Above the list: how many they are, their total size, how many were never used. Name, Size and Usage sort the list.
- Clicking an index opens its details: the full definition as the server reports it, the mongosh command that creates it (
Copy) and, on a sharded cluster, the uses on each member.
Create index… opens a dialog with the fields (suggested from the documents; direction 1 / -1 or type text, 2dsphere, 2d, hashed; $** for a wildcard index; the arrows change their order), the name and the options: Unique, Sparse, Hidden, TTL (in seconds, minutes, hours or days), Partial (a filter, with autocomplete), Collation, the weights and the language of a text index, and any other option of createIndex in More options. Text switches to the keys and options as createIndex takes them, and back. The command is shown while editing, with Copy command; an option MongoDB doesn't know is refused instead of being ignored. A wildcard written wrong (address.*, **: MongoDB would quietly index a field with that very name) or given something a wildcard index can't have (unique, sparse, TTL, a type, a wildcardProjection missing or out of place) is pointed out while editing, and an existing index on such a field is marked not a wildcard in the list.
Edit… opens the same dialog on an existing index, and says what the change takes before saving. Hiding it and changing its TTL are applied in place. MongoDB can't change anything else of an index (keys, name, unique, partial filter, …): after a confirmation it is dropped and built again. When the new definition can exist next to the old one (other keys under another name), it is built first and the old index is dropped afterwards, so queries are never left without one. If the new definition is refused (e.g. duplicate values for unique), the index stays, or is created again, as it was.
Duplicate… opens the dialog on a copy of the index, to create a variant of it.
- While an index is being built, the list shows it as
building with the progress of the build, and the dialog can be closed: the build goes on and the tab says when it ends.
Hide hides an index from the query planner without deleting it (useful to find out whether it's still needed), Unhide brings it back; Drop deletes it after a confirmation. _id_ can't be touched.
- Views have no indexes of their own: they use those of the source collection.
- Search indexes (Atlas Search and Vector Search), below the others: name, type (
search / vector search), status colored (READY, PENDING, BUILDING, FAILED, STALE, DELETING, …, with a new definition being built shown too), whether queries can use it, and the definition in short (dynamic mapping or the mapped fields with their types, analyzer; for vectors the path, dimensions, similarity, quantization and the filter fields). Clicking one shows the full definition, the mongosh command (Copy), the server's message and the status on each host. Refresh reads them again, and while one is being built the list is read every 5 seconds, only while the tab is shown.
Create search index… asks for the name, the type (Search / Vector Search) and the definition as text, with colors and suggestions (mapping options, field types, analyzers; vector field options). Dynamic mapping and Static mappings (the fields of the documents with the types seen in them) fill it in, and the sampled fields can be ticked one by one (nested ones under document mappings). For a vector index: Path (the arrays of numbers are suggested), Dimensions (filled in from the length of the sampled arrays), Similarity (cosine, euclidean, dotProduct), Quantization (none, scalar, binary) and the filter fields; the form and the text follow each other. A name already taken, dimensions that don't match the documents and a static mapping without fields are pointed out before saving. Edit… changes the definition (updateSearchIndex: it's built again in the background, queries use the old one until then), Drop drops it after a confirmation. Not on read-only connections.
- On a server without search (MongoDB without
mongot, older versions) the section says what search needs (Atlas, an Atlas local deployment, or MongoDB Community 8.3+ with mongot) instead of showing an error, and doesn't ask the server again until Refresh.
- Index advisor: right-click a connection, a database or a collection →
Index Advisor opens a tab that reads the indexes (with how many times they were used, from $indexStats) and the slow operations, and suggests what to do:
- Indexes to create: for slow queries that read the whole collection, sort in memory or examine many more documents than they return, the index that would serve them (equality fields, then sort, then range). Queries the same index can serve are merged into a single suggestion (
{ kind: 1 } and { kind: 1, user: 1 } → only the second); those already served by an existing index aren't suggested. For each suggestion: number of operations and total time, the queries with their average, documents examined / returned, Open / Explain to open them in the collection's tab, Create Index… (with a confirmation) and Copy for the mongosh command;
- Redundant indexes: indexes whose fields are the start of another index (also with all directions reversed, e.g.
{ a: -1 } and { a: 1, b: 1 }), which therefore only cost writes and memory. unique and TTL indexes aren't considered redundant, nor are those with different options (partialFilterExpression, sparse, collation);
- Unused indexes: indexes never used since statistics started (server start or index creation), only if the statistics cover at least one day; newer ones are only counted.
_id, unique and TTL indexes are left out (they do their job without being read by queries). Hidden indexes are listed too, with Unhide. Statistics only come from the server Mongoster is connected to: on a replica set, check the other members too;
Hide hides the index from the query planner without dropping it (you can go back right away if something slows down), Drop… drops it after a confirmation; on read-only connections the actions are disabled;
- slow operations come from the profiler (
system.profile, the last 5,000 per database) where it has data, otherwise from the "Slow query" lines of the server log (the last 1,024 lines). If a database's profiler is off, Turn On… turns it on for operations slower than the threshold (slowms, usually 100 ms).
- Explain: the
Explain button (in Find and in the pipeline editor) shows how MongoDB runs the query: index used or COLLSCAN, in-memory sort, documents and keys examined compared to those returned, time, execution plan as a tree; Raw shows the full output.
- If the query reads the whole collection or sorts in memory, it suggests an index (equality fields first, then sort, then ranges);
Create… opens the Indexes tab with the index dialog already filled in.
- For pipelines it explains up to the stage shown; those with
$out/$merge can't be explained.
- Code: the
Code button (in Find and in the pipeline editor) shows the query (filter, projection, sort) or the pipeline as code for mongosh, Node.js, Python (PyMongo), Java, C# and Go (driver v2):
- BSON types become the driver's (
ObjectId, dates, Long/Int64, Decimal128, regex, UUID, binary, timestamp, MinKey/MaxKey…), so the query finds exactly the same documents;
Full program adds imports, the connection (from the MONGODB_URI environment variable) and printing of the results: a program that runs as it is;
Copy copies the code, Open in Editor opens it in a new tab with the right language. The chosen language is remembered for the collection.
- Playground:
.mongodb.js files with mongosh syntax. New Playground (icon in the view's title bar, or right-click a connection, a database or a collection) opens one already set to that connection and database.
Ctrl+Enter (or ▶ Run at the top of the file, or the tab's ▶ button) runs the whole file, or only the selected lines; the result opens beside it: documents as a table or as mongosh text (Table / JSON), Copy and Open in Editor.
- As in mongosh,
await isn't needed: every call is awaited where it is, so const u = db.users.findOne({ … }); u.name, db.users.findOne({ … }).name, db.users.find().toArray().length, print(db.users.countDocuments()), if (db.users.findOne({ … })) { … } and `${db.users.countDocuments()} users` all work (also in if/for/while/try blocks and in async functions), while find()/aggregate() cursors stay lazy until toArray(), forEach(), explain()… or the end of the script. Inside callbacks that aren't async (map, forEach of an array…) calls are not awaited. The value of the last expression is shown (for a cursor, the first 200 documents); print(), printjson() and console.log() write to the result's output and to the Mongoster Playground channel.
- Available:
db.<collection> (or db.getCollection("…")) with find/aggregate (cursors with sort, limit, skip, project, toArray, forEach, map, count, explain…), findOne, countDocuments, distinct, insert*, update*, replaceOne, delete*, findOneAnd*, bulkWrite, indexes, drop; use("db"), db.getSiblingDB(), db.runCommand(), db.adminCommand(), db.getCollectionNames(), db.stats(); ObjectId(), ISODate(), NumberLong(), NumberDecimal(), UUID(), Timestamp() and the other BSON types.
- Sessions and transactions, as in mongosh:
const session = db.getMongo().startSession() (also db.getMongo().getDB() / getDBNames()); the collections of session.getDatabase("shop") run every operation in the session (cursors, findOne, counts, distinct, writes, bulkWrite, runCommand). session.startTransaction({ readConcern, writeConcern, readPreference }), commitTransaction(), abortTransaction(), endSession(), inTransaction(), hasEnded(), getSessionId(); session.withTransaction(() => { orders.insertOne(…); stock.updateOne(…) }) commits, retrying the callback on a transient error (a write conflict) and the commit when its outcome is unknown, as the driver does: inside a callback written in place await isn't needed either. Sessions still open at the end of the script, after an error or a Cancel are ended and their transaction aborted (not committed), with a note in the output. Transactions need a replica set or a sharded cluster (a single-node replica set is enough): on a standalone server MongoDB's error says so. With a read-only connection sessions and read-only transactions work, writes are refused as always.
- The default connection and database are shown (and can be changed) in the CodeLens at the top of the file and in the status bar;
use("…") in the script takes precedence. With a read-only connection, methods that write, $out/$merge and commands that change things are refused.
- Errors show the line (click to go there);
Cancel in the notification stops waiting for the result (operations already sent may still complete on the server).
- Autocomplete in the file: after
db. the database's collections and methods, after db.users. the collection's methods, after find(...). the cursor's, after db.getMongo(). and a session (….startSession()., or a variable assigned one) their methods, after session.getDatabase("x"). the collections of x; inside find, aggregate, updateMany, sort… the same field, operator and value suggestions as the table.
- Server monitor: right-click a connection →
Open Server Monitor opens a tab with five sections, refreshed with Refresh or automatically (every 2, 5 or 15 seconds, only while the tab is visible):
Operations: the operations in progress (currentOp) with type, namespace, duration (yellow over 5 s, red over 30 s), client and application, plan (COLLSCAN highlighted), lock waits and command; filter by text and by minimum duration, idle connections and the server's internal operations on request. Click a row for the full details; Kill stops the operation (killOp) after a confirmation.
Slow queries: slow operations, from two sources:
Profiler: those recorded in the chosen database's system.profile (the last 1,000). The profiler level (off, operations over N ms, all) can be changed from there; Clear empties the recorded operations and keeps the settings.
Server log: the "Slow query" lines of the server's recent log (the last 1,024), for all databases or just one, without turning on the profiler; the threshold (slowms, 100 ms by default) can be changed from there.
Since limits them to the last 15 minutes, the last hour or the last 24 hours. Operations of the profiler itself, of the monitor and the server's internal ones are left out.
By query groups operations by query shape: the same query with different values ({ status: ?, age: { $gt: ? } }, a pipeline with its stages) becomes a single row with the number of runs, total, average and maximum time, documents examined compared to those returned, plans and last run, sortable by column. Requests for a cursor's later batches (getMore) count with their query. All shows every operation.
- When the query scans the whole collection (
COLLSCAN), sorts in memory or examines many more documents than it returns, the details (⚑) suggest an index following the ESR rule (equality, sort, range) and Create Index… creates it after a confirmation; if it already exists, it says so.
Open in Collection opens the filter (with sort and projection) or the pipeline in the collection's tab, Explain opens it and shows the current plan right away; Copy Query, Show Operations (the single runs) and the full profiler or log document.
Stats: version, uptime, connections, operations per second by type, network and memory of the server; a table of databases (collections, views, documents, data, storage, indexes) and, clicking one, of its collections, sortable by column.
Replication: the state of the replica set:
- tiles with the replica set name and term, current primary (and the server you are connected to), healthy members, maximum replication lag (yellow over 10 s, red over 60 s; intentionally delayed members are left out), oplog window (how much time it covers: how far a member can fall behind and still catch up), size and number of entries, election settings;
- the members table: state (
PRIMARY, SECONDARY, ARBITER, unreachable…), lag behind the primary, last applied operation, last heartbeat, ping, sync source, priority and votes, notes (hidden, delayed by N s, never primary, tags, error messages), uptime. Click a member for the full replSetGetStatus and replSetGetConfig data;
Step Down… makes the primary step down after a confirmation (replSetStepDown) so that another one is elected, for example to test a failover;
- the oplog: the last 50, 200 or 1,000 replicated operations, newest first, filterable by database or collection (inside transactions too) and by type. For each entry: time, type, namespace,
_id and what changes (set status, address.city · unset tempToken for updates, the inserted document, the command, the operations of a transaction); click for the full entry. Periodic no-ops are left out unless requested.
- On a standalone server or a mongos, the section says so. Without the
clusterMonitor role, members are read from hello with fewer details.
Sharding: the sharded cluster, through a mongos:
- tiles with the shards (and zones), sharded collections (with balancing off, not balanced), chunks (jumbo ones highlighted, chunk size), the balancer (enabled or disabled, round in progress, active window), migrations in the last 24 hours with the failed ones and balancer rounds with errors (
config.changelog, config.actionlog), the config server replica set and the active mongos routers;
- the shards table: replica set and members, state, draining, zones, chunks, data and documents of the sharded collections (
$shardedDataDistribution from 6.0.3, $collStats per shard before), databases it is the primary shard of. Click a shard for its listShards entry;
- the sharded collections, filterable and sortable: shard key (
{ customerId: 1, _id: "hashed" }), unique, balancing on or off, chunks in all and per shard, data and documents with a bar of their distribution across the shards, balance (balancerCollectionStatus: balanced, uneven chunks, zone violation, draining…; without it, uneven when the largest shard holds much more than its share), jumbo chunks. Click a collection for chunks, data and share per shard, its zones with their ranges (config.tags) and the shards in each zone, and the config.collections document; Disable Balancing… / Enable Balancing… after a confirmation (configureCollectionBalancing, or noBalance in config.collections on servers without its enableBalancing option);
- the recent events, newest first: the last 100 migrations, splits, merges and balancer rounds (or every event of
config.changelog), filterable by database or collection, failed ones highlighted; click for the full entry;
Stop Balancer… / Start Balancer… after a confirmation (balancerStop, balancerStart);
- On a standalone server or a replica set the section says that it is not a sharded cluster, on a shard or config server member that it belongs to one (connect to a mongos to see it). Without the
clusterMonitor role it shows what can be read and lists what can't; the balance of each collection also needs clusterManager. The per-collection commands run on Refresh, not on every automatic refresh.
- With a read-only connection, operations can't be killed, the profiler and the threshold can't be changed, suggested indexes can't be created, the primary can't be stepped down and the balancer can't be started or stopped, for the cluster or a collection.
- GridFS: GridFS buckets (the
<bucket>.files / <bucket>.chunks pairs) appear in the tree under the database with a files icon; click to open their tab:
- the list of files with name, size, upload date, content type, metadata and
_id, sortable by name, size or date, in pages of 100, with the total number of files and bytes. The filter searches the name, or accepts a mongosh filter on the files collection ({ "metadata.contentType": "image/png" });
- click a file for a preview: images (up to 4 MB), text (the first 256 KB) or the first 512 bytes in hexadecimal for binary files;
Edit Metadata opens the file's document in the editor (Ctrl+S saves it), Copy _id, Copy Name;
Open downloads the file to a temporary folder and opens it in VS Code (text, images, PDF…); Download… saves it where you choose;
Upload… (also from the tree: right-click a bucket, or a database → Upload Files to GridFS… to create a new one, fs by default) uploads one or more files, with the content type taken from the extension. If files with the same name already exist, you choose whether to add a new revision (GridFS keeps them all), replace them or skip them. Uploads and downloads are streamed with the progress in the notification and can be cancelled;
Rename… and Delete (after a confirmation, together with the chunks); right-click the bucket → Delete GridFS Bucket… deletes the whole bucket. With a read-only connection, files can only be browsed and downloaded.
- Users and roles: right-click a connection (or a database) →
Manage Users and Roles opens a tab with the users and roles of one database or of all of them (Database), filterable by name, role or privilege. At the top you can see which user and roles the connection is authenticated with (or that it isn't).
Users: user, database where it's defined, roles, authentication mechanisms. Create User… asks for the name, the database, the password (Generate creates a random 24-character one, Copy copies it), the roles (with role names suggested; those that only exist in admin, such as clusterMonitor or readAnyDatabase, go there on their own) and optional custom data. Password… sets a new password; after setting it, Copy Password copies it, because MongoDB never shows it again. Click a user for their roles: ✕ revokes a role after a confirmation, Grant adds one. Delete deletes the user after a confirmation.
Roles: custom roles, with privileges (shop.orders: find, insert, shop.* for all the database's collections, cluster), inherited roles and the number of users who have them; Built-in roles adds MongoDB's own. Click a role for its full privileges and users. Create Role… / Edit… ask for the privileges in mongosh syntax ([{ resource: { db: "shop", collection: "orders" }, actions: ["find", "insert"] }]) and the inherited roles; Delete deletes the role after a confirmation.
- If you change the password or remove roles of the user you are connected with, you are reminded to update the connection string. With a read-only connection, users and roles can only be browsed.
- Watch (change streams): right-click a collection, a database or a connection →
Watch Changes (or Watch in the collection's toolbar) opens a tab that shows inserts, updates, replacements and deletes (and drop, rename, …) live, newest first:
- click an event for its details: for updates, the table of changed fields (before → after), for inserts the document, then the current document, the full event with
Copy event and Open document to open it in the editor;
- values before the change (and the deleted document) are shown if the collection records pre-images:
Enable… turns them on (changeStreamPreAndPostImages, after a confirmation; not with read-only connections);
- filters by operation type and by text;
$match applies a server-side filter to the events (e.g. { "fullDocument.status": "active" }); Current document on update also reads the current version of the updated document;
Pause holds new events without closing the stream, Stop / Start close and reopen it, Clear empties the list (the last 1000 events are kept).
- Change streams need a replica set or a sharded cluster (a single-node replica set is enough); on a standalone server, the tab explains this. If the collection is dropped or renamed, the stream closes.
- AI assistants (MCP): an MCP server lets an AI assistant (GitHub Copilot in VS Code, Claude Code, Cursor and other clients of the Model Context Protocol) work with the connections saved in Mongoster. Run
Mongoster: Set Up MCP Server for AI Assistants… from the Command Palette: it turns the server on and copies the configuration for your client.
- The tools:
list_connections, list_databases, list_collections, describe_collection (estimated count, indexes and search indexes, and the fields of a sample of documents with their types and how often they are present), find_documents and aggregate (up to 100 documents in mongosh syntax, with how many match), and open_query, open_aggregation and open_search, which open the collection's tab with the filter or the pipeline's stages, or the global search, and run them so you see the results in Mongoster. Ask for example "find the orders of the users in Rome and show them to me".
- Debugging an application:
watch_changes opens a change stream for a few seconds and returns the inserts, updates, replaces and deletes with the documents and the fields changed, plus a resume token: called again with it, it goes on from where it stopped without losing any change, so the AI can follow what the application writes while you use it. write_history reads the recent writes from the oplog, also those to one document by _id (who changed it and when), with transactions expanded into their operations. mongoster_writes lists the writes made from Mongoster itself (its undo history) and mongoster_write_details the documents as they were before one of them. Change streams and the oplog need a replica set or a sharded cluster.
- Performance:
explain_query explains a find or a pipeline (index used or collection scan, documents examined against returned, in-memory sort) and suggests an index; slow_queries groups the slow operations of the profiler or of the server log by query shape; current_operations shows what the server is running now, with locks and transactions; index_advice lists the indexes to create, the redundant ones and the unused ones; collection_stats gives the sizes and the use of each index. They never change the profiler or kill operations.
- The deployment:
server_status (version, topology, connections, operation counters, memory, cache, lock queues, transactions), database_stats (sizes of the databases and of their collections), replica_set_status (members, state, lag, oplog window) and sharding_status (shards, sharded collections, balancer, recent migrations). Without a role such as clusterMonitor they show what they can read and say which role is missing.
- The data model:
count_documents, distinct_values (the values of a field with how many documents have each), collection_options (validator, view pipeline, capped, time series, collation, shard key: why an insert is refused) and describe_relations (the references between collections that the relationship diagram finds). list_saved_queries gives the queries you saved on a collection, and redis_oplog_status whether a connection publishes to redis-oplog, on which channels, and its last error (never the Redis URL).
- Tabs for you: besides the queries, aggregations and searches,
open_watch, open_monitor (on a section: operations, slow queries, statistics, replication, sharding), open_explain and open_history open those tabs.
- GitHub Copilot in VS Code finds the server on its own once it is on. For Claude Code, the setup command copies
claude mcp add --transport http mongoster http://127.0.0.1:37017/mcp --header "Authorization: Bearer …"; for clients configured with JSON (.mcp.json, Cursor, Windsurf…) it copies the mcpServers entry.
- The server never writes: there are no tools that change data, and pipelines with
$out or $merge are refused. It listens on 127.0.0.1 only and needs an access token, kept in VS Code's SecretStorage (Generate a new access token replaces it); connection strings are never given to the AI. With mongoster.mcp.readDocuments off, the AI only sees the structure, statistics and query shapes, and opens tabs, without reading documents: find_documents, aggregate, distinct_values, watch_changes, write_history and mongoster_write_details aren't offered. Each call is written to the Mongoster MCP output channel.
- Several VS Code windows: the tabs open in the window you used last. Only one window can listen on the port, so a window that gets the focus takes it from the one that had it (calls in progress there finish); when that window is closed, another one takes the port within a few seconds.
- Port:
37017 on 127.0.0.1. Mongoster: Change MCP Server Port… (also Change the port… in the setup command) asks for another one; clients other than Copilot then need the new address, so copy the configuration again. If another program is using the port, a warning says so and Change Port suggests a free one.
- Settings:
mongoster.mcp.enabled (off by default), mongoster.mcp.port and mongoster.mcp.readDocuments.
- Views are read-only, like the collections of read-only connections (
view / read-only badge next to the name).
Ctrl+C on a selected cell copies its value.
Desktop app
The same code also runs as a desktop app (Electron) for Windows, macOS and Linux, for those who don't use VS Code. Everything described above works the same way; what VS Code provides is replaced by the app:
- Window: the connections in the side bar (
Ctrl+B hides it), tabs on two sides (a tab's menu has Move to the Other Side; documents, playground results and what the extension opens "beside" go to the second one), Ctrl+PageUp / Ctrl+PageDown to switch tab, Ctrl+W to close it.
- Commands: the same context menus on the tree and buttons in its title, the menu bar, and the Command Palette (
Ctrl+Shift+P).
- Editor: documents as JSON, playgrounds, view definitions, validation rules and generated code open in the editor of VS Code (Monaco), with
Ctrl+S to save, the playground's CodeLens, Ctrl+Enter and autocomplete. A new playground is saved as a .mongodb.js file wherever you like; File › Open File… (Ctrl+O) opens it again, with the connection it had.
- Settings (
Ctrl+,): the mongoster.* settings in a tab, plus the color theme (View › Theme: dark, light or the system's).
- Storage: connections, history and settings are kept in the app's own folder (
%APPDATA%\Mongoster, ~/Library/Application Support/Mongoster, ~/.config/Mongoster), and connection strings, passwords and the MCP token are encrypted with the system's keychain. The app and the extension don't share their connections.
- AI assistants (MCP): the MCP server works in the app too, with the same setup command (
Tools menu). Only the automatic discovery by GitHub Copilot needs the extension. The app and VS Code have their own access tokens and the same default port: the first one started gets it, and Change MCP Server Port… gives the other one its own.
- Scheduled tasks: with
mongoster.scheduledTasks.keepRunningInTray on (off by default) and at least one task enabled, closing the window keeps the app running in the system tray, so the tasks keep running: the tray icon's menu has Open Mongoster and Quit, and a task that fails meanwhile shows a system notification. Show Scheduled Tasks is also in the Tools menu.
The installers of each version are on the Releases page: .exe for Windows, .dmg for macOS (Intel and Apple silicon), .AppImage for Linux. They are not signed with a certificate yet, so the first time Windows SmartScreen asks to confirm (More info, then Run anyway) and macOS wants the app allowed in System Settings › Privacy & Security.
To run it from the sources or build the installers yourself, see Development.
Development
npm install
npm run build
Press F5 in VS Code ("Run Mongoster") to open an Extension Development Host window, or run npm run app for the desktop app. Building, testing and releasing are described in docs/DEVELOPMENT.md, and how the code is organized in docs/ARCHITECTURE.md.
| |