DB Insights MCP Server
Allows querying MySQL databases through read-only SELECT queries, with schema discovery and row sampling.
Supports PostgreSQL databases with read-only SELECT queries, schema exploration, and transaction safety (SET TRANSACTION READ ONLY).
Provides a default SQLite database for querying, with tools to list tables, describe schemas, sample rows, and run safe SELECT queries.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@DB Insights MCP Servershow me the users table schema"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
DB Insights MCP Server
An MCP server that lets an AI assistant answer questions about a SQL database —
read-only, by design. The model can discover the schema and run SELECT
queries through a guarded interface, but it physically cannot insert, update, or
drop anything. The server is the safety wall between the model and your data.
MCP (Model Context Protocol) is the standard way to give an AI client — Claude Desktop, Cursor, an agent — access to external tools and data. This server exposes a database as a set of safe tools any MCP client can use.
Why read-only is the whole point
"Let our AI talk to our database" is easy to ask for and scary to ship. A model
(or a prompt injection riding in on some untrusted text) might try
DROP TABLE customers. This server makes that impossible: every query is checked
before it runs, and anything that isn't a single read-only SELECT is rejected.
Rejected: Only SELECT (or WITH ... SELECT) queries are allowed.The guard (server/safety.py) strips comments, allows a single statement only,
requires it to start with SELECT/WITH, blocks write and DDL keywords, and
blocks SELECT ... INTO. On top of that, queries run in a connection that never
commits (and SET TRANSACTION READ ONLY on Postgres), and every result is capped.
Related MCP server: safe-sql-mcp
Architecture
MCP client (Claude Desktop / MCP Inspector / agent)
│ MCP over stdio (local) or Streamable HTTP (deployed)
▼
this server (FastMCP)
├─ tools: list_tables · describe_table · sample_rows · run_query
├─ resource: schema://overview (schema, loaded into the model's context)
├─ prompt: explore(question) (a starter prompt template)
├─ safety: SELECT-only · single statement · no DDL/DML · row cap · no commit
└─ SQLAlchemy ──> SQLite (seeded sample DB) | Postgres/MySQL via DATABASE_URLThe client's model decides which tools to call and writes the SQL. This server validates and runs it. The server never calls an LLM itself — so it needs no API key. Following MCP's own distinction: the schema is a resource (data read into context), and the queries are tools (actions).
Run and test it
1. Install dependencies
pip install -r requirements.txt2. Test with MCP Inspector (no LLM needed)
Use forward slashes — backslashes cause a path mangling bug on Windows:
mcp dev server/main.pyThat opens the Inspector in your browser. Click Connect, then go to the
Tools tab. Call list_tables, then run_query with something like:
SELECT p.category, ROUND(SUM(oi.quantity * oi.unit_price), 2) AS revenue
FROM order_items oi JOIN products p ON p.id = oi.product_id
GROUP BY p.category ORDER BY revenue DESC;Then try DELETE FROM customers and watch it get rejected.
Windows note: if the Inspector shows a
VIRTUAL_ENVwarning on connect, that's harmless —uvignores the active venv and manages its own environment.
3. Wire up Claude Desktop
Open the config via Claude Desktop → profile icon → Settings → Developer → Edit Config.
Or navigate to it directly:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Set cwd to the absolute path of this folder and command to the full path of
the Python executable in your virtual environment:
{
"mcpServers": {
"db-insights": {
"command": "C:\\path\\to\\venv\\Scripts\\python.exe",
"args": ["-m", "server.main"],
"cwd": "C:\\path\\to\\db-insights-mcp"
}
}
}Fully quit Claude Desktop (system tray → Quit or clear from Task-manager), then relaunch it. Ask something
like "which product category made the most revenue?" and it will call the tools
on its own.
4. Run the tests
pytestSQLite by default, your database by env var
One setting, no code change:
Variable | Default | What it does |
|
| seeded sample DB; point at Postgres for real |
|
| hard cap on rows any query returns |
|
|
|
For a real database:
DATABASE_URL=postgresql+psycopg://user:pass@host:5432/dbnameSeeding only ever touches the default SQLite file — it never writes to a database you point it at.
When this helps (and when it doesn't)
Good fit: internal analytics assistants, "ask our data in plain English," letting an agent explore a reporting database safely.
Be careful when: the database holds sensitive rows the model shouldn't read (the
guard stops writes, not reads — scope the connection's user/permissions for
that), or queries can be expensive (set MAX_ROWS and a DB-side statement timeout).
Notes
Built on the official MCP Python SDK (
mcp.server.fastmcp.FastMCP).SSE transport is deprecated upstream; this uses stdio and Streamable HTTP.
The guard is intentionally strict — a literal like
SELECT 'DROP'is refused. Better a rare false reject than one destructive query slipping through.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
AI agents propose database changes as reviewable requests — no direct write access.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables safe, read-only SQL access to SQLite databases for AI agents, allowing schema exploration and SELECT queries with defense-in-depth protections.3MIT
- FlicenseNot gradedqualityCmaintenanceEnables read-only SQL database access for AI assistants, allowing schema exploration and safe query execution without risk of data modification.-
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants to safely query and explore SQL Server and PostgreSQL databases with read-only access, supporting schema discovery, relationship exploration, and query execution.373MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to explore SQL Server schemas, relationships, and execute safe SQL queries with read-only mode by default and optional write control.1MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/six-eyes-dev/MCP-server-for-DB'
If you have feedback or need assistance with the MCP directory API, please join our Discord server