mcp-mongodb mcp

v1.2.0 · MCP Tool · database · registry.pascalai.org

MongoDB access via FireDAC native driver (libmongoc-1.0.dll). Direct connection to any MongoDB server — no Atlas required. Operations: find, find_one, insert_one, insert_many, update_one, update_many, delete_one, delete_many, aggregate, count. All filter/document/update/pipeline values are JSON strings.

mongodbnosqldatabasedocumentcrudfiredacnative

Input Parameters

ParameterTypeDescription
operationrequired string Operation to perform. One of: find, find_one, insert_one, insert_many, update_one, update_many, delete_one, delete_many, aggregate, count.
hostoptional string MongoDB server host (default: localhost). Default: localhost.
portoptional integer MongoDB server port (default: 27017). Default: 27017.
databaserequired string Database name.
usernameoptional string MongoDB username (omit for no-auth connections).
passwordoptional string MongoDB password.
collectionrequired string Collection name.
filteroptional string Query filter as JSON string (e.g. '{"status":"active"}' or '{"age":{"$gt":18}}'). Default: {} (all documents).
documentoptional string Document to insert as JSON string. Required for insert_one.
documentsoptional string Array of documents as JSON string for insert_many (e.g. '[{"name":"A"},{"name":"B"}]').
updateoptional string Update operators as JSON string for update_one/update_many (e.g. '{"$set":{"status":"closed"}}').
pipelineoptional string Aggregation pipeline as JSON array string for aggregate (e.g. '[{"$match":{"active":true}},{"$group":{"_id":"$city","count":{"$sum":1}}}]').
projectionoptional string Fields to return as JSON string for find/find_one (e.g. '{"name":1,"email":1,"_id":0}').
sortoptional string Sort specification as JSON string for find (e.g. '{"createdAt":-1}' for descending).
limitoptional integer Maximum documents to return for find. Default: 20. Default: 20.
skipoptional integer Number of documents to skip for find (pagination). Default: 0. Default: 0.
upsertoptional boolean If true, insert a new document when no match found (update_one/update_many). Default: false. Default: False.

Output Fields

FieldTypeDescription
ok boolean
documents array[object]
document object
insertedCount integer
matchedCount integer
modifiedCount integer
deletedCount integer
count integer
error string

Examples

Find pending orders

// Input
{
  "operation": "find",
  "host": "localhost",
  "database": "shop",
  "collection": "orders",
  "filter": "{\"status\":\"pending\"}",
  "sort": "{\"createdAt\":-1}",
  "limit": 10
}

// Output
{
  "ok": true,
  "documents": [
    {
      "_id": "...",
      "status": "pending"
    }
  ],
  "count": 1
}

Insert a document

// Input
{
  "operation": "insert_one",
  "host": "localhost",
  "database": "shop",
  "collection": "products",
  "document": "{\"name\":\"Widget\",\"price\":9.99,\"stock\":100}"
}

// Output
{
  "ok": true,
  "insertedCount": 1
}

Update a document with $set

// Input
{
  "operation": "update_one",
  "host": "localhost",
  "database": "shop",
  "collection": "orders",
  "filter": "{\"_id\":{\"$oid\":\"64abc123\"}}",
  "update": "{\"$set\":{\"status\":\"shipped\"}}"
}

// Output
{
  "ok": true,
  "matchedCount": 1,
  "modifiedCount": 1
}

Aggregate: count orders by status

// Input
{
  "operation": "aggregate",
  "host": "localhost",
  "database": "shop",
  "collection": "orders",
  "pipeline": "[{\"$group\":{\"_id\":\"$status\",\"count\":{\"$sum\":1}}},{\"$sort\":{\"count\":-1}}]"
}

// Output
{
  "ok": true,
  "documents": [
    {
      "_id": "shipped",
      "count": 142
    }
  ]
}

Count active users

// Input
{
  "operation": "count",
  "host": "localhost",
  "database": "app",
  "collection": "users",
  "filter": "{\"active\":true}"
}

// Output
{
  "ok": true,
  "count": 3847
}

Connect with authentication

// Input
{
  "operation": "find",
  "host": "mongo.internal",
  "port": 27017,
  "username": "appuser",
  "password": "secret",
  "database": "production",
  "collection": "events",
  "filter": "{}"
}

// Output
{
  "ok": true,
  "documents": [],
  "count": 0
}

Install & Discovery

Install

ppm install mcp-mongodb

Get JSON Schema

GET /v1/packages/mcp-mongodb/1.2.0/schema

Discover by keyword

GET /v1/mcp/discover?q=mongodb
Discovery hint: Install with ppm install mcp-mongodb or invoke remotely via POST /v1/invoke/mcp-mongodb on the MCP Service.