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

# MongoDB

> Connect a MongoDB database to Myrmex — create a read-only audit user and add the integration.

import { Note, Steps, Step, CardGroup, Card, Tip } from '@mintlify/components';

Connect your **MongoDB** database so Myrmex can audit its hardening and compliance, check its operational health, explore its collections, and — with approval — run queries and commands for you. Myrmex reaches the database over the native MongoDB protocol through a [Collector](/documentation/agent-endpoint-security/collector-mode) on your network. Operations run live and on demand through the [Integration Specialist](/documentation/multi-agent-system/integration-specialist-agent) agent — Myrmex reads only what you ask for and keeps none of your data on the Myrmex side.

## What Myrmex Can Do

<CardGroup cols={2}>
  <Card title="Compliance audit" icon="shield-halved">
    Run a [Security Posture](/documentation/security-posture/overview) audit and map findings to CIS, ISO 27001, NIST CSF, and BACEN [frameworks](/documentation/security-posture/frameworks).
  </Card>

  <Card title="Health checks" icon="heart-pulse">
    Review connections, replication lag, the oplog window, and cache usage.
  </Card>

  <Card title="Explore collections" icon="table">
    List databases and collections so you can see what the instance holds.
  </Card>

  <Card title="Describe structure" icon="sitemap">
    Inspect a collection's fields, indexes, and validation rules.
  </Card>

  <Card title="Sensitive-data scan" icon="user-secret">
    Scan collections and fields for personal or sensitive data that needs protection.
  </Card>

  <Card title="Run queries" icon="terminal">
    Run read queries and commands any time; writes require your confirmation.
  </Card>
</CardGroup>

## Before You Start

* A **Collector** on a network that can reach the MongoDB host on its TCP port (default `27017`). See [Collector mode](/documentation/agent-endpoint-security/collector-mode).
* A **dedicated database user** for Myrmex (create it in Step 1).
* The **Auth Database** is the `authSource` where the user is defined (default `admin`).

## Step 1 — Create the Credential in MongoDB

Create a dedicated, least-privilege user for auditing. `clusterMonitor` grants read access to server status and configuration; `readAnyDatabase` lets Myrmex list collections and inspect structure.

```javascript theme={null}
// Connected to the admin database as an administrator
use admin
db.createUser({
  user: "myrmex_audit",
  pwd: "a-strong-password",
  roles: [
    { role: "clusterMonitor", db: "admin" },
    { role: "readAnyDatabase", db: "admin" }
  ]
})
```

<Tip>
  Keep the account read-only for auditing. Add `readWrite` on the target database only if you want the agents to run write operations through **Run queries**.
</Tip>

## Step 2 — Add the Integration in Myrmex

From the **Directory**, choose **Add Integration → MongoDB**, then fill in:

| Field             | Description                                                                                             |
| ----------------- | ------------------------------------------------------------------------------------------------------- |
| **Name**          | A unique name for this database.                                                                        |
| **Description**   | Optional note to identify the instance.                                                                 |
| **Host**          | MongoDB server hostname or IP address.                                                                  |
| **Port**          | MongoDB server port (default `27017`).                                                                  |
| **Auth Database** | Authentication database (`authSource`, default `admin`).                                                |
| **Username**      | MongoDB user with permission to run the audit queries.                                                  |
| **Password**      | MongoDB user password (stored encrypted).                                                               |
| **Collectors**    | The [Collector(s)](/documentation/agent-endpoint-security/collector-mode) that can reach this database. |

## Connect

Click **Connect** to validate the login. The database then appears under **Environment → Integrations** alongside your other [integrations](/documentation/integrations/overview), and you can start asking the AI about it in the Workspace.

## Notes

* **Read-only by default.** Auditing, health, exploration, and sensitive-data scans only need the read-only roles above. Add `readWrite` only if you want confirmation-gated **Run queries** writes.
* **Nothing is stored.** Every operation runs in real time through the Collector; results return to your Workspace and no database data is retained on the Myrmex side.
* **Encryption in transit** follows your server's configuration; the posture audit flags an unencrypted listener.
