Skip to main content
Glama
HumanSamadian

Data Nexus MCP

Data Nexus MCP

一个模块化、安全的平台,通过 REST API、MCP(模型上下文协议)和 Vue.js Web UI 连接 SQL 和 NoSQL 数据库。

架构

┌─────────────┐     ┌──────────────┐     ┌─────────────────┐
│   Web UI    │────▶│  REST API    │────▶│ core-db-command │
│  (Vue.js)   │     │  (FastAPI)   │     │  (Python lib)   │
└─────────────┘     └──────┬───────┘     └────────┬────────┘
                           │                       │
                    ┌──────▼───────┐               │
                    │  MCP Server  │───────────────┘
                    └──────┬───────┘
                           │
                    ┌──────▼───────┐
                    │  MCP Client  │──▶ AI Agents / LLMs
                    └──────────────┘

模块

模块

描述

core-db-command

core_db_command/

基于插件的 Python 库,支持所有数据库驱动

rest-api-command

rest_api_command/

FastAPI REST 层,支持 OAuth2/LDAP/基本认证

mcp-server

mcp_server/

MCP 工具:query_database, get_schema, list_tables, describe_table, execute_sql

mcp-client

mcp_client/

用于智能体集成的 MCP 客户端桥接

web-ui

web-ui/

Vue 3 + Pinia + Monaco Editor 查询工作室

config

config/

支持 ${ENV} 替换的 YAML 连接定义

Related MCP server: Database MCP Server

支持的数据库类型

驱动注册表支持 50 多种数据库类型,涵盖 13 个类别:

  • 关系型: PostgreSQL, MySQL, MSSQL, Oracle, CockroachDB, TiDB, YugabyteDB, TimescaleDB, pgvector

  • 文档型: MongoDB, DocumentDB, Firestore, Couchbase(存根)

  • 键值型: Redis, DynamoDB, Memcached/etcd/RocksDB(存根)

  • 宽列型: Cassandra, ScyllaDB, Bigtable/HBase(存根)

  • 图型: Neo4j, Neptune/JanusGraph/ArangoDB(存根)

  • 时间序列型: InfluxDB, ClickHouse, Prometheus/QuestDB(存根)

  • 向量型: Qdrant, Weaviate, Milvus, Pinecone

  • 搜索引擎型: Elasticsearch, OpenSearch, Splunk/Solr(存根)

  • 数据仓库型: BigQuery, Snowflake, Redshift/Databricks(存根)

  • 多模型型: Cosmos DB, OrientDB(存根)

  • 嵌入式型: SQLite, DuckDB, Realm/LMDB(存根)

  • 账本型: QLDB/BigchainDB(存根)

  • NewSQL型: Spanner(存根)

已完全实现的驱动包括 PostgreSQL, MySQL, MSSQL, Oracle, MongoDB, Redis, SQLite, DuckDB, Elasticsearch, ClickHouse, Neo4j, InfluxDB, Cassandra, DynamoDB, BigQuery, Snowflake, Qdrant, Weaviate, Milvus, Pinecone, Cosmos DB 和 Firestore。存根驱动已注册并可扩展。

快速开始

前提条件

  • Python 3.11+

  • Node.js 20+(用于 Web UI 开发)

  • Docker 和 Docker Compose(可选)

1. 安装 Python 依赖

cp .env.example .env
pip install -e ".[dev]"

2. 配置连接

编辑 config/connections.yaml 并通过环境变量设置密钥:

connections:
  - name: postgres_prod
    type: postgresql
    host: localhost
    port: 5432
    database: mydb
    user: readonly_user
    password: ${PG_PASSWORD}

3. 启动 REST API

db-rest-api
# or: uvicorn rest_api_command.app:app --reload

API 文档:http://localhost:8000/docs

4. 启动 Web UI(开发模式)

cd web-ui
cp .env.example .env
npm install
npm run dev

打开 http://localhost:5173 — 默认凭据:admin / changeme

5. 使用 Docker Compose 运行

docker compose up -d

服务:

REST API 端点

方法

路径

描述

GET

/api/connections

列出连接(不含凭据)

POST

/api/db/{name}/query

