MCP Data Analyst
Allows querying and analyzing data in Elasticsearch using SQL API with natural language.
Allows querying and analyzing data in InfluxDB using InfluxQL with natural language.
Allows querying and analyzing data in MongoDB databases using natural language.
Allows querying and analyzing data in MySQL databases using natural language.
Provides the language model capability to convert natural language queries into SQL using the OpenAI API.
Allows querying and analyzing data in PostgreSQL databases using natural language.
Allows querying and analyzing data in SQLite databases using natural language.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MCP Data Analyst
A Model Context Protocol (MCP) server that enables natural language querying of SQL databases using AI. Connect your database and ask questions in plain English - the server will generate and execute SQL queries for you.
Features
🤖 Natural Language to SQL: Ask questions in plain English, get SQL results
🔌 Multiple Database Support: MySQL, PostgreSQL, MSSQL, MongoDB, SQLite, SSAS (MDX), Elasticsearch (SQL), InfluxDB (InfluxQL)
📊 Schema Auto-Discovery: Automatically scans and caches your database schema
🛠️ MCP Integration: Works seamlessly with MCP-compatible clients
⚡ Efficient: Connection pooling and schema caching for performance
🔒 Read-only by Design: Only SELECT-style queries are executed
Related MCP server: TalkDB
Query Languages
SQL: MySQL, PostgreSQL, MSSQL, SQLite, Elasticsearch (SQL API)
MDX: SSAS
InfluxQL: InfluxDB
Installation
Prerequisites
Python 3.12 or higher
One of: MySQL, PostgreSQL, MSSQL, MongoDB, SQLite, SSAS, Elasticsearch, or InfluxDB
OpenAI API key (or compatible API endpoint)
Setup
Clone the repository:
cd /path/to/your/workspaceCreate a virtual environment (recommended):
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtConfigure environment variables:
Copy the example below and create a
.envfile:# LLM Configuration LLM_API_KEY=your-api-key-here LLM_MODEL=gpt-3.5-turbo LLM_API_URL=https://api.openai.com/v1
Database Configuration
DB_TYPE=mysql # mysql|postgresql|mssql|mongodb|sqlite|ssas|elasticsearch|influxdb DB_HOST=127.0.0.1 DB_PORT=3306 # 5432 (PostgreSQL), 1433 (MSSQL), 27017 (MongoDB), 2383 (SSAS), 9200 (Elasticsearch), 8086 (InfluxDB) DB_USER=root DB_PASSWORD=your-password DB_NAME=your-database-name # For InfluxDB: database name; for SSAS/Elasticsearch: catalog/index database name
SQLite only
DB_PATH=database.db
## Usage
### Running the MCP Server
Start the server using the standard MCP stdio transport:
```bash
python server.pyThe server will:
Validate configuration
Connect to your database
Build a schema cache
Start listening for MCP requests
Available MCP Tools
The server exposes 3 tools that can be called by MCP clients:
1. query_database_with_prompt
Ask questions in natural language and get SQL results.
# Example: "Show me the top 5 customers by total purchases"
{
"success": true,
"query": "SELECT c.name, SUM(o.total) as total_purchases FROM customers c...",
"data": [...]
}2. get_database_schema
Retrieve the complete database schema.
{
"success": true,
"schema": {
"users": {
"name": "users",
"columns": {...}
}
}
}3. build_db_definition
Rebuild the schema cache from the database.
{
"success": true,
"message": "Successfully loaded schema for 8 tables",
"tables": ["users", "orders", "products", ...]
}Integration with MCP Clients
To use this server with an MCP client (like Claude Desktop), add it to your MCP configuration:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"data-analyst": {
"command": "python",
"args": ["/path/to/mcp-data-analyst/server.py"],
"env": {
"LLM_API_KEY": "your-key",
"DB_TYPE": "mysql",
"DB_HOST": "localhost",
"DB_NAME": "your_db"
}
}
}
}Development
Adding a New Database Type
Create a new file in
DataAnalyst/database/Type/(e.g.,SQLite.py)Extend the
BaseDatabaseabstract classImplement all required methods:
__init__,execute_query,build_definition,closeAdd the new type to
DbTypesenumUpdate
DataAnalyst/database/Type/__init__.pyto export your classUpdate
server.pyto handle the new database type
Examples
Example 1: Customer Analysis
Query: "Show me the top 10 customers by total order value"
Generated SQL:
SELECT c.customer_name, SUM(o.total_amount) as total_value
FROM customers c
JOIN orders o ON c.id = o.customer_id
GROUP BY c.id, c.customer_name
ORDER BY total_value DESC
LIMIT 10;Example 2: Product Inventory
Query: "Which products are low in stock (less than 10 units)?"
Generated SQL:
SELECT product_name, quantity_in_stock
FROM products
WHERE quantity_in_stock < 10
ORDER BY quantity_in_stock ASC;Contributing
Contributions are welcome! Please ensure:
Code follows PEP 8 style guidelines
All functions have type hints and docstrings
New database types extend
BaseDatabaseChanges maintain backward compatibility
Support
For issues, questions, or contributions, please open an issue on the repository.
Built with:
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Query, explore, and manage your databases through natural conversation.
Ask questions in plain language, get answers from your business database. No SQL required.
Ask business questions in plain English. Get instant answers from your database, no SQL needed.
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables 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.-
- AlicenseNot gradedqualityDmaintenanceEnables natural language querying of databases with multi-turn conversations, auto-generated charts, and proactive monitoring via scheduled queries and alerts.1MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to query databases using natural language, with automatic schema discovery and SQL compilation.833 npm3,235Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables natural language querying of any SQL database by converting plain English questions into SQL queries, with auto-schema detection and safety features.3MIT