# QueryPilot [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/nickklos10/QueryPilot  
**GitHub Stars:** 3  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/querypilot

## Description
Safe SQL gateway for AI agents: SELECT-only validation, access policies, masking, audit trail, evals

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "querypilot": {
    "command": "uvx",
    "args": ["--from","querypilot[mcp]","querypilot"],
    "env": {
      "QUERYPILOT_DATABASE_URL": "",
      "OPENAI_API_KEY": "",
      "ANTHROPIC_API_KEY": "",
      "QUERYPILOT_PROXY_PASS": ""
    }
  }
}
```

**Requires environment variables:** `QUERYPILOT_DATABASE_URL`, `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `QUERYPILOT_PROXY_PASS` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What QueryPilot MCP server does

The QueryPilot MCP server places a controlled SQL layer between an AI agent and a database. It supports SQLAlchemy database URLs and engines, including SQLite, PostgreSQL, DuckDB, MySQL/MariaDB, SQL Server, Snowflake, BigQuery, Redshift, Trino, Oracle, and Databricks when the corresponding driver extra is installed.

The server exposes schema discovery, SQL validation, query execution, and optional natural-language database questions. Queries are restricted to one statement and SELECT operations. Validation checks tables and columns against the connected schema, identifies some engine-specific dangerous functions, and can return suggestions for misspelled identifiers. Execution adds database-specific read-only protections, transaction rollback, row limits, and statement timeouts where supported.

Policies can control which tables and views are visible, filter rows, cap result sizes, and mask returned values. The Postgres proxy also records JSONL audit entries containing the client SQL, executed SQL, row count, user, and application. An evaluation harness is included for checking whether generated SQL is correct and remains correct over time.

## How it works

On connection, QueryPilot infers the SQL dialect from the URL and inspects tables, views, keys, comments, and related schema information. Agents can first search or inspect that metadata, then validate generated SQL before execution. Validation errors are returned as structured results rather than exceptions, with hints that help an agent revise its query.

The MCP tool set includes `list_tables`, `describe_table`, `search_schema`, `validate_sql`, `run_sql`, and `ask_database`. The last tool requires a configured model generator. Results use compact JSON and include a truncation indicator when `max_rows` limits the response.

The QueryPilot MCP server can run through stdio or streamable HTTP. The same toolkit can also be exposed to OpenAI and Anthropic tool-calling APIs, LangChain, LlamaIndex, OpenAI Agents, the Claude Agent SDK, and integrations that consume typed functions. For PostgreSQL, the prototype proxy applies validation and policy enforcement to clients such as psql, database drivers, BI tools, and other database-facing MCP servers.

## Setup and configuration

Install the package from PyPI with `pip install querypilot`. Running `querypilot demo` creates a small SQLite database and demonstrates a permitted query alongside a blocked write. For a real database, `querypilot init --db <DATABASE_URL>` creates `querypilot.yaml` with the connection, business hints, column descriptions, and access policy. Commands, the MCP server, and `QueryPilot.from_config()` can read this configuration.

Use `querypilot mcp-config` for supported client configuration output, including Claude Code and Cursor. The generated setup uses an absolute `uvx` path; `--runner python` can launch the current environment instead. Streamable HTTP is available with `querypilot mcp --transport streamable-http --port 8000`.

Database drivers are included for SQLite and PostgreSQL. Other engines require their documented extras, such as `querypilot[duckdb]`, `querypilot[mysql]`, or the relevant warehouse or driver extra. Natural-language `ask` generation can use OpenAI or Anthropic when the corresponding API key is present, an OpenAI-compatible endpoint for Ollama, vLLM, or LM Studio, or an offline demo generator when no key is configured.

## Tools and capabilities

- Discover permitted tables, views, comments, columns, types, keys, and sample values.
- Search schema metadata for tables and columns related to a question.
- Validate and rewrite SQL with dialect-aware checks and correction hints.
- Execute validated SELECT statements with compact rows and truncation status.
- Convert natural-language questions into validated SQL when a generator is configured.
- Apply row filters, masking rules, maximum row limits, read-only transactions, and audit logging where the selected mode supports them.

## Limitations and notes

QueryPilot is read-only by design for agent SQL operations; writes, DDL, and other rejected statements cannot be used through the normal validated path. Some database protections depend on engine support, so a read-only database role is recommended for warehouses without a read-only session mode. The Postgres proxy is identified as a prototype. Additional database backends may require installing their specific package extras and drivers.

_Full upstream README: https://allmcps.com/mcp/querypilot/readme_

