db-mcp
Self-hosted MCP gateway that gives AI coding agents read-only access to your databases.
Install / Use
claude mcp add mdadul -- npx -y github:mdadul/db-mcpIf the server publishes to npm under a different name, use that package instead — check the repo README.
MCP Server
Model Context Protocol server
Quality Score
Category
Data & AnalyticsSupported Platforms
Our assessment of db-mcp
db-mcp scores 75/100 on our quality scale, 537th of 598 Data & Analytics skills we index.
Its MCP Server is 4.9 KB long, well organised into 18 sections with 5 code examples: a solid amount of guidance for an agent.
It has 3 GitHub stars, so there is little community track record yet; judge it on its content.
Maintenance, license and trust
- The repository was last updated 14 days ago, so db-mcp is actively maintained.
- No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
- Its trust signals score 75/100, with 3 cautions from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
db-mcp compared with similar skills
All 4 of these similar skills score higher than db-mcp; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| db-mcp (this skill)by mdadul | 75 | 3 | 14d ago | MCP Server |
| Agent-Reachby Panniantong | 100 | 106.4k | 5d ago | CLAUDE.md |
| claude-memby thedotmack | 100 | 105.0k | today | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 78.3k | today | CLAUDE.md |
| CowAgentby zhayujie | 100 | 47.7k | today | CLAUDE.md |
Frequently asked questions
- How do I install db-mcp?
- Run
claude mcp add mdadul -- npx -y github:mdadul/db-mcp. The install tabs above show the steps for each supported agent. - Which AI agents does db-mcp work with?
- It is written for Claude Code and Claude Desktop, as a MCP Server file. Other agents that read the same format can often use it too.
- Is db-mcp safe to use?
- It declares no license and scores 75/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is db-mcp still maintained?
- The repository was last updated 14 days ago, so db-mcp is actively maintained.
Skill content
View source on GitHubDB 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 | |---|---|---| | <img src="client/public/postgre.png" width="20" height="20"> | PostgreSQL | All versions | | <img src="client/public/mysql.png" width="20" height="20"> | MySQL | MySQL 5.7+ / MariaDB | | <img src="client/public/sqlite.webp" width="20" height="20"> | SQLite | Local file, no server needed | | <img src="client/public/redshift.png" width="20" height="20"> | 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.
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 up
docker 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 server
Open 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 4080
Copy 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 |
|------|-------------|
| list_databases | Lists all connected databases |
| get_database_schema | Lists tables (optional name filter) |
| get_table_schema | Shows columns, indexes, and foreign keys for a table |
| execute_read_query | Runs a SELECT query (capped at 100 rows by default, max 1000) |
Environment variables
| Variable | Required | Description |
|---|---|---|
| DATABASE_PATH | Yes | Path for the local SQLite metadata store (e.g. ./data/db-mcp.sqlite) |
| ENCRYPTION_KEY | Yes | 64-char hex key for credential encryption. Generate: openssl rand -hex 32 |
| MCP_TOKEN | Yes | Bearer token for the /mcp endpoint. Generate: openssl rand -base64 32 |
| PORT | No | HTTP port (default: 4080) |
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.
Related Skills
Agent-Reach
106.4kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
claude-mem
105.0kPersistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
headroom
78.3kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
CowAgent
47.7kOpen-source personal AI assistant & Agent Harness. Plans tasks, runs tools and skills, self-evolves with memory and knowledge. Multi-agent, multi-model, multi-channel. Lightweight, extensible, one-line install.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
