Database Explorer MCP Server
Provides read-only exploration of PostgreSQL databases, including table and schema inspection, row sampling, SELECT query execution, foreign-key relationship discovery, column statistics, schema search, and query validation with configurable safety and resource limits.
Provides read-only exploration of SQLite databases, including table listing, schema inspection, row sampling, SELECT query execution, relationship discovery, column statistics, schema search, and query validation.
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.
Database Explorer MCP Server
A read-only database explorer MCP (Model Context Protocol) server supporting SQLite and PostgreSQL backends. Built for use with Opencode and any MCP-compatible client.
https://github.com/user-attachments/assets/b4ca24ec-37d1-4d46-88c8-7f0c9919486b
Features
Read-only by design: Database connections are opened read-only; writes are impossible at the driver level.
SQL safety layer: SQL is parsed to reject non-SELECT statements, multiple statements, and dangerous constructs (PRAGMA, ATTACH, COPY, etc.).
Row and response limits: Configurable max rows, response size cap, and concurrent query cap.
Column masking: Sensitive columns (customer IDs, geolocation, review comments) are hashed/redacted per a configurable sensitivity policy.
Table access control: Allowlist/blocklist with per-table descriptions.
Tools (9):
list_tables,describe_table,sample_rows,run_query,get_relationships,explain_query,column_stats,search_schema,validate_query.Resources:
schema://overview,schema://table/{name}.Prompts:
explore,answer.Transports: Streamable HTTP (
/mcp) and stdio.
Related MCP server: readonly-postgres-mcp
Quick Start
1. Clone and configure
git clone https://github.com/your-username/Database-Explorer-MCP-Server.git
cd Database-Explorer-MCP-Server/mcp-server
cp .env.example .env
# Edit .env with your Kaggle credentials (KAGGLE_USERNAME, KAGGLE_KEY)
# and confirm MCP_DATABASE_URL.2. Start everything with Docker Compose
docker-compose up -d --buildThis single command:
Starts a Postgres 15 container and loads the Olist schema.
Downloads the Olist Brazilian E-Commerce CSV dataset via the Kaggle API (using
KAGGLE_USERNAME/KAGGLE_KEYfrom.env).Loads the CSVs into Postgres in foreign-key-safe order.
Starts the MCP server on
http://localhost:8765/mcp.
Check that everything is healthy:
docker-compose ps3. Connect to Opencode
Add to ~/.config/opencode/opencode.json:
{
"mcp": {
"db-explorer": {
"type": "remote",
"url": "http://localhost:8765/mcp",
"enabled": true
}
}
}Restart Opencode to pick up the change.
Running locally without Docker
For development, you can run the MCP server directly against a local Postgres or the sample SQLite DB:
# Using the sample SQLite DB (no setup required)
uvicorn mcp_server.server:build_app --factory --host 127.0.0.1 --port 8765
# Or stdio transport (for MCP Inspector)
python -m mcp_serverThe server listens at http://localhost:8765/mcp (HTTP) or stdio.
Tools
Tool | Description |
| List tables/views with row counts |
| Full table structure: columns, types, PK, indexes, comments |
| Up to 10 sample rows from a table (sensitive columns masked) |
| Execute a single SELECT query (capped rows, timeout enforced) |
| Foreign keys (outgoing + incoming) for join planning |
| Query plan without execution |
| Distinct count, nulls, min/max, top values for a column |
| Keyword search across table and column names |
| Check if a SQL query would pass safety rules without running it |
Resources
schema://overview— Full schema overview with all tables and columnsschema://table/{name}— Detailed info for a specific table including FKs
Prompts
explore— Guided process for exploring a read-only databaseanswer— Process for answering data questions with SQL
Configuration
All settings use the MCP_ environment variable prefix (via .env):
Variable | Default | Description |
|
| SQLite read-only URI or Postgres connection string |
| 1000 | Max rows returned by |
| 100 | Default row cap |
| 30000 | Query timeout in milliseconds |
| 1000000 | Max response payload size |
| 5 | Cap on concurrent queries |
|
| JSON array of allowed schema-qualified table names |
|
| JSON array of blocked table names |
|
| Default Postgres schema |
| 2 | Min Postgres pool connections |
| 10 | Max Postgres pool connections |
| 10 | Default/sample row limit |
| — | Kaggle API username (for |
| — | Kaggle API key (for |
Safety Guarantees
Connection-level read-only: SQLite opens with
mode=ro; Postgres issuesSET TRANSACTION READ ONLYon every transaction.SQL parsing: Only single
SELECT/WITHstatements allowed;INSERT,UPDATE,DELETE,DDL,PRAGMA,COPY,pg_sleep, etc. are rejected.Resource limits: Row caps, response size caps, and concurrent query caps prevent runaway queries.
Column masking: Sensitive columns are hashed or redacted before results are returned.
Scripts
scripts/download_data.py— Download Olist Brazilian E-Commerce CSVs via Kaggle APIscripts/load_data.py— Load CSVs into Postgres in FK-safe order (--reset,--no-geolocation)scripts/make_sample_db.py— Generate a small sample SQLite DB for local testing
Testing
pytest tests/Runs 37 tests: 24 SQLite unit tests + 13 Postgres integration tests (skipped if Postgres is unavailable).
Postgres integration tests require Docker:
docker-compose up -d --build
pytest tests/The data-loader service downloads and loads the Olist dataset automatically when the stack starts.
Linting & Type Checking
ruff check src/ tests/ scripts/
mypy src/License
MIT License. See LICENSE.
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 your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Query, join, profile, clean and convert CSV/JSON/Parquet with server-side DuckDB over MCP.
Read authorized Loam tables and supported external databases through a bounded MCP connection.
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA read-only MCP server for PostgreSQL that enables safe database introspection and querying via natural language.468 npmMIT
- AlicenseAqualityCmaintenanceReadonly PostgreSQL MCP server with SQL guardrails for analytical queries and schema introspection.216 npmMIT
- AlicenseNot gradedqualityDmaintenanceRead-only MCP server for SQL databases (SQLite/PostgreSQL) that enables listing tables, describing schemas, and executing SELECT queries with safety guardrails.MIT
- AlicenseNot gradedqualityDmaintenanceProvides a read-only PostgreSQL MCP server with schema introspection. Enforces least-privilege database roles to prevent any writes, even from malicious SQL.MIT