DB Query
Query and export data from various databases including ElasticSearch, MySQL, PostgreSQL, Oracle, and SQLite.
[ 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
pip install db-query-mcp
ElasticSearch:
pip install "db-query-mcp[elasticsearch]"
Install from GitHub:
pip install git+https://github.com/NewToolAI/db-query-mcp
MySQL requires additional dependencies:
pip install pymysql
PostgreSQL requires additional dependencies:
pip install psycopg2-binary
For other databases, install their respective connection packages:
Database | Connection Package | Example Connection String |
---|---|---|
SQLite | Built-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
{
"mcpServers": {
"sqlite_db_mcp": {
"command": "uvx",
"args": [
"db-query-mcp",
"--db",
"sqlite",
"--uri",
"sqlite:///sqlite_company.db"
]
}
}
}
{
"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
{
"mcpServers": {
"sqlite_db_mcp": {
"command": "db-query-mcp",
"args": [
"--db",
"sqlite",
"--uri",
"sqlite:///sqlite_company.db"
]
}
}
}
{
"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"
]
}
}
}
Related Servers
MCP Snowflake Reader
Read-only access to Snowflake databases. Requires Snowflake connection information provided via MCP client configuration.
libSQL by xexr
MCP server for libSQL databases with comprehensive security and management tools. Supports file, local HTTP, and remote Turso databases with connection pooling, transaction support, and 6 specialized database tools.
Nimiq MCP Server
An MCP server for read-only interaction with the Nimiq blockchain.
RentCast
Access property data, valuations, and market statistics using the RentCast API.
Supabase MCP Server
An MCP server providing administrative control over a Supabase PostgreSQL database, compatible with Cursor's Composer and Codeium's Cascade.
MySQL Server Pro
A MySQL server with CRUD operations, database anomaly analysis, and support for SSE and STDIO.
Neo4j
A server for accessing and interacting with a Neo4j graph database, configured via environment variables.
Drug Gene Interaction Database (DGIdb)
A bridge to the Drug Gene Interaction Database (DGIdb) API, enabling AI clients to query drug-gene interaction data.
Unofficial ChEMBL MCP Server
Access the ChEMBL chemical database for drug discovery, chemical informatics, and bioactivity research using specialized tools via its REST API.
Atlan
Official MCP Server from Atlan which enables you to bring the power of metadata to your AI tools