NLP Database MCP Server
Provides read-only access to MySQL databases, allowing natural language queries via schema inspection and safe SQL execution.
Provides read-only access to PostgreSQL databases, allowing natural language queries via schema inspection and safe SQL execution.
Provides read-only access to SQLite databases, allowing natural language queries via schema inspection and safe SQL execution.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@NLP Database MCP ServerList the top 3 products by total sales revenue."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ποΈ NLP Database MCP Server
Connect your LLMs to SQL databases safely and intuitively using the Model Context Protocol (MCP). NLP Database acts as a secure, read-only bridge that allows AI agents to explore schemas and query data using natural language.
π Key Features
Read-Only Security: Strict regex validation ensures only
SELECTandWITHstatements are executed.Smart Guardrails: Automatic
LIMIT 500on all queries to prevent system bloat.Universal Compatibility: Native support for PostgreSQL, MySQL, SQL Server, and SQLite.
Agent-Optimized: Designed to provide descriptive errors that help LLMs self-correct.
Performance: 5-minute schema caching to reduce database overhead.
Usage Example
Once the server is connected to your LLM (Claude, Gemini, etc.), the agent gains access to two main tools: get_schema and execute_query.
Typical Workflow
Exploration: The user asks a question like: "How many users signed up last month?"
Schema Inspection: The LLM automatically calls
get_schemato understand your table names and columns.Query Execution: The LLM generates a SQL query and calls
execute_query.Natural Response: The LLM receives the data and translates it back to you in plain English or Spanish.
Example Interaction
User:
"List the top 3 products by total sales revenue."
LLM (Internal Thought Process):
Call
get_schemato find relevant tables (findsproductsandorders).Generate SQL:
SELECT p.name, SUM(o.amount) FROM products p JOIN orders o ON p.id = o.product_id GROUP BY p.name ORDER BY 2 DESC LIMIT 3.Call
execute_querywith the generated SQL.
LLM Response:
"The top 3 products by revenue are:
Enterprise Subscription ($50,200)
Professional License ($32,150)
Basic Plan ($12,400)"
Available Tools
Tool | Parameters | Description |
| (none) | Returns a list of all tables, their columns, and data types. |
|
| Executes a safe |
π οΈ 1. Installation & Drivers
Step 1: Clone the Repository
git clone https://github.com/your-repo/nlp-database.git
cd nlp-database
Step 2: Install Dependencies
You can install dependencies directly or use a virtual environment (recommended for isolation).
Option A: Using a Virtual Environment (Recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Option B: Direct Installation
pip install -r requirements.txt
Step 3: Install Database Drivers
Install only the driver required for your specific database:
PostgreSQL:
pip install psycopg2-binaryMySQL:
pip install pymysqlSQL Server:
pip install pyodbcSQLite: Already included in Python standard library.
π 2. Connection Strings (DATABASE_URL)
Database | Connection String Format |
PostgreSQL |
|
MySQL |
|
SQL Server |
|
SQLite |
|
βοΈ 3. Client Configuration
A. Claude Code (CLI)
claude mcp add nlp-database -- python C:/path/to/nlp_database.py --env DATABASE_URL="your_connection_string"
B. Gemini CLI
Add this to your ~/.gemini/settings.json:
{
"mcpServers": {
"nlp-database": {
"command": "python",
"args": ["C:/path/to/nlp_database.py"],
"env": {
"DATABASE_URL": "postgresql://user:pass@localhost/db"
}
}
}
}
C. Google Antigravity
Locate your mcp_config.json (usually in ~/.gemini/antigravity/):
{
"mcpServers": {
"nlp-database": {
"command": "python",
"args": ["C:/path/to/nlp_database.py"],
"env": {
"DATABASE_URL": "mssql+pyodbc://user:pass@server/db?driver=ODBC+Driver+17+for+SQL+Server"
}
}
}
}
D. OpenCode
Edit %USERPROFILE%\.opencode\opencode.jsonc:
{
"mcp": {
"nlp-database": {
"type": "local",
"command": "python",
"args": ["C:/path/to/nlp_database.py"],
"enabled": true,
"environment": {
"DATABASE_URL": "mysql+pymysql://user:pass@localhost/db"
}
}
}
}
E. Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"nlp-database": {
"command": "python",
"args": ["C:/path/to/nlp_database.py"],
"env": {
"DATABASE_URL": "sqlite:///C:/data/prod.db"
}
}
}
}
AquΓ tienes el apartado diseΓ±ado para resaltar la privacidad y la facilidad de uso con modelos locales. Puedes insertarlo justo antes de la secciΓ³n de Security.
Running with Local Models (100% Private)
For maximum privacy, you can pair NLP Database with a local LLM. This ensures that your database schema and query results never leave your machine.
Using Ollama + Claude Desktop / OpenCode
Install Ollama: Download it from ollama.com.
Pull a Model: Recommended models for SQL generation are
llama3.1,codellama, orqwen2.5-coder.
ollama run llama3.1
Configure your Client: Point your MCP client to your local Python script as shown in the Client Configuration section.
Select Local Model: In your client (like OpenCode or a local-ready editor), select your Ollama endpoint (usually
http://localhost:11434) as the provider.
Why go local?
Feature | Local Model | Cloud Model (OpenAI/Anthropic) |
Data Privacy | π Total. Data stays on your disk. | π Data sent to 3rd party servers. |
Cost | π° Free. Uses your own GPU/CPU. | π³ Pay-per-token. |
Internet | π Not required. Works offline. | π Required. |
Latency | β‘ Depends on your hardware. | βοΈ Depends on API response time. |
π Security: Dedicated Read-Only User
Always use a restricted database user. Here is how to create one:
PostgreSQL Example:
CREATE USER nlp_readonly WITH PASSWORD 'secure_password';
GRANT CONNECT ON DATABASE my_db TO nlp_readonly;
GRANT USAGE ON SCHEMA public TO nlp_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO nlp_readonly;
π Configuration Options
Environment Variable | Default | Description |
| Required | SQLAlchemy connection string. |
|
| Max rows returned to the LLM. |
|
| Max execution time in seconds. |
|
| Enable to log raw SQL queries to console. |
π€ Contributing
This is an open-source project and I'd love your help to make it better! Whether you are a Python expert, a Data Engineer, or just starting with MCP, your contributions are welcome.
How to help:
Report bugs or suggest features via Issues.
Improve documentation.
Add support for more database engines.
Submit Pull Requests with your improvements.
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
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/Lisito11/nlp-database-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server