- Explore MCP Servers
- PROMPTQL
Promptql
What is Promptql
PROMPTQL is a FastAPI service that acts as a natural language query gateway, converting natural language queries into SQL and NoSQL queries using LangChain and Claude.
Use cases
Use cases for PROMPTQL include enabling non-technical users to query databases using natural language, integrating with applications that require dynamic query generation, and simplifying data retrieval processes in business applications.
How to use
To use PROMPTQL, clone the repository, set up a virtual environment, install the required dependencies, configure your database settings in the .env file, and run the application using Uvicorn. Access the API documentation at http://localhost:8000/docs.
Key features
Key features of PROMPTQL include support for multiple databases (PostgreSQL, MongoDB, MySQL, SQLite), natural language to SQL/NoSQL query conversion, automatic schema introspection, query validation, health check endpoints, comprehensive test suite, API documentation with Swagger UI, monitoring and metrics, rate limiting, and enhanced error handling.
Where to use
PROMPTQL can be used in various fields such as data analysis, business intelligence, and application development where natural language processing and database interaction are required.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Promptql
PROMPTQL is a FastAPI service that acts as a natural language query gateway, converting natural language queries into SQL and NoSQL queries using LangChain and Claude.
Use cases
Use cases for PROMPTQL include enabling non-technical users to query databases using natural language, integrating with applications that require dynamic query generation, and simplifying data retrieval processes in business applications.
How to use
To use PROMPTQL, clone the repository, set up a virtual environment, install the required dependencies, configure your database settings in the .env file, and run the application using Uvicorn. Access the API documentation at http://localhost:8000/docs.
Key features
Key features of PROMPTQL include support for multiple databases (PostgreSQL, MongoDB, MySQL, SQLite), natural language to SQL/NoSQL query conversion, automatic schema introspection, query validation, health check endpoints, comprehensive test suite, API documentation with Swagger UI, monitoring and metrics, rate limiting, and enhanced error handling.
Where to use
PROMPTQL can be used in various fields such as data analysis, business intelligence, and application development where natural language processing and database interaction are required.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Natural Language Query Gateway
A FastAPI service that converts natural language queries to SQL/NoSQL queries using LangChain and Claude.
Features
- Support for multiple databases:
- PostgreSQL
- MongoDB
- MySQL
- SQLite
- Natural language to SQL/NoSQL query conversion
- Automatic schema introspection
- Query validation and error handling
- Health check endpoints
- Comprehensive test suite
- API documentation with Swagger UI
- New: Monitoring and metrics
- New: Rate limiting and security features
- New: Enhanced error handling and logging
Prerequisites
- Python 3.10+
- One or more of the following databases:
- PostgreSQL
- MongoDB
- MySQL
- SQLite
- Anthropic API key
Installation
- Clone the repository:
git clone <repository-url>
cd PROMPTQL
- Create and activate a virtual environment:
# Windows
python -m venv .env
.env\Scripts\activate
# Linux/macOS
python -m venv .env
source .env/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Create
.envfile:
cp .env.example .env
- Configure your environment variables in
.env:
# Database Type (required) DB_TYPE=postgres # Options: postgres, mongodb, mysql, sqlite # Database Settings DB_HOST=localhost DB_PORT=5432 # Default ports: PostgreSQL=5432, MongoDB=27017, MySQL=3306 DB_USER=your_username DB_PASSWORD=your_password DB_NAME=your_database # SQLite Specific DB_PATH=./data/database.db # Only for SQLite # API Settings ANTHROPIC_API_KEY=your_api_key # Security Settings API_KEY=your_api_key RATE_LIMIT_REQUESTS=100 RATE_LIMIT_WINDOW=60 ALLOWED_ORIGINS=["http://localhost:3000"] ENABLE_DOCS=true
Running the Application
- Start the server:
uvicorn app.main:app --reload
- Access the API documentation:
http://localhost:8000/docs
API Endpoints
Health Check
GET /health
Metrics
GET /metrics
Schema Information
GET /schema/{source}
Query Execution
POST /query
Content-Type: application/json
X-API-Key: your_api_key
{
"query": "Show me all users who signed up this month",
"source": "sql"
}
Supported Databases
GET /supported-databases
Security Features
- API key authentication
- Rate limiting
- CORS protection
- Security headers
- Input validation
- Error handling
Monitoring
The application provides the following monitoring capabilities:
- Request logging
- Query execution metrics
- Database connection status
- LLM request tracking
- Performance metrics
Testing
- Run all tests:
pytest
- Run specific test file:
pytest tests/test_api.py
- Run with coverage:
pytest --cov=app tests/
Example Queries
SQL (PostgreSQL/MySQL/SQLite)
{
"query": "Find all users older than 25",
"source": "sql"
}
MongoDB
{
"query": {
"collection": "users",
"age": {
"$gt": 25
},
"interests": "coding"
},
"source": "mongodb"
}
Development
Project Structure
PROMPTQL/ ├── app/ │ ├── __init__.py │ ├── main.py │ ├── config/ │ │ ├── __init__.py │ │ └── settings.py │ ├── core/ │ │ ├── __init__.py │ │ ├── errors.py │ │ ├── llm.py │ │ ├── monitoring.py │ │ ├── security.py │ │ └── validation.py │ ├── databases/ │ │ ├── __init__.py │ │ ├── base.py │ │ ├── postgres.py │ │ ├── mongodb.py │ │ ├── mysql.py │ │ └── sqlite.py │ └── models/ │ ├── __init__.py │ └── schemas.py ├── tests/ │ ├── __init__.py │ ├── conftest.py │ └── test_api.py ├── .env.example ├── requirements.txt └── README.md
Adding a New Database
- Create a new adapter in
app/databases/ - Implement the
BaseDBinterface - Add database-specific settings to
app/config/settings.py - Update the database instances in
app/main.py - Add test cases in
tests/
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
MIT
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










