loading…
Search for a command to run...
loading…
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
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.
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.
SELECT and WITH statements are executed.LIMIT 500 on all queries to prevent system bloat.Once the server is connected to your LLM (Claude, Gemini, etc.), the agent gains access to two main tools: get_schema and execute_query.
get_schema to understand your table names and columns.execute_query.User:
"List the top 3 products by total sales revenue."
LLM (Internal Thought Process):
get_schema to find relevant tables (finds products and orders).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.execute_query with the generated SQL.LLM Response:
"The top 3 products by revenue are:
- Enterprise Subscription ($50,200)
- Professional License ($32,150)
- Basic Plan ($12,400)"
| Tool | Parameters | Description |
|---|---|---|
get_schema |
(none) | Returns a list of all tables, their columns, and data types. |
execute_query |
sql_query |
Executes a safe SELECT statement and returns the results as JSON. |
git clone https://github.com/your-repo/nlp-database.git
cd nlp-database
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
Install only the driver required for your specific database:
pip install psycopg2-binarypip install pymysqlpip install pyodbcDATABASE_URL)| Database | Connection String Format |
|---|---|
| PostgreSQL | postgresql://user:pass@localhost:5432/dbname |
| MySQL | mysql+pymysql://user:pass@localhost:3306/dbname |
| SQL Server | mssql+pyodbc://user:pass@server/db?driver=ODBC+Driver+17+for+SQL+Server |
| SQLite | sqlite:///C:/absolute/path/to/database.db |
claude mcp add nlp-database -- python C:/path/to/nlp_database.py --env DATABASE_URL="your_connection_string"
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"
}
}
}
}
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"
}
}
}
}
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"
}
}
}
}
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.
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.
llama3.1, codellama, or qwen2.5-coder.ollama run llama3.1
http://localhost:11434) as the provider.| 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. |
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;
| Environment Variable | Default | Description |
|---|---|---|
DATABASE_URL |
Required | SQLAlchemy connection string. |
MAX_RESULT_ROWS |
500 |
Max rows returned to the LLM. |
QUERY_TIMEOUT |
30 |
Max execution time in seconds. |
DB_ECHO_SQL |
false |
Enable to log raw SQL queries to console. |
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:
Run in your terminal:
claude mcp add nlp-database-mcp-server -- npx Security
Low riskAutomated heuristic from public metadata — not a security guarantee.