Db MCP Server 12c256e2

MCP数据服务

提供方 kunwarmahen

数据服务 stdio · 本地进程 无需鉴权 社区 / 第三方 Claude DesktopClaude
查看接入方式

通过模型上下文协议查询和管理PostgreSQL和MongoDB数据库,支持自动模式发现、网络范围数据库访问和零配置部署。

一句话选型结论

按资料字段整理

Db MCP Server 12c256e2 属于数据服务类 MCP 服务器,stdio · 本地进程,无需鉴权,可直接接入 Claude Desktop、Claude,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类数据服务 传输方式stdio · 本地进程 鉴权无需鉴权 部署方式本地部署
GitHub 星标 0 仓库热度,无公开仓库时显示未标注
工具数 7 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

数据服务
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量7暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

支持客户端

适用场景

数据库管理Python本地部署PostgreSQLMongoDBAI集成自动发现

安装与配置

stdio · 本地进程 无需鉴权
客户端在本机拉起子进程,数据不出本机
pip install -r requirements.txt

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 Node.js 等运行时,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后客户端会列出约 7 个工具,随便调一个只读工具确认能返回结果。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
数据库查询

用自然语言查库、取数,不用手写 SQL。

数据同步与清洗

把多来源数据拉到一处做整理。

报表取数

按口径快速拉出统计结果。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 资料标注 7 个工具,职责相对集中,接入后不容易误操作。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 Claude Desktop、Claude,换客户端不用重新研究配置。
  • 资料标注无需鉴权,装好就能连。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在数据服务场景里让模型直接调用外部能力的人。
  • 已经在用 Claude Desktop、Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
Db MCP Server 12c256e2当前 7 stdio · 本地进程 本地部署 有 2026-05-17
Memory 9d25f64e 9 未标注 未标注 无 2026-05-17
Getzep MCP 9 stdio · 本地进程 本地部署 有 2026-05-17
anything-llm 未标注 stdio · 本地进程 本地部署 有 2026-04-11
Prisma MCP Server 未标注 stdio · 本地进程 本地部署 有 2026-05-17
Astr Bot 未标注 stdio · 本地进程 本地部署 有 2026-05-17

服务器档案

数据服务
字段来自项目仓库与公开索引,中文说明由本站标注
提供方kunwarmahen上游标注的维护方 kunwarmahen
分类数据服务本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式无需鉴权远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · 未标注本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验2026-05-17上游最后核验时间

详细介绍

9.7 KB
来自项目仓库与上游目录的原文,未做删改

Database MCP Server

Query and manage databases through the Model Context Protocol.

Overview

The Database MCP Server provides AI-accessible database operations for PostgreSQL and MongoDB. It enables:

  • PostgreSQL queries and data management
  • MongoDB document operations
  • Automatic schema discovery
  • Network-wide database access through MCP Discovery Hub
  • Zero-configuration deployment with automatic broadcasting

Perfect for building AI applications that need to interact with databases safely and efficiently.

Features

PostgreSQL Support

  • Get server version and database info
  • List tables in any schema
  • Query data with configurable limits
  • Insert new records
  • SQL validation and safety checks

MongoDB Support

  • List collections
  • Find documents with filters
  • Insert documents
  • ObjectId handling and JSON serialization

Network Integration

  • Automatic multicast broadcasting for discovery
  • Multi-transport support (HTTP and streamable-http)
  • Compatible with MCP Discovery Hub
  • Zero-configuration networking

Installation

Prerequisites

  • Python 3.10+
  • PostgreSQL server (or MongoDB, or both)
  • uv package manager (or pip)

Setup```bash

Clone or navigate to project

cd database-mcp-server

Install dependencies

uv sync

Or with pip:

pip install -r requirements.txt


## Configuration

### Environment Variables```env
# Transport mode
MCP_TRANSPORT=http                    # http, streamable-http, or stdio (default)

# Server settings
MCP_HOST=0.0.0.0                     # Binding host
MCP_PORT=3002                         # Server port
MCP_SERVER_NAME=Database MCP Server  # Display name

# PostgreSQL
DATABASE_URL=postgresql://user:pass@localhost:5432/dbname
# Or individual settings:
POSTGRES_USER=postgres
POSTGRES_PASSWORD=
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=postgres

# MongoDB
MONGODB_URL=mongodb://localhost:27017
MONGODB_DB=test

