Skip to main content
Glama
DB MCP Server

DB MCP Server

by Pawangunjkar

DB MCP Server

Open-source MCP server owned by Pawan Gunjkar (pawangunjkar@gmail.com · GitHub). MIT licensed.

Developers ask the editor to inspect and change data without opening a SQL client, Mongo shell, redis-cli, or Kibana. The server speaks MCP over stdio, keeps named sessions, and routes each session to the right engine.

Sibling servers: github-mcp, jenkins-mcp, linux-ssh-mcp, observability-mcp, k8s-mcp.

Project information

Item

Value

Package

db-mcp

Runtime

Python 3.10+, FastMCP, stdio

SQL

PostgreSQL, MySQL, MariaDB, SQLite, Oracle, SQL Server

NoSQL

MongoDB, Redis, Elasticsearch

Safety

WHERE required on update/delete. DROP / TRUNCATE / ALTER and deletes need confirm=true. DB_ALLOW_WRITE=false makes the session read-only

Related MCP server: Polyglot DB MCP

Architecture

flowchart TB
  subgraph L1["Layer 1 — Editor"]
    IDE["Cursor or Claude Desktop"]
  end

  subgraph L2["Layer 2 — MCP"]
    SRV["db-mcp FastMCP server"]
    HUB["DbHub named sessions"]
  end

  subgraph L3["Layer 3 — Drivers"]
    SA["SQLAlchemy"]
    MG["PyMongo"]
    RD["redis-py"]
    ES["HTTP client"]
  end

  subgraph L4["Layer 4 — Databases"]
    PG["PostgreSQL / MySQL / SQLite"]
    OR["Oracle / SQL Server"]
    MO["MongoDB"]
    RE["Redis"]
    EL["Elasticsearch"]
  end

  IDE -->|"db_query / db_insert / mongo_find"| SRV
  SRV --> HUB
  HUB --> SA
  HUB --> MG
  HUB --> RD
  HUB --> ES
  SA --> PG
  SA --> OR
  MG --> MO
  RD --> RE
  ES --> EL

A chat message becomes one tool call. The hub picks the session, the driver binds parameters, and the database returns rows or a write count. The editor never opens a second window.

flowchart LR
  Q["db_connect"] --> S["Session"]
  S --> R["db_query / db_describe_table"]
  S --> W["db_insert / db_update"]
  W --> C{"confirm or WHERE?"}
  C -->|yes| DB[("Database")]
  C -->|no| STOP["Refused"]
  R --> DB

Engines

Kind

Engine

URL example

SQL

postgresql

postgresql+psycopg://user:pass@localhost:5432/ecs_oms

SQL

mysql / mariadb

mysql+pymysql://user:pass@localhost:3306/app

SQL

oracle

oracle+oracledb://user:pass@localhost:1521/?service_name=ORCLPDB

SQL

sqlserver

mssql+pymssql://user:pass@localhost:1433/app

SQL

sqlite

sqlite:///C:/data/app.db

NoSQL

mongodb

mongodb://localhost:27017

NoSQL

redis

redis://localhost:6379/0

NoSQL

elasticsearch

http://localhost:9200

Oracle uses the python-oracledb thin mode, so the Instant Client is not required. CockroachDB and Amazon Aurora PostgreSQL use the postgresql engine.

Read tools

db_query, db_list_tables, db_describe_table, mongo_find, mongo_list_databases, mongo_list_collections, redis_get, redis_keys, es_search

Write tools

db_insert, db_update, db_delete, db_execute, mongo_insert, mongo_update, mongo_delete, redis_set, redis_delete, es_index_document, es_delete_document

UPDATE and DELETE require a WHERE clause. DROP, TRUNCATE, ALTER, Mongo deletes, and Elasticsearch deletes require confirm=true. Set DB_ALLOW_WRITE=false to make a session read-only.

Cursor

{
  "mcpServers": {
    "db": {
      "command": "uv",
      "args": ["run", "--directory", "C:/AI_Workspaces/Anti_Workspace/db-mcp", "server.py"],
      "env": {
        "DB_ENGINE": "postgresql",
        "DB_URL": "postgresql+psycopg://ecs:ecs_secret@localhost:5432/ecs_oms",
        "DB_ALLOW_WRITE": "true"
      }
    }
  }
}

Available Tools

23 tools
db_connectC

Connect a named session. engine is postgresql, mysql, mariadb, sqlite, oracle, sqlserver, mongodb, redis, or elasticsearch.

Inputs: url (required), engine (required), allow_write, session_name. Returns: result

db_deleteB

