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

# MongoDB

> MongoDB Provider is a provider used to query MongoDB databases

## Authentication

This provider requires authentication.

* **host**: Mongo host\_uri (required: True, sensitive: False)
* **username**: MongoDB username (required: False, sensitive: False)
* **password**: MongoDB password (required: False, sensitive: True)
* **database**: MongoDB database name (required: False, sensitive: False)
* **auth\_source**: Mongo authSource database name (required: False, sensitive: False)
* **additional\_options**: Mongo kwargs, these will be passed to MongoClient (required: False, sensitive: False)

Certain scopes may be required to perform specific actions or queries via the provider. Below is a summary of relevant scopes and their use cases:

* **connect\_to\_server**: The user can connect to the server (mandatory)

## In workflows

This provider can be used in workflows.

As "step" to query data, example:

```yaml theme={null}
steps:
    - name: Query mongodb
      provider: mongodb
      config: "{{ provider.my_provider_name }}"
      with:
        query: {value}  
        as_dict: {value}  
        single_row: {value}  
```

Check the following workflow example:

* [query\_mongodb.yaml](https://github.com/keephq/keep/blob/main/examples/workflows/query_mongodb.yaml)

## Connecting with the Provider

In order to connect to the MongoDB database, you can use either a connection URI or individual parameters. Here's how you can provide authentication information:

1. If using a connection URI, provide the `host` parameter with the MongoDB connection string.
2. If using individual parameters, provide the following:
   * `username`: MongoDB username.
   * `password`: MongoDB password.
   * `host`: MongoDB hostname.
   * `database`: MongoDB database name.
   * `authSource`: MongoDB database name.

## Notes

* Ensure that the provided user has the necessary privileges to execute queries on the specified MongoDB database.

## Useful Links

* [MongoDB Documentation](https://docs.mongodb.com/)