参数化查询

POST

/api/db/{name}/sql

原始 SQL / 原生命令

GET

/api/db/{name}/schema

数据库架构

GET

/api/db/{name}/tables

列出表/集合

GET

/api/db/{name}/tables/{table}/describe

表结构

GET/POST

/api/query-history

查询历史

MCP 服务器

.env 或 Cursor MCP env 中配置:

MCP_REST_API_URL=http://localhost:8000
# Option A: bearer token (when REST_API_AUTH_MODE=oauth2)
MCP_REST_API_TOKEN=<jwt-from-/api/auth/token>
# Option B: username/password (works with basic auth; auto-fetches JWT if oauth2)
MCP_REST_API_USER=admin
MCP_REST_API_PASSWORD=changeme

运行:

db-mcp-server

添加到 Cursor/Claude MCP 配置:

{
  "mcpServers": {
    "data-nexus-mcp": {
      "command": "db-mcp-server",
      "cwd": "/path/to/data_nexus_mcp",
      "env": {
        "MCP_REST_API_URL": "http://localhost:8000",
        "MCP_REST_API_USER": "admin",
        "MCP_REST_API_PASSWORD": "changeme"
      }
    }
  }
}

注意:REST_API_* 变量属于 REST API 进程(db-rest-api),而不是 MCP 服务器配置。

MCP 客户端

db-mcp-client                    # list available tools
db-mcp-client query local_sqlite "SELECT 1"

认证

设置 REST_API_AUTH_MODE 为以下之一:

  • basic — HTTP 基本认证(开发模式默认)

  • oauth2 — 通过 /api/auth/token 获取 JWT Bearer 令牌

  • ldap — LDAP 绑定(需要 REST_API_LDAP_SERVERREST_API_LDAP_BASE_DN

添加新驱动

  1. 创建 core_db_command/drivers/mydb.py

  2. 继承 BaseDriver 并设置 driver_type

  3. 使用 @DriverRegistry.register 装饰

  4. core_db_command/drivers/registry_loader.py 中导入

from core_db_command.base import BaseDriver, DriverRegistry

@DriverRegistry.register
class MyDBDriver(BaseDriver):
    driver_type = "mydb"

    async def connect(self): ...
    async def disconnect(self): ...
    async def query(self, query, params=None): ...
    async def execute(self, command, params=None): ...
    async def list_tables(self, schema=None): ...
    async def describe_table(self, table, schema=None): ...

测试

pytest tests/ -v

安全说明

  • REST API 或 MCP 服务器绝不返回凭据

  • 密钥必须使用 YAML 配置中的 ${ENV_VAR} 占位符

  • 所有 API 端点都需要认证

  • 查询输入会经过验证并限制长度

项目结构

data-nexus-mcp/
├── core_db_command/       # Core library + drivers
├── rest_api_command/      # FastAPI REST API
├── mcp_server/            # MCP server
├── mcp_client/            # MCP client
├── web-ui/                # Vue.js frontend
├── config/                # YAML connection config
├── tests/                 # Unit tests
├── docker-compose.yml
├── Dockerfile
└── pyproject.toml

许可证

MIT

Install Server
A
license - permissive license
B
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    -
    quality
    C
    maintenance
    Enables LLMs and agents to interact with relational databases (SQL Server, MySQL, PostgreSQL) through MCP tools. Supports executing queries, inserting records, listing tables, and exposing database schemas with secure credential management.
  • A
    license
    -
    quality
    D
    maintenance
    Provides universal database operations for AI assistants through MCP, supporting 40+ databases including PostgreSQL, MySQL, MongoDB, Redis, and SQLite with built-in introspection tools for schema exploration.
    29
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Give your AI agent safe, plain-English access to any database via MCP. Ask questions in natural language, get SQL queries and results, run read-only queries, and set up scheduled alerts.
    9
    60
    MIT

View all related MCP servers

Related MCP Connectors

  • Free public MCP for AI agents — 193 tools, 44 workflows. No API key.

  • Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.

  • Shared, governed long-term memory for AI agents across tools and sessions via MCP and REST.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HumanSamadian/data-nexus-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server