Delete rows matching where_sql. confirm=true is required.

Inputs: table (required), where_sql (required), schema, confirm, +2 more. Returns: result

db_describe_tableB

Describe columns of a SQL table.

Inputs: table (required), schema, session_name. Returns: result

db_disconnectC

Disconnect a database session.

Inputs: session_name. Returns: result

db_executeB

Run a write statement. DROP, TRUNCATE, and ALTER require confirm=true.

Inputs: sql (required), confirm, params_json, session_name. Returns: result

db_insertC

Insert one row. values_json is a JSON object of column to value.

Inputs: table (required), values_json (required), schema, session_name. Returns: result

db_list_tablesA

List tables in a SQL schema. Oracle schema is the owner. Postgres schema is usually public.

Inputs: schema, session_name. Returns: result

db_queryA

Run a read statement. Use :name binds in params_json. Results are capped by limit (max 500).

Inputs: sql (required), limit, params_json, session_name. Returns: result

db_statusA

List active database sessions and supported engines.

Inputs: no named parameters. Returns: result

db_updateC

Update rows. where_sql is required, for example id = :id.

Inputs: table (required), where_sql (required), values_json (required), schema, +2 more. Returns: result

es_delete_documentA

Delete one Elasticsearch document. confirm=true is required.

Inputs: index (required), doc_id (required), confirm, session_name. Returns: result

es_index_documentB

Index one Elasticsearch document. Omit doc_id to let Elasticsearch assign one.

Inputs: index (required), document_json (required), doc_id, session_name. Returns: result

mongo_deleteB

Delete MongoDB documents matching a non-empty filter. confirm=true is required.

Inputs: database (required), collection (required), filter_json (required), confirm, +1 more. Returns: result

mongo_findD

Find MongoDB documents.

Inputs: database (required), collection (required), limit, filter_json, +1 more. Returns: result

mongo_insertC

Insert one MongoDB document.

Inputs: database (required), collection (required), document_json (required), session_name. Returns: result

mongo_list_collectionsC

List collections in a MongoDB database.

Inputs: database (required), session_name. Returns: result

mongo_list_databasesB

List MongoDB database names.

Inputs: session_name. Returns: result

mongo_updateC

Update MongoDB documents. update_json should include operators such as $set. Empty filters are refused.

Inputs: database (required), collection (required), filter_json (required), update_json (required), +1 more. Returns: result

redis_deleteC

DEL a Redis key.

Inputs: key (required), session_name. Returns: result

redis_getC

GET a Redis key.

Inputs: key (required), session_name. Returns: result

redis_keysC

List Redis keys matching a pattern, capped at 200.

Inputs: pattern, session_name. Returns: result

redis_setC

SET a Redis key.

Inputs: key (required), value (required), session_name. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 23 tools

    Disambiguation5/5

    Every tool is namespaced by engine (db_, mongo_, redis_, es_) and action, making read, write, and administrative operations easy to separate. Even db_execute vs db_insert/update/delete is clear because execute is for arbitrary SQL statements while the specialized tools target row-level operations.

    Naming Consistency4/5

    Tool names follow a mostly consistent <engine>_<operation> pattern, with clear prefixes like db_, mongo_, redis_, and es_. Minor inconsistency exists between verb-only names like db_query, db_execute, and mongo_find versus verb-noun names like db_list_tables and mongo_list_databases.

    Tool Count4/5

    23 tools is slightly above the typical sweet spot, but the server covers four different database engines, so the breadth is justified. Each tool represents a distinct operation and none feel redundant or purely decorative.

    Completeness4/5

    SQL, MongoDB, and Redis have solid CRUD and inspection coverage, and Elasticsearch covers search, indexing, and deletion. Minor gaps exist, such as no ES update/get-by-id, no explicit transaction control, and no SQL database listing, but agents can often work around these with db_execute or search queries.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI to query and manage PostgreSQL and MongoDB databases through natural language. Supports automatic schema discovery, safe data operations, and network-wide database access with zero-configuration deployment.
      -
    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables interaction with 20+ databases (PostgreSQL, MongoDB, Neo4j, Elasticsearch, Redis, and more) through a single unified interface, allowing cross-database queries and operations via natural language.
      1
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to connect to and interact with PostgreSQL, MySQL, SQLite, and MongoDB databases through natural language, supporting schema exploration, query execution, data export, and more.
      13
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables executing SQL queries, schema introspection, and data management for PostgreSQL and MySQL databases via natural language, supporting local, SSH, and AWS RDS connections.
      8
      69 npm
      MIT