# MongoDB — Pipedream Connect

> MongoDB is an open source NoSQL database management program.

- API slug: `mongodb` (use in MCP headers and tool keys)
- Auth: API key (Pipedream-managed)
- Categories: Databases
- Website: https://www.mongodb.com/
- This page (HTML): https://pipedream.com/apps/mongodb
- Tools: 9 actions · 4 triggers

## Connect via MCP (recommended)

- Endpoint: `https://remote.mcp.pipedream.net/v3`
- Headers: `Authorization: Bearer <token>` · `x-pd-project-id` · `x-pd-environment` · `x-pd-external-user-id` · `x-pd-app-slug: mongodb`

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "mongodb",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// e.g. run Create New Document:
const result = await mcp.callTool({
  name: "mongodb-create-new-document",
  arguments: {
    database: "Database",
    collection: "Collection",
  },
})
```

Docs: [MCP guide](https://pipedream.com/docs/connect/mcp/developers.md)

## SDK

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "mongodb-create-new-document",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    mongodb: { authProvisionId: "apn_xxxxxxx" },
    database: "Database",
    collection: "Collection",
  },
})
```

Docs: [Managed auth guide](https://pipedream.com/docs/connect/managed-auth/quickstart.md) · [Tools guide](https://pipedream.com/docs/connect/components.md)

## Actions (9)

### `mongodb-create-new-document` — Create New Document (Write)

Create a new document in a collection of your choice. See the docs here

Full schema: https://pipedream.com/apps/mongodb/actions/create-new-document.md

### `mongodb-delete-document` — Delete a Document (Write)

Delete a single document by ID. See the docs here

Full schema: https://pipedream.com/apps/mongodb/actions/delete-document.md

### `mongodb-execute-aggregation` — Execute Aggregation (Write)

Execute an aggregation pipeline on a MongoDB collection. See the documentation

Full schema: https://pipedream.com/apps/mongodb/actions/execute-aggregation.md

### `mongodb-find-document` — Find Document (Read-only)

Finds a document by a query filter. See the documentation

Full schema: https://pipedream.com/apps/mongodb/actions/find-document.md

### `mongodb-find-document-by-id` — Find Document by Id (Read-only)

Retrieves a single document by ID. See the docs here

Full schema: https://pipedream.com/apps/mongodb/actions/find-document-by-id.md

### `mongodb-list-database-options` — List Database Options (Read-only)

Retrieves available options for the Database field.

Full schema: https://pipedream.com/apps/mongodb/actions/list-database-options.md

### `mongodb-search-documents` — Search Documents (Read-only)

Search for specific documents or return all documents. See the docs here

Full schema: https://pipedream.com/apps/mongodb/actions/search-documents.md

### `mongodb-update-document` — Update a Document (Write)

Updates a single document by ID. See the docs here

Full schema: https://pipedream.com/apps/mongodb/actions/update-document.md

### `mongodb-update-documents` — Update Documents (Write)

Updates many documents by query filter. See the documentation

Full schema: https://pipedream.com/apps/mongodb/actions/update-documents.md

## Triggers (4)

### `mongodb-new-collection` — New Collection (Polling)

Emit new an event when a new collection is added to a database

Full schema: https://pipedream.com/apps/mongodb/triggers/new-collection.md

### `mongodb-new-database` — New Database (Polling)

Emit new an event when a new database is added

Full schema: https://pipedream.com/apps/mongodb/triggers/new-database.md

### `mongodb-new-document` — New Document (Polling)

Emit new an event when a new document is added to a collection

Full schema: https://pipedream.com/apps/mongodb/triggers/new-document.md

### `mongodb-new-field-in-document` — New Field in Document (Polling)

Emit new an event when a new field is added to a document

Full schema: https://pipedream.com/apps/mongodb/triggers/new-field-in-document.md

---

- All apps: https://pipedream.com/apps — index: https://pipedream.com/llms.txt
- Pipedream docs for agents: https://pipedream.com/docs/llms.txt
