> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# MongoDB

> Mount a MongoDB cluster as a Mirage filesystem of databases, collections, and documents.

`MongoDBVFS` exposes a MongoDB connection as a read-only filesystem: databases at the top level, collections inside, individual documents at the leaves.

Setup steps for the connection URI live at [MongoDB Credentials](/home/setup/mongodb).

## Node

```bash theme={null}
pnpm add @struktoai/mirage-node mongodb
```

```ts theme={null}
import { MongoDBVFS, MountMode, Workspace } from '@struktoai/mirage-node'

const mongo = new MongoDBVFS({
  uri: process.env.MONGO_URI!,
  databases: ['app', 'analytics'],
})

const ws = new Workspace({ '/mongo': mongo }, { mode: MountMode.READ })
await ws.shell('ls /mongo/app/users/')
```

## Browser

```bash theme={null}
pnpm add @struktoai/mirage-browser
```

The browser variant routes Mongo operations through an HTTP driver (no direct DB connection from the page). The browser examples ship a `mongo_proxy` Vite plugin that forwards to a server-side `mongodb` driver:

```ts theme={null}
import { MongoDBVFS, MountMode, Workspace } from '@struktoai/mirage-browser'

const mongo = new MongoDBVFS({
  uri: 'mongodb-proxy://app',
  httpDriver: { fetch: window.fetch },
})
```

## Config

| Field | Default | Notes |
| - | - | - |
| `uri` | required | Mongo connection URI. Redacted in snapshots. |
| `databases` | none | Optional allowlist of database names. |
| `maxDocLimit` | `5000` | Most documents one `tail -n` returns; past it, a notice on stderr and exit 1. |

## Mount mode

`read`.

For the database/collection/document layout see the [Python MongoDB docs](/python/vfs/mongodb).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.