# Broadcasting (for MCP Discovery Hub)
MCP_ENABLE_BROADCAST=true            # Enable/disable broadcasting
MCP_BROADCAST_INTERVAL=30            # Seconds between announcements

.env File

Create a .env file in the project root:```env

Database Connections

DATABASE_URL=postgresql://postgres:password@localhost:5432/mydb
MONGODB_URL=mongodb://localhost:27017
MONGODB_DB=mydb

MCP Server

MCP_TRANSPORT=http
MCP_PORT=3002
MCP_SERVER_NAME=Database MCP Server
MCP_ENABLE_BROADCAST=true
MCP_BROADCAST_INTERVAL=30


### Docker Example```bash
# With PostgreSQL in Docker
docker run -d \
  -e POSTGRES_PASSWORD=mypassword \
  -p 5432:5432 \
  postgres:15

# With MongoDB in Docker
docker run -d \
  -p 27017:27017 \
  mongo:latest

# Start MCP server
MCP_TRANSPORT=http MCP_PORT=3002 uv run main.py

Usage

Start in HTTP Mode (with broadcasting)```bash

Using environment variables

MCP_TRANSPORT=http MCP_PORT=3002 uv run main.py

Or with .env file

uv run main.py


### Start in Streamable-HTTP Mode```bash
MCP_TRANSPORT=streamable-http MCP_PORT=3002 uv run main.py

Start in Stdio Mode (for Claude)```bash

Default mode, works with Claude Desktop

uv run main.py


## Available Tools

### PostgreSQL Tools

#### Get DB Version```
pg_version()

Retrieve PostgreSQL server version information

List Tables```

pg_list_tables(schema: str = "public")


List all tables in a schema

**Example:**```json
{
  "method": "tools/call",
  "params": {
    "name": "pg_list_tables",
    "arguments": { "schema": "public" }
  }
}

List Rows```

pg_list_rows(table: str, limit: int = 100)


Query data from a table with limit

**Example:**```json
{
  "method": "tools/call",
  "params": {
    "name": "pg_list_rows",
    "arguments": { "table": "users", "limit": 50 }
  }
}

Insert Row```

pg_insert_row(table: str, data: dict)


Insert a new record and return the inserted ID

**Example:**```json
{
  "method": "tools/call",
  "params": {
    "name": "pg_insert_row",
    "arguments": {
      "table": "users",
      "data": { "name": "John", "email": "john@example.com" }
    }
  }
}

MongoDB Tools

List Collections```

mongo_list_collections()


Get all collection names in the database

#### Find Documents```
mongo_find(
  collection: str,
  query: dict = {},
  limit: int = 10
)

Query documents from a collection

Example:```json
{
"method": "tools/call",
"params": {
"name": "mongo_find",
"arguments": {
"collection": "users",
"query": { "status": "active" },
"limit": 20
}
}
}


#### Insert Document```
mongo_insert(collection: str, doc: dict)

Insert a document into a collection

Example:```json
{
"method": "tools/call",
"params": {
"name": "mongo_insert",
"arguments": {
"collection": "logs",
"doc": {
"timestamp": "2024-10-17T10:00:00Z",
"level": "info",
"message": "Server started"
}
}
}
}


## Integration with MCP Discovery Hub

### Automatic Discovery

When broadcasting is enabled, the database server automatically registers:

1. **Server broadcasts**: Every 30 seconds on `239.255.255.250:5353`
2. **Hub discovers**: Discovery hub receives and probes the server
3. **Tools registered**: All 7 database tools become available network-wide

### Multi-Server Setup

Deploy multiple database servers for different purposes:```
Database Server 1 (PostgreSQL, port 3002)
    ↓
Database Server 2 (MongoDB, port 3003)
    ↓
Database Server 3 (Mixed, port 3004)
    ↓
MCP Discovery Hub (port 8000)
    ↓
AI Tool (Claude, etc.)

All servers discovered and available to AI automatically.

API Endpoints (When in HTTP Mode)

GET /

Server information```bash
curl http://localhost:3002/


### POST /mcp

MCP protocol endpoint

All MCP communication (initialize, tools/list, tools/call)

## Use Cases

### 1. Data Analysis

AI-powered analysis of your database:```
"User: Summarize user activity from the last month"
AI: I'll query the activity logs for you...
→ calls pg_list_rows(table="activity_logs", limit=1000)
→ analyzes and summarizes results

2. Automated Reporting

