DB MCP Gateway
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 MCP GatewayShow me the last 10 orders"
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 MCP Gateway
Give Claude Code, Cursor, Windsurf, or any MCP-compatible AI tool read-only access to your databases — without exposing credentials or risking data changes.
Self-hosted. Everything runs locally. Your passwords never leave your machine.
https://github.com/user-attachments/assets/f768ff6f-3c9e-4583-9179-c7022d3b7487
Supported databases
Database | Notes | |
PostgreSQL | All versions | |
MySQL | MySQL 5.7+ / MariaDB | |
SQLite | Local file, no server needed | |
Amazon Redshift | SSL required, Redshift-specific catalog queries |
What it does
Instead of copy-pasting query results between your DB client and your AI tool, the gateway lets your AI query the database directly. It can explore schemas, inspect tables, and run SELECT queries. It cannot insert, update, delete, or drop anything.
Related MCP server: Generic Database MCP Server
Quick Start
Option A — Docker (recommended, no local install needed)
git clone https://github.com/mdadul/db-mcp
cd db-mcp
# Generate .env with secure random keys, then start
sh scripts/setup.sh
docker compose updocker compose pulls the pre-built image from Docker Hub — no build step required.
The MCP_TOKEN is printed by setup.sh — copy it before you close the terminal.
Option B — Native (requires Bun)
git clone https://github.com/mdadul/db-mcp
cd db-mcp
bun install
bun run dev # generates .env automatically, then starts the serverOpen http://localhost:4080.
Your MCP_TOKEN is in .env.
Connect your AI tool
Claude Code (CLI)
claude mcp add --transport http db-mcp http://localhost:4080/mcp \
--header "Authorization: Bearer <MCP_TOKEN>"Then restart Claude Code.
Cursor / Windsurf / Claude Desktop
Add to your mcp.json:
{
"mcpServers": {
"db-mcp": {
"url": "http://localhost:4080/mcp",
"headers": {
"Authorization": "Bearer <MCP_TOKEN>"
}
}
}
}Claude.ai Web
Claude.ai requires HTTPS. Expose the gateway through a tunnel first:
# Option A — Cloudflare (no account needed)
npx cloudflared tunnel --url http://localhost:4080
# Option B — ngrok
ngrok http 4080Copy the https://... URL from the tunnel output, then add it in Claude.ai → Settings → Integrations → Add MCP Server.
Using it with your AI
Once connected, just ask naturally:
"How many orders were created this week?" "What columns does the
userstable have?" "Show me the last 10 failed jobs."
The AI will call the gateway tools automatically — no copy-pasting.
Available tools
Tool | What it does |
| Lists all connected databases |
| Lists tables (optional name filter) |
| Shows columns, indexes, and foreign keys for a table |
| Runs a SELECT query (capped at 100 rows by default, max 1000) |
Environment variables
Variable | Required | Description |
| Yes | Path for the local SQLite metadata store (e.g. |
| Yes | 64-char hex key for credential encryption. Generate: |
| Yes | Bearer token for the |
| No | HTTP port (default: |
A .env file is created with generated values on first run.
Troubleshooting
Tools not showing up in Claude Code
Restart Claude Code after adding the MCP server. If still missing, run claude mcp list to confirm it's registered and shows ✓ Connected.
"Failed to connect" in Claude Code
Check the gateway is running (http://localhost:4080 should load) and the token in your config matches .env.
"Session not found" errors The gateway is stateless — each request is independent. If you see this, reconnect the MCP server in your IDE.
"URL must start with https" (Claude.ai Web) Claude.ai blocks plain HTTP. Use a tunnel — see the Claude.ai Web setup above.
Connection refused to my database
If the gateway runs in Docker and your database is on the host, use host.docker.internal instead of localhost as the host.
Security notes
The
MCP_TOKENcontrols access to all your databases via the gateway. Treat it like a password.Database credentials are encrypted with AES-256-GCM. The key lives only in
ENCRYPTION_KEY— never in the database.Only
SELECT,SHOW,DESCRIBE, andEXPLAINare permitted. Write operations are rejected at the gateway layer before reaching the database.All queries are logged in the web dashboard under each database's Logs tab.
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
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
- dataOAuthco.thinair
Read-only PostgreSQL, MySQL, SQL Server access via MCP — 24 dialect-aware hosted tools.
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.
Related MCP Servers
- FlicenseNot gradedqualityFmaintenanceA read-only MCP server that enables AI agents to explore database schemas and execute safe queries on PostgreSQL and MySQL.-
- FlicenseNot gradedqualityDmaintenanceEnables read-only SQL querying and schema inspection across MSSQL, PostgreSQL, and MySQL databases via MCP tools.-
- AlicenseNot gradedqualityBmaintenanceProvides read-only access to PostgreSQL databases via MCP, enforcing least-privilege roles, row-level security, masked views, and SQL AST guardrails to prevent data leakage and unauthorized operations, enabling AI agents to safely query sensitive production data.MIT
- AlicenseNot gradedqualityCmaintenanceProvides read-only Microsoft SQL Server database access to AI agents with row-level security, enabling SELECT queries, table metadata, and schema introspection through MCP.24MIT
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/mdadul/db-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server