> ## 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.

`MongoDBResource` 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 { MongoDBResource, MountMode, Workspace } from '@struktoai/mirage-node'

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

const ws = new Workspace({ '/mongo': mongo }, { mode: MountMode.READ })
await ws.execute('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 { MongoDBResource, MountMode, Workspace } from '@struktoai/mirage-browser'

const mongo = new MongoDBResource({
  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.        |
| `defaultDocLimit`    | `100`    | Default page size for ad-hoc reads.          |
| `defaultSearchLimit` | `100`    | Default page size for search-style queries.  |
| `maxDocLimit`        | `10_000` | Hard ceiling per read.                       |

## Mount mode

`read`.

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