# MongoDB Adapter

## Connection Requirements

{% stepper %}
{% step %}

### IP

IP address of the MongoDB host.
{% endstep %}

{% step %}

### Port

Port number (optional, default: 27017).
{% endstep %}

{% step %}

### Connection String

Only required when using MongoDB Atlas.

{% hint style="info" %}
Provide the full connection string as given by the Atlas dashboard (starting with `mongodb+srv://`). For local MongoDB instances, leave this field empty and use host, database, and authentication parameters instead.
{% endhint %}
{% endstep %}

{% step %}

### Database

Name of the MongoDB database to connect to.
{% endstep %}

{% step %}

### Authentication database

The database in which the MongoDB user is created. This is used as the `authSource` during authentication.
{% endstep %}

{% step %}

### Username

Username for authenticating with the MongoDB instance.
{% endstep %}

{% step %}

### Password

Password for the provided username. Used during authentication.
{% endstep %}

{% step %}

### View Name

Name of the MongoDB view to retrieve data from. (optional)

{% hint style="info" %}
View\
OctoXLabs needs a for integration. In this view, the name of the column with the hostname must be `Hostname`. You can add the remaining fields as you wish.
{% endhint %}
{% endstep %}

{% step %}

### Custom query

The custom query field for MongoDB. (optional).

Example:

{% code title="example.json" %}

```json
{ "hostname": { "$in": ["server1.example.com"] } }
```

{% endcode %}
{% endstep %}

{% step %}

### Collection Name

The name of the MongoDB collection to query. (required).

Example: `servers`
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
Please perform a **connection test** to ensure there is a valid connection to the host.\
When the discovery operation is finalized, you will be able to see the details on the **Assets** page.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.octoxlabs.com/adapters/adapters/mongodb-adapter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
