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

# mongodb

> MongoDB API

**Server path:** `/mongodb` | **Type:** Application | **PCID required:** Yes

## Tools

| Tool                                                          | Description                                                                                                                                                                                                                                              |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`mongodb_aggregate`](#mongodb_aggregate)                     | Execute an aggregation pipeline on a MongoDB collection. Supports read-only stages such as $match, $group, $sort, $project, $lookup, $unwind, $limit, and $skip. Note: $out and $merge stages write data to collections and should be used with caution. |
| [`mongodb_count_documents`](#mongodb_count_documents)         | Count the number of documents in a MongoDB collection matching the given filter.                                                                                                                                                                         |
| [`mongodb_delete_many`](#mongodb_delete_many)                 | Delete all documents in a MongoDB collection that match the filter.                                                                                                                                                                                      |
| [`mongodb_delete_one`](#mongodb_delete_one)                   | Delete the first document in a MongoDB collection that matches the filter.                                                                                                                                                                               |
| [`mongodb_describe_collection`](#mongodb_describe_collection) | Infer the schema of a MongoDB collection by sampling documents. Returns field names and their detected BSON types.                                                                                                                                       |
| [`mongodb_find`](#mongodb_find)                               | Find multiple documents in a MongoDB collection matching the given filter. Returns an array of documents.                                                                                                                                                |
| [`mongodb_find_one`](#mongodb_find_one)                       | Find a single document in a MongoDB collection matching the given filter. Returns the first matched document or null.                                                                                                                                    |
| [`mongodb_get_info`](#mongodb_get_info)                       | Get information about the connected MongoDB database.                                                                                                                                                                                                    |
| [`mongodb_insert_many`](#mongodb_insert_many)                 | Insert multiple documents into a MongoDB collection in a single operation.                                                                                                                                                                               |
| [`mongodb_insert_one`](#mongodb_insert_one)                   | Insert a single document into a MongoDB collection.                                                                                                                                                                                                      |
| [`mongodb_list_collections`](#mongodb_list_collections)       | List all collections in the connected MongoDB database.                                                                                                                                                                                                  |
| [`mongodb_update_many`](#mongodb_update_many)                 | Update all documents in a MongoDB collection that match the filter. Use MongoDB update operators like $set, $unset, $inc, $push.                                                                                                                         |
| [`mongodb_update_one`](#mongodb_update_one)                   | Update the first document in a MongoDB collection that matches the filter. Use MongoDB update operators like $set, $unset, $inc, $push.                                                                                                                  |

***

## mongodb\_aggregate

Execute an aggregation pipeline on a MongoDB collection. Supports read-only stages such as $match, $group, $sort, $project, $lookup, $unwind, $limit, and $skip. Note: $out and $merge stages write data to collections and should be used with caution.

**Parameters:**

| Parameter    | Type      | Required | Default | Description                                                                                                                                                          |
| ------------ | --------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `collection` | string    | Yes      | —       | Collection name                                                                                                                                                      |
| `pipeline`   | object\[] | Yes      | —       | Aggregation pipeline stages (e.g. \[\{ "$match": &#123; "status": "active" &#125; &#125;, &#123; "$group": \{ "\_id": "$category", "total": &#123; "$sum": 1 } } }]) |
| `options`    | object    | No       | —       | Additional MongoDB operation options (e.g. \{ "limit": 10, "sort": \{ "name": 1 } })                                                                                 |

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      },
      "collection": {
        "type": "string",
        "description": "Collection name"
      },
      "pipeline": {
        "type": "array",
        "items": {
          "type": "object",
          "additionalProperties": true
        },
        "description": "Aggregation pipeline stages (e.g. [{ \"$match\": { \"status\": \"active\" } }, { \"$group\": { \"_id\": \"$category\", \"total\": { \"$sum\": 1 } } }])"
      },
      "options": {
        "type": "object",
        "additionalProperties": true,
        "description": "Additional MongoDB operation options (e.g. { \"limit\": 10, \"sort\": { \"name\": 1 } })"
      }
    },
    "required": [
      "PCID",
      "collection",
      "pipeline"
    ]
  }
  ```
</Expandable>

***

## mongodb\_count\_documents

Count the number of documents in a MongoDB collection matching the given filter.

**Parameters:**

| Parameter    | Type   | Required | Default | Description                                                                          |
| ------------ | ------ | -------- | ------- | ------------------------------------------------------------------------------------ |
| `collection` | string | Yes      | —       | Collection name                                                                      |
| `filter`     | object | No       | —       | MongoDB query filter (e.g. \{ "status": "active", "age": \{ "\$gt": 18 } })          |
| `options`    | object | No       | —       | Additional MongoDB operation options (e.g. \{ "limit": 10, "sort": \{ "name": 1 } }) |

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      },
      "collection": {
        "type": "string",
        "description": "Collection name"
      },
      "filter": {
        "type": "object",
        "additionalProperties": true,
        "description": "MongoDB query filter (e.g. { \"status\": \"active\", \"age\": { \"$gt\": 18 } })"
      },
      "options": {
        "type": "object",
        "additionalProperties": true,
        "description": "Additional MongoDB operation options (e.g. { \"limit\": 10, \"sort\": { \"name\": 1 } })"
      }
    },
    "required": [
      "PCID",
      "collection"
    ]
  }
  ```
</Expandable>

***

## mongodb\_delete\_many

Delete all documents in a MongoDB collection that match the filter.

**Parameters:**

| Parameter    | Type   | Required | Default | Description                                                                                                           |
| ------------ | ------ | -------- | ------- | --------------------------------------------------------------------------------------------------------------------- |
| `collection` | string | Yes      | —       | Collection name                                                                                                       |
| `filter`     | any    | Yes      | —       | Filter to identify documents to delete. Must contain at least one condition; use mongodb\_find first to verify scope. |
| `options`    | object | No       | —       | Additional MongoDB operation options (e.g. \{ "limit": 10, "sort": \{ "name": 1 } })                                  |

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      },
      "collection": {
        "type": "string",
        "description": "Collection name"
      },
      "filter": {
        "type": "effects",
        "description": "Filter to identify documents to delete. Must contain at least one condition; use mongodb_find first to verify scope."
      },
      "options": {
        "type": "object",
        "additionalProperties": true,
        "description": "Additional MongoDB operation options (e.g. { \"limit\": 10, \"sort\": { \"name\": 1 } })"
      }
    },
    "required": [
      "PCID",
      "collection",
      "filter"
    ]
  }
  ```
</Expandable>

***

## mongodb\_delete\_one

Delete the first document in a MongoDB collection that matches the filter.

**Parameters:**

| Parameter    | Type   | Required | Default | Description                                                                          |
| ------------ | ------ | -------- | ------- | ------------------------------------------------------------------------------------ |
| `collection` | string | Yes      | —       | Collection name                                                                      |
| `filter`     | object | Yes      | —       | Filter to identify the document to delete                                            |
| `options`    | object | No       | —       | Additional MongoDB operation options (e.g. \{ "limit": 10, "sort": \{ "name": 1 } }) |

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      },
      "collection": {
        "type": "string",
        "description": "Collection name"
      },
      "filter": {
        "type": "object",
        "additionalProperties": true,
        "description": "Filter to identify the document to delete"
      },
      "options": {
        "type": "object",
        "additionalProperties": true,
        "description": "Additional MongoDB operation options (e.g. { \"limit\": 10, \"sort\": { \"name\": 1 } })"
      }
    },
    "required": [
      "PCID",
      "collection",
      "filter"
    ]
  }
  ```
</Expandable>

***

## mongodb\_describe\_collection

Infer the schema of a MongoDB collection by sampling documents. Returns field names and their detected BSON types.

**Parameters:**

| Parameter    | Type   | Required | Default | Description                |
| ------------ | ------ | -------- | ------- | -------------------------- |
| `collection` | string | Yes      | —       | Collection name to inspect |

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      },
      "collection": {
        "type": "string",
        "description": "Collection name to inspect"
      }
    },
    "required": [
      "PCID",
      "collection"
    ]
  }
  ```
</Expandable>

***

## mongodb\_find

Find multiple documents in a MongoDB collection matching the given filter. Returns an array of documents.

**Parameters:**

| Parameter    | Type   | Required | Default | Description                                                                          |
| ------------ | ------ | -------- | ------- | ------------------------------------------------------------------------------------ |
| `collection` | string | Yes      | —       | Collection name                                                                      |
| `filter`     | object | No       | —       | MongoDB query filter (e.g. \{ "status": "active", "age": \{ "\$gt": 18 } })          |
| `options`    | object | No       | —       | Additional MongoDB operation options (e.g. \{ "limit": 10, "sort": \{ "name": 1 } }) |

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      },
      "collection": {
        "type": "string",
        "description": "Collection name"
      },
      "filter": {
        "type": "object",
        "additionalProperties": true,
        "description": "MongoDB query filter (e.g. { \"status\": \"active\", \"age\": { \"$gt\": 18 } })"
      },
      "options": {
        "type": "object",
        "additionalProperties": true,
        "description": "Additional MongoDB operation options (e.g. { \"limit\": 10, \"sort\": { \"name\": 1 } })"
      }
    },
    "required": [
      "PCID",
      "collection"
    ]
  }
  ```
</Expandable>

***

## mongodb\_find\_one

Find a single document in a MongoDB collection matching the given filter. Returns the first matched document or null.

**Parameters:**

| Parameter    | Type   | Required | Default | Description                                                                          |
| ------------ | ------ | -------- | ------- | ------------------------------------------------------------------------------------ |
| `collection` | string | Yes      | —       | Collection name                                                                      |
| `filter`     | object | No       | —       | MongoDB query filter (e.g. \{ "status": "active", "age": \{ "\$gt": 18 } })          |
| `options`    | object | No       | —       | Additional MongoDB operation options (e.g. \{ "limit": 10, "sort": \{ "name": 1 } }) |

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      },
      "collection": {
        "type": "string",
        "description": "Collection name"
      },
      "filter": {
        "type": "object",
        "additionalProperties": true,
        "description": "MongoDB query filter (e.g. { \"status\": \"active\", \"age\": { \"$gt\": 18 } })"
      },
      "options": {
        "type": "object",
        "additionalProperties": true,
        "description": "Additional MongoDB operation options (e.g. { \"limit\": 10, \"sort\": { \"name\": 1 } })"
      }
    },
    "required": [
      "PCID",
      "collection"
    ]
  }
  ```
</Expandable>

***

## mongodb\_get\_info

Get information about the connected MongoDB database.

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      }
    },
    "required": [
      "PCID"
    ]
  }
  ```
</Expandable>

***

## mongodb\_insert\_many

Insert multiple documents into a MongoDB collection in a single operation.

**Parameters:**

| Parameter    | Type      | Required | Default | Description                                                                          |
| ------------ | --------- | -------- | ------- | ------------------------------------------------------------------------------------ |
| `collection` | string    | Yes      | —       | Collection name                                                                      |
| `documents`  | object\[] | Yes      | —       | Array of documents to insert                                                         |
| `options`    | object    | No       | —       | Additional MongoDB operation options (e.g. \{ "limit": 10, "sort": \{ "name": 1 } }) |

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      },
      "collection": {
        "type": "string",
        "description": "Collection name"
      },
      "documents": {
        "type": "array",
        "items": {
          "type": "object",
          "additionalProperties": true,
          "description": "Document to insert as a key-value object"
        },
        "description": "Array of documents to insert"
      },
      "options": {
        "type": "object",
        "additionalProperties": true,
        "description": "Additional MongoDB operation options (e.g. { \"limit\": 10, \"sort\": { \"name\": 1 } })"
      }
    },
    "required": [
      "PCID",
      "collection",
      "documents"
    ]
  }
  ```
</Expandable>

***

## mongodb\_insert\_one

Insert a single document into a MongoDB collection.

**Parameters:**

| Parameter    | Type   | Required | Default | Description                                                                          |
| ------------ | ------ | -------- | ------- | ------------------------------------------------------------------------------------ |
| `collection` | string | Yes      | —       | Collection name                                                                      |
| `document`   | object | Yes      | —       | Document to insert as a key-value object                                             |
| `options`    | object | No       | —       | Additional MongoDB operation options (e.g. \{ "limit": 10, "sort": \{ "name": 1 } }) |

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      },
      "collection": {
        "type": "string",
        "description": "Collection name"
      },
      "document": {
        "type": "object",
        "additionalProperties": true,
        "description": "Document to insert as a key-value object"
      },
      "options": {
        "type": "object",
        "additionalProperties": true,
        "description": "Additional MongoDB operation options (e.g. { \"limit\": 10, \"sort\": { \"name\": 1 } })"
      }
    },
    "required": [
      "PCID",
      "collection",
      "document"
    ]
  }
  ```
</Expandable>

***

## mongodb\_list\_collections

List all collections in the connected MongoDB database.

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      }
    },
    "required": [
      "PCID"
    ]
  }
  ```
</Expandable>

***

## mongodb\_update\_many

Update all documents in a MongoDB collection that match the filter. Use MongoDB update operators like $set, $unset, $inc, $push.

**Parameters:**

| Parameter    | Type   | Required | Default | Description                                                                                                                |
| ------------ | ------ | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
| `collection` | string | Yes      | —       | Collection name                                                                                                            |
| `filter`     | any    | Yes      | —       | Filter to identify documents to update. Must contain at least one condition; use mongodb\_find first to verify scope.      |
| `update`     | object | Yes      | —       | MongoDB update document using update operators (e.g. \{ "$set": &#123; "field": "value" &#125;, "$inc": \{ "count": 1 } }) |
| `options`    | object | No       | —       | Additional MongoDB operation options (e.g. \{ "limit": 10, "sort": \{ "name": 1 } })                                       |

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      },
      "collection": {
        "type": "string",
        "description": "Collection name"
      },
      "filter": {
        "type": "effects",
        "description": "Filter to identify documents to update. Must contain at least one condition; use mongodb_find first to verify scope."
      },
      "update": {
        "type": "object",
        "additionalProperties": true,
        "description": "MongoDB update document using update operators (e.g. { \"$set\": { \"field\": \"value\" }, \"$inc\": { \"count\": 1 } })"
      },
      "options": {
        "type": "object",
        "additionalProperties": true,
        "description": "Additional MongoDB operation options (e.g. { \"limit\": 10, \"sort\": { \"name\": 1 } })"
      }
    },
    "required": [
      "PCID",
      "collection",
      "filter",
      "update"
    ]
  }
  ```
