Docbase

io.github.CloudCorpRecords由 GitHub 账号 CloudCorpRecords 发布v0.1.0更新于 Nov 7, 2026

MongoDB tools: query, aggregate, index, and administer collections and databases.

已验证STDIO仅桌面数据库数据与分析

概览

AI 生成的概览

本地 MCP 服务器,为助手提供完整的 MongoDB 工具:浏览数据库、查询与聚合、写入文档,以及管理集合和索引。

可以做什么
  • 浏览数据库、集合、索引、存储大小与数据库统计信息
  • 执行 find 查询、计数、聚合管道与执行计划分析
  • 批量插入、更新和删除文档
  • 创建、重命名、删除集合与数据库,创建或删除索引
  • 导出匹配的文档并读取服务器日志行
适用场景
适合需要让助手直接查看或修改 MongoDB 实例的场景,例如探查集合结构、运行临时查询与聚合,或在对话中执行管理与数据变更操作。
运行要求
以本地 stdio 进程运行,可通过 npx 或 Docker 镜像启动。实时调用需要 PATH 中有 mongosh 客户端,并能连接到 MongoDB 实例;官方镜像不自带 mongosh。连接字符串可在命令行传入,或通过环境变量 MDB_MCP_CONNECTION_STRING 提供,也可传给 connect 工具。
安装前请注意
多个工具会写入或销毁数据:insert-many、update-many、delete-many、drop-collection、drop-database、rename-collection、drop-index 和 create-index 都会作用于真实数据库。连接字符串可能包含凭据,需以参数或环境变量传入。若缺少 mongosh 或无法连接实例,服务器仍会启动,只在调用时报错。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Docbase,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

docbase

docbase gives an agent — or you, at a terminal — a complete set of MongoDB database tools: browse databases and collections, run find queries and aggregation pipelines, insert, update, and delete documents, manage indexes and collections, read database statistics and server logs, and ask the server to explain a query plan.

There is no bundled MongoDB driver. Every tool call is first mapped to a plain MongoDB command document ({ find: ... }, { aggregate: ... }, { createIndexes: ... }), and the default executor runs that document through the mongosh command-line client with db.runCommand(...). A machine that wants live answers therefore needs mongosh on its PATH and a reachable MongoDB instance. Without either, the server still starts and lists its tools; only the call itself reports the problem, in plain language.

Install

bash
npx @reneturcios/docbase call list-databases

Or run the container image:

bash
docker run -i ghcr.io/cloudcorprecords/docbase

The container defaults to the MCP server (see below). Note the stock image bundles no mongosh binary, so containerised live queries need a mongosh provided on the host or mounted into the image.

CLI

bash
# Run one tool; the JSON-args argument is optional for no-arg toolsdocbase call list-databasesdocbase call find '{"database":"shop","collection":"users","filter":{"active":true},"limit":5}'docbase call db-stats '{"database":"shop"}'
# Start the MCP server (connection string optional, see below)docbase mcp mongodb://alice@localhost:27017/shop
docbase --version

Exit codes: 0 on success, 1 when the tool call, the connection, or mongosh itself fails (the error says which), 2 for usage errors.

