Skip to main content
Glama

Database Query MCP

by NewToolAI

image

Python Version License

[ 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:

DatabaseConnection PackageExample Connection String
SQLiteBuilt-in Pythonsqlite:///example.db
MySQLpymysql or mysql-connector-pythonmysql+pymysql://user:password@localhost/dbname
PostgreSQLpsycopg2 or psycopg2-binarypostgresql://user:password@localhost:5432/dbname
Oraclecx_Oracleoracle+cx_oracle://user:password@hostname:1521/sidname
SQL Serverpyodbc or pymssqlmssql+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" ] } } }
-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

A versatile tool that enables querying and exporting data from multiple relational databases (MySQL, PostgreSQL, Oracle, SQLite, etc.) in read-only mode for data safety.

  1. Introduction
    1. Demo
      1. Changelog
        1. Installation
          1. Configuration
            1. Run using uvx
            2. Run Using command

          Related MCP Servers

          • -
            security
            F
            license
            -
            quality
            A tool that provides simple API to execute SQL queries and manage MySQL databases, designed to integrate with Cursor IDE for AI assistants to directly perform database operations.
            Last updated -
            Python
            • Linux
            • Apple
          • A
            security
            A
            license
            A
            quality
            A server that connects to PostgreSQL databases and provides tools for safely exploring schemas, running read-only SQL queries, and performing data analysis with pre-built templates.
            Last updated -
            5
            693
            1
            JavaScript
            MIT License
          • A
            security
            A
            license
            A
            quality
            Provides secure, read-only access to MariaDB/MySQL databases, allowing users to list databases, explore table schemas, and execute SQL queries with built-in security measures.
            Last updated -
            4
            114
            3
            JavaScript
            MIT License
          • -
            security
            F
            license
            -
            quality
            Provides Claude Desktop with secure access to multiple database connections, allowing users to query MySQL, PostgreSQL, SQLite, and SQL Server databases directly through natural language.
            Last updated -
            • Apple

          View all related MCP servers

          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/NewToolAI/db-query-mcp'

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