</Expandable>

***

## mongodb\_update\_one

Update the first document in a MongoDB collection that matches the filter. Use MongoDB update operators like $set, $unset, $inc, $push.

**Parameters:**

| Parameter    | Type   | Required | Default | Description                                                                                                                |
| ------------ | ------ | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
| `collection` | string | Yes      | —       | Collection name                                                                                                            |
| `filter`     | object | Yes      | —       | Filter to identify the document to update                                                                                  |
| `update`     | object | Yes      | —       | MongoDB update document using update operators (e.g. \{ "$set": &#123; "field": "value" &#125;, "$inc": \{ "count": 1 } }) |
| `options`    | object | No       | —       | Additional MongoDB operation options (e.g. \{ "limit": 10, "sort": \{ "name": 1 } })                                       |

<Expandable title="inputSchema">
  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "PCID": {
        "type": "string",
        "description": "Pink Connect ID"
      },
      "collection": {
        "type": "string",
        "description": "Collection name"
      },
      "filter": {
        "type": "object",
        "additionalProperties": true,
        "description": "Filter to identify the document to update"
      },
      "update": {
        "type": "object",
        "additionalProperties": true,
        "description": "MongoDB update document using update operators (e.g. { \"$set\": { \"field\": \"value\" }, \"$inc\": { \"count\": 1 } })"
      },
      "options": {
        "type": "object",
        "additionalProperties": true,
        "description": "Additional MongoDB operation options (e.g. { \"limit\": 10, \"sort\": { \"name\": 1 } })"
      }
    },
    "required": [
      "PCID",
      "collection",
      "filter",
      "update"
    ]
  }
  ```
</Expandable>
