trackmcp
Back to directory
NewToolAI

db-query-mcp

View on GitHub

db-query-mcp is an MCP tool that enables data querying and export operations across diverse databases.

13 stars PythonOthers Updated Sep 1, 2026

Documentation

image
Python Version
License
PyPI
GitHub pull request

English | [中文 ]

db-query-mcp

Introduction

db-query-mcp is a mcp tool supporting diverse database querying and exporting, featuring:

  • Multi-DB Support: Full compatibility with mainstream databases (ElasticSearch, MySQL, PostgreSQL, Oracle, SQLite, etc.)
  • Secure Access: Default read-only mode for data protection
  • Smart Query: Natural language to SQL conversion with query optimization
  • Data Export: CSV / Json export capabilities
  • Roadmap: Expanding support for MongoDB and GraphDatabase to become full-stack DB query MCP

Demo

https://github.com/user-attachments/assets/60771cda-8b52-41bd-90e3-523c836f6366

Changelog

  • 2025-06-02: Added support for ElasticSearch database queries

Installation

bash
pip install db-query-mcp

ElasticSearch:

bash
pip install "db-query-mcp[elasticsearch]"

Install from GitHub:

bash
pip install git+https://github.com/NewToolAI/db-query-mcp

MySQL requires additional dependencies:

bash
pip install pymysql

PostgreSQL requires additional dependencies:

bash
pip install psycopg2-binary

For other databases, install their respective connection packages:

DatabaseConnection PackageExample Connection String
SQLiteBuilt-in Python`sqlite:///example.db`
MySQL`pymysql` or `mysql-connector-python``mysql+pymysql://user:password@localhost/dbname`
PostgreSQL`psycopg2` or `psycopg2-binary``postgresql://user:password@localhost:5432/dbname`
Oracle`cx_Oracle``oracle+cx_oracle://user:password@hostname:1521/sidname`
SQL Server`pyodbc` or `pymssql``mssql+pyodbc://user:password@hostname/dbname`

Configuration

Note: ​For certain clients, such as Cursor, only one db-query-mcp server can run at a time.​​

Run using uvx

json
{
  "mcpServers": {
      "sqlite_db_mcp": {
        "command": "uvx",
        "args": [
          "db-query-mcp",
          "--db",
          "sqlite",
          "--uri", 
          "sqlite:///sqlite_company.db"
        ]
      }
  }
}
json
{
  "mcpServers": {
      "es_db_mcp": {
        "command": "uvx",
        "args": [
          "db-query-mcp",
          "--db",
          "elasticsearch",
          "--uri", 
          "https://user:password@localhost:9200?index=test_data_index&ca_certs=/home/user/http_ca.crt"
        ]
      }
  }
}

Run Using command

json
{
  "mcpServers": {
      "sqlite_db_mcp": {
        "command": "db-query-mcp",
        "args": [
          "--db",
          "sqlite",
          "--uri", 
          "sqlite:///sqlite_company.db"
        ]
      }
  }
}
json
{
  "mcpServers": {
      "es_db_mcp": {
        "command": "db-query-mcp",
        "args": [
          "--db",
          "elasticsearch",
          "--uri", 
          "https://user:password@localhost:9200?index=test_data_index&ca_certs=/home/user/http_ca.crt"
        ]
      }
  }
}

Frequently asked questions

What is db-query-mcp?

db-query-mcp is db-query-mcp is an MCP tool that enables data querying and export operations across diverse databases.

How do I install db-query-mcp?

Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.

Is db-query-mcp open source?

Yes — it is hosted on GitHub at https://github.com/NewToolAI/db-query-mcp and has 13 stars.

Related MCP tools

Run your own MCP server? See who uses it and what to fix.

Measure it with TrackMCP