The connection string is a normal MongoDB URL (mongodb:// or mongodb+srv://). For both mcp and call it can be left off the command line and supplied through the MDB_MCP_CONNECTION_STRING environment variable. The connect tool also accepts a connectionString argument, which is validated and used for that call's ping.

How a call flows

  1. Arguments are validated (required database/collection names, object-shaped filters, non-empty document arrays, and so on). Invalid calls fail before anything reaches an executor.
  2. The call is mapped to its command document — for example update-many becomes { update: <collection>, updates: [{ q: filter, u: update, multi: true }] }.
  3. The executor runs the document. Three tools post-process the reply: collection-schema samples 25 documents ($sample) and infers a field-to-types map from them; mongodb-logs runs getLog and applies the requested limit to the returned lines; export runs a find and returns the matching documents under the requested export title.

MCP server

One bin serves both faces. The mcp subcommand starts a stdio MCP server:

bash
npx -y @reneturcios/docbase mcp mongodb://alice@localhost:27017/shop

MCP client configuration:

json
{  "mcpServers": {    "docbase": {      "command": "npx",      "args": ["-y", "@reneturcios/docbase", "mcp"],      "env": { "MDB_MCP_CONNECTION_STRING": "mongodb://alice@localhost:27017/shop" }    }  }}

Tools

ToolRequiredOptionalWhat it does
connect—connectionStringPing the instance (validates a supplied connection string)
list-databases——List all databases (listDatabases)
list-collectionsdatabase—List a database's collections
collection-schemadatabase, collection—Infer field types from a 25-document sample
collection-indexesdatabase, collection—List a collection's indexes
collection-storage-sizedatabase, collection—Collection storage statistics (collStats)
finddatabase, collectionfilter, projection, limit, sortRun a find query
aggregatedatabase, collection, pipeline—Run an aggregation pipeline
countdatabase, collectionqueryCount matching documents
insert-manydatabase, collection, documents—Insert documents (ordered)
update-manydatabase, collection, filter, update—Update all matching documents
delete-manydatabase, collection, filter—Delete all matching documents
create-collectiondatabase, collection—Create a collection
drop-collectiondatabase, collection—Drop a collection
drop-databasedatabase—Drop a database
rename-collectiondatabase, collection, newName—Rename a collection (same database)
create-indexdatabase, collection, keys—Create an index; the name is derived from the keys
drop-indexdatabase, collection, indexName—Drop an index by name
explaindatabase, collectionmethod, methodArgsExplain a query plan (queryPlanner verbosity)
exportdatabase, collectionexportTitle, filterReturn matching documents under an export title
db-statsdatabase—Database statistics (dbStats)
mongodb-logs—limit, typeRead server log lines (getLog, default global)

Development

bash
npm installnpm run build   # tsc -> dist/npm test        # node test runner over test/*.test.ts, no network, no live databasenpm run dev     # run the CLI from source via tsx

All command construction, validation, schema inference, and log limiting are covered by tests that drive the core through a fake executor — no MongoDB server and no mongosh binary are needed to run the suite.

License

MIT — see LICENSE.

来源:README.md,提交 bf9c374

工具

22

connect

Connect to a MongoDB instance

输入参数connectionString

list-databases

List all databases in the connected MongoDB instance

无需输入参数。

list-collections

List collections in a MongoDB database

输入参数database必填

collection-schema

Describe the schema for a collection

输入参数database必填collection必填

collection-indexes

List indexes for a collection

输入参数database必填collection必填

collection-storage-size

Get the storage size of a collection

输入参数database必填collection必填

find

Run a find query against a MongoDB collection

输入参数sortlimitfilterdatabase必填collection必填projection

aggregate

Run an aggregation pipeline against a MongoDB collection

输入参数database必填pipeline必填collection必填

count

Count documents in a MongoDB collection

输入参数querydatabase必填collection必填

insert-many

Insert documents into a MongoDB collection

输入参数database必填documents必填collection必填

update-many

Update documents in a MongoDB collection

输入参数filter必填update必填database必填collection必填

delete-many

Delete documents from a MongoDB collection

输入参数filter必填database必填collection必填

create-collection

Create a new collection in a MongoDB database

输入参数database必填collection必填

drop-collection

Drop a collection from a MongoDB database

输入参数database必填collection必填

drop-database

Drop a MongoDB database

输入参数database必填

rename-collection

Rename a MongoDB collection

输入参数newName必填database必填collection必填

create-index

Create an index on a MongoDB collection

输入参数keys必填database必填collection必填

drop-index

Drop an index from a MongoDB collection

输入参数database必填indexName必填collection必填

explain

Get the execution plan for a MongoDB query

输入参数methoddatabase必填collection必填methodArgs

export

Export a MongoDB collection to a file

输入参数filterdatabase必填collection必填exportTitle

db-stats

Get statistics for a MongoDB database

输入参数database必填

mongodb-logs

Retrieve MongoDB log entries

输入参数typelimit

版本历史

1
  1. v0.1.0最新Oct 31, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分