mcp-sql-readonly
Provides read-only tools for exploring and querying PostgreSQL databases: list tables and views, describe columns, run a single SELECT with row caps and timeouts, and retrieve a schema overview.
Provides read-only tools for exploring and querying SQLite databases: list tables and views, describe columns, run a single SELECT with row caps and timeouts, and retrieve a schema overview.
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-sql-readonly
A safe, read-only Model Context Protocol server that lets Claude Desktop, Claude Code, Cursor or any MCP client explore and query your SQL database (SQLite or Postgres) without ever being able to change it.
"Which product category made the most revenue last quarter?" → Claude calls
list_tables,describe_table, writes the SQL, runs it and answers.
Why it's safe
Two independent layers, so one mistake can't cost you data:
SQL guard: every query is parsed with sqlglot. Only a single
SELECTgets through (CTEs andUNIONincluded). It rejectsINSERT,UPDATE,DELETE, DDL,PRAGMA,ATTACH,SELECT ... INTO, data-modifying CTEs and stacked statements, with a message the model can learn from.Read-only connection: SQLite opens with
mode=ro. Postgres sessions run withdefault_transaction_read_only = on. Even if the guard is bypassed, nothing can be written.
There's also a row cap (default 100 per call, max 1000) that reports truncated: true, and a 5-second per-query timeout.
Related MCP server: tabletalk
Tools
Name | Kind | What it does |
| tool | Tables and views you can query |
| tool | Columns: name, type, nullable, primary key |
| tool | One read-only SELECT → columns, rows, row_count, truncated, elapsed_ms |
| resource | Whole schema as markdown |
All tools are marked readOnlyHint: true, so clients can auto-approve them.
Quick start
git clone https://github.com/sharmaujwal177-stack/mcp-sql-readonly && cd mcp-sql-readonly
uv venv && uv pip install -e ".[dev]" # add ,postgres for Postgres
uv run python examples/seed_demo.py # demo shop database
uv run pytest -q # 24 testsClaude Desktop: Settings → Developer → Edit Config:
{
"mcpServers": {
"shop-db": {
"command": "/ABSOLUTE/PATH/mcp-sql-readonly/.venv/bin/mcp-sql-readonly",
"env": { "DATABASE_URL": "sqlite:////ABSOLUTE/PATH/mcp-sql-readonly/examples/demo.sqlite" }
}
}
}Claude Code:
claude mcp add shop-db --env DATABASE_URL=sqlite:///$PWD/examples/demo.sqlite -- $PWD/.venv/bin/mcp-sql-readonlyPostgres: connect as a role with only SELECT grants:
DATABASE_URL=postgresql://readonly_user:pass@host:5432/app mcp-sql-readonlyEnv var | Default | Meaning |
| required |
|
|
| Hard cap on rows per query |
|
| Per-query timeout |
|
|
|
Want more servers?
This server is part of the MCP Starter Kit by ash-tool. The kit adds:
GitHub server: search repos and issues, read PRs and files; writes only when you switch them on
Any-REST-API server: describe endpoints in a short TOML file and each becomes a typed tool, with auth from env vars
A full setup guide for Claude Desktop, Claude Code and Cursor, plus 43 tests
The server in this repo is free and MIT licensed forever. Issues and PRs welcome.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables read-only, SELECT-only querying of any Postgres database through MCP-compatible clients like Claude, with schema introspection and guarded SQL execution.MIT
- AlicenseAqualityDmaintenanceEnables querying SQLite databases in plain language through MCP, letting clients like Claude Code inspect schemas and run read-only SQL.31MIT
- AlicenseNot gradedqualityBmaintenanceEnables Claude and other MCP clients to map a SQLite database's schema and run read-only SQL queries against it, with writes blocked at the SQLite level through multiple enforcement layers. Results come back as context-friendly Markdown tables with row caps and a query timeout.2MIT
- AlicenseAqualityBmaintenanceEnables Claude or any MCP host to explore and query a SQLite database through read-only tools for listing tables, describing schemas, and running SQL queries.3MIT