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

# MongoDB

> Connect MongoDB to query your collections and analyze your documents with natural language

Connect Adapt to MongoDB to query your collections and analyze your documents
using natural language. Adapt connects to your database through a standard
connection string, so you can explore collections and pull insights without
writing queries by hand.

## Set up credentials

Adapt connects to MongoDB using a connection string (URI). MongoDB Atlas uses
the `mongodb+srv://` format, and self-hosted deployments typically use
`mongodb://`.

<Steps>
  <Step title="Create a read-only database user (recommended)">
    In MongoDB Atlas, go to **Database Access** and add a database user with a
    read-only role (for example `readAnyDatabase`, or `read` on a specific
    database) rather than an admin account. Note the username and password.
  </Step>

  <Step title="Allowlist network access">
    In Atlas, go to **Network Access** and add the IP addresses that need to
    connect so Adapt can reach your cluster.
  </Step>

  <Step title="Copy your connection string">
    In Atlas, go to **Database > Clusters**, click **Connect**, choose
    **Drivers**, and copy the connection string. It looks like:

    ```
    mongodb+srv://<username>:<password>@cluster0.example.mongodb.net/?retryWrites=true&w=majority
    ```

    Replace `<username>` and `<password>` with your database user's credentials.
    For self-hosted deployments, use your `mongodb://host:27017/...` URI. Any
    special characters in the password must be percent-encoded.
  </Step>
</Steps>

<Note>
  The `mongodb+srv://` format resolves your cluster's hosts automatically. Use the
  plain `mongodb://` format for standalone or self-managed servers.
</Note>

## Connect to Adapt

<Steps>
  <Step title="Open Integrations">
    In Adapt, go to **Settings > Integrations**.
  </Step>

  <Step title="Find MongoDB">
    Search for **MongoDB** and select it from the catalog.
  </Step>

  <Step title="Start the connection">
    Click **Connect** to open the connection form.
  </Step>

  <Step title="Add your credentials">
    Enter the values you gathered above, then click **Add connection**:

    | Secret Name   | Value                          |
    | ------------- | ------------------------------ |
    | `MONGODB_URI` | Your MongoDB connection string |

    You can rename the connection and choose whether it is shared with your
    organization or kept personal to you.
  </Step>

  <Step title="Test the connection">
    Ask Adapt to list your collections or query your data.
  </Step>
</Steps>

### Security

* Credentials are encrypted at rest with AES-256
* Use a dedicated database user with a read-only role
* Restrict network access with an IP access list and allowlist only trusted addresses
* Connect over TLS, which is enabled by default for Atlas `mongodb+srv://` connections
* Never share your connection string publicly or commit it to source control

## Capabilities

Adapt can query your MongoDB database. Explore your collections and analyze your
documents using natural language.

### Examples

Explore data:

```
What collections are in my MongoDB database?
```

Inspect documents:

```
Show me a sample document from the orders collection.
```

Summarize records:

```
How many users were created in the last 30 days?
```

Analyze trends:

```
What are the top 10 products by order count this month?
```