Generate reports from database data:```
"User: Create a report of orders by region"
AI: Let me fetch the order data...
→ calls pg_list_rows(table="orders", limit=10000)
→ groups and aggregates by region
→ generates report


### 3. Data Entry and Updates

AI-assisted data entry:```
"User: Add a new customer with this information"
AI: I'll add them to the database...
→ calls pg_insert_row(table="customers", data={...})

4. Document Search and Retrieval

MongoDB document management:```
"User: Find all documents with status pending"
AI: Searching for pending documents...
→ calls mongo_find(collection="tasks", query={"status": "pending"})


### 5. System Monitoring

Database health and activity monitoring:```
"User: Check if there are any slow queries"
AI: Let me check the query logs...
→ calls pg_list_rows(table="query_logs")
→ identifies slow queries

Safety Features

Input Validation

  • Table and column names validated against regex
  • SQL injection prevention through parameterized queries
  • Data type validation for inserts

Error Handling

  • Database connection errors caught and reported
  • Timeout protection (30 seconds default)
  • Clear error messages for debugging

Best Practices

  1. Read-only operations first: Start with queries before modifying data
  2. Use limits: Always set reasonable limits on queries
  3. Monitor logs: Check database_mcp.log for issues
  4. Backup data: Ensure backups before AI access to production
  5. Audit trail: Log all database modifications from MCP

Performance Considerations

  • Query performance: Depends on query complexity and data size
  • Connection pooling: PostgreSQL pool_size=5 for concurrency
  • Broadcasting overhead: Minimal (30-byte UDP packets)
  • Timeout protection: 30-second limit on operations

Optimization Tips

  • Use limit parameter to reduce data transfer
  • Filter documents with query parameter in MongoDB
  • Create appropriate database indexes for common queries
  • Use schema parameter to narrow PostgreSQL searches

Logs

Server logs are written to database_mcp.log:```bash

View logs

tail -f database_mcp.log

Check for errors

grep ERROR database_mcp.log

Monitor database operations

grep "Listing tables|Inserting|Finding" database_mcp.log


## Troubleshooting

### PostgreSQL Connection Error```bash
# Check PostgreSQL is running
psql postgresql://user:pass@localhost:5432/db

# Verify credentials in .env
echo $DATABASE_URL

MongoDB Connection Error```bash

Check MongoDB is running

mongo --eval "db.version()"

Verify connection string

echo $MONGODB_URL


### Broadcasting Not Working```bash
# Verify multicast is enabled
ip route show | grep 239.255.255.250

# Check firewall settings
sudo firewall-cmd --list-all

Port Already in Use```bash

Use different port

MCP_PORT=3003 uv run main.py
```

Performance Metrics

Typical response times:

  • Simple SELECT: 10-50ms
  • Database info queries: 5-20ms
  • MongoDB find operations: 20-100ms
  • Insert operations: 30-200ms (depending on triggers)

Network overhead (with broadcasting):

  • Broadcasting: 0.01% overhead
  • Discovery: One-time cost per server

Requirements

  • Python 3.10+
  • FastAPI
  • SQLAlchemy
  • PyMongo
  • FastMCP
  • python-dotenv

Contributing

Improvements welcome! Potential enhancements:

  • Additional database support (MySQL, SQLite)
  • Stored procedure execution
  • Transaction support
  • Advanced query builder
  • Connection pooling configuration
  • Database replication support

License

MIT License - See LICENSE file for details

Support

  • Issues: Report on GitHub
  • Documentation: See MCP Discovery Hub wiki
  • Examples: Check examples/ directory
  • Database docs: PostgreSQL and MongoDB official documentation

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
Db MCP Server 12c256e2 怎么安装?

在客户端按下面的安装命令接入:pip install -r requirements.txt。装完在客户端配置里引用同一个包或端点。

Db MCP Server 12c256e2 怎么在 Claude Desktop、Claude 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

Db MCP Server 12c256e2 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Db MCP Server 12c256e2 需要 API Key 吗?

资料标注为无需认证,装好就能连;如果实际调用时报鉴权错误,按官方文档补上凭据。

Db MCP Server 12c256e2 支持哪些客户端?

资料标注支持 Claude Desktop、Claude;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

Db MCP Server 12c256e2 能提供哪些能力?

资料显示约 7 个工具;能力标签包括 数据分析、PostgreSQL、Claude、MongoDB。具体工具清单以官方文档为准。

Db MCP Server 12c256e2 需要什么运行环境?

属于本地进程,需要在本机装好运行环境。

Db MCP Server 12c256e2 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-05-17。