DB-MCP
About
Self-hosted MCP gateway that gives AI coding agents read-only access to your databases.
Details
- Author
- mdadul
- Categories
- Developer Tools
Jump to
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 composepulls the pre-built image from Docker Hub — no build step required.
TheMCP_TOKENis printed bysetup.sh— copy it before you close the terminal.
git clone https://github.com/mdadul/db-mcp cd db-mcp bun install bun run dev # generates .env automatically, then starts the server
Open](https://github.com/user-attachments/assets/f768ff6f-3c9e-4583-9179-c7022d3b7487)http://localhost:4080.
YourMCP_TOKENis in.env.
claude mcp add --transport http db-mcp http://localhost:4080/mcp \ --header "Authorization: Bearer <MCP_TOKEN>"
{ "mcpServers": { "db-mcp": { "url": "http://localhost:4080/mcp", "headers": { "Authorization": "Bearer <MCP_TOKEN>" } } } }
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 thehttps://...URL from the tunnel output, then add it in Claude.ai → Settings → Integrations → Add MCP Server.
"How many orders were created this week?" "What columns does theuserstable have?" "Show me the last 10 failed jobs."
The AI will call the gateway tools automatically — no copy-pasting.
A.envfile is created with generated values on first run.
Tools not showing up in Claude CodeRestart Claude Code after adding the MCP server. If still missing, runclaude mcp listto confirm it's registered and shows✓ Connected.
"Failed to connect" in Claude CodeCheck the gateway is running (http://localhost:4080should load) and the token in your config matches.env.
"Session not found" errorsThe 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 databaseIf the gateway runs in Docker and your database is on the host, usehost.docker.internalinstead oflocalhostas the host.
- TheMCP_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 inENCRYPTION_KEY— never in the database.
- OnlySELECT,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.
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
Create crafted UI components inspired by the best 21st.dev design engineers.
Bring agent evaluations, observability, and synthetic test set generation directly into your IDE for free with Galileo's new MCP server
An MCP server to help AI assistants to answer questions and generate AccelByte Extend SDK code more effectively .
MCP server for AI Diagram Maker — generate beautiful software engineering diagrams directly inside Cursor, Claude Desktop, Claude Code, or any MCP-compatible AI agent
ALAPI MCP Tools,Call hundreds of API interfaces via MCP
AI-powered SVG animation generator that transforms static files into animated SVG components using the Allyson platform
MCP server that gives AI assistants on-demand access to 1,500+ amCharts docs, ~300 code examples, and 1000+ class API references.
APIMatic MCP Server is used to validate OpenAPI specifications using APIMatic. The server processes OpenAPI files and returns validation summaries by leveraging APIMatic’s API.
One shared context layer for AI agents and humans — live API specs, DB schemas, and versioned contracts across repos so every agent and teammate works from the same source of truth.
Build and deploy full-stack Next.js apps with 98 tools for React, AWS, and MongoDB
Give Claude Code, Cursor, Windsurf, or any MCP-compatible AI toolread-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
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. Itcannotinsert, update, delete, or drop anything.
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 composepulls the pre-built image from Docker Hub — no build step required.
TheMCP_TOKENis printed bysetup.sh— copy it before you close the terminal.
git clone https://github.com/mdadul/db-mcp cd db-mcp bun install bun run dev # generates .env automatically, then starts the server
Openhttp://localhost:4080.
YourMCP_TOKENis in.env.
claude mcp add --transport http db-mcp http://localhost:4080/mcp \ --header "Authorization: Bearer <MCP_TOKEN>"
{ "mcpServers": { "db-mcp": { "url": "http://localhost:4080/mcp", "headers": { "Authorization": "Bearer <MCP_TOKEN>" } } } }
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 thehttps://...URL from the tunnel output, then add it in Claude.ai → Settings → Integrations → Add MCP Server.
"How many orders were created this week?" "What columns does theuserstable have?" "Show me the last 10 failed jobs."
The AI will call the gateway tools automatically — no copy-pasting.
A.envfile is created with generated values on first run.
Tools not showing up in Claude CodeRestart Claude Code after adding the MCP server. If still missing, runclaude mcp listto confirm it's registered and shows✓ Connected.
"Failed to connect" in Claude CodeCheck the gateway is running (http://localhost:4080should load) and the token in your config matches.env.
"Session not found" errorsThe 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 databaseIf the gateway runs in Docker and your database is on the host, usehost.docker.internalinstead oflocalhostas the host.
- TheMCP_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 inENCRYPTION_KEY— never in the database.
- OnlySELECT,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.
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
Create crafted UI components inspired by the best 21st.dev design engineers.
Bring agent evaluations, observability, and synthetic test set generation directly into your IDE for free with Galileo's new MCP server
An MCP server to help AI assistants to answer questions and generate AccelByte Extend SDK code more effectively .
MCP server for AI Diagram Maker — generate beautiful software engineering diagrams directly inside Cursor, Claude Desktop, Claude Code, or any MCP-compatible AI agent
ALAPI MCP Tools,Call hundreds of API interfaces via MCP
AI-powered SVG animation generator that transforms static files into animated SVG components using the Allyson platform
MCP server that gives AI assistants on-demand access to 1,500+ amCharts docs, ~300 code examples, and 1000+ class API references.
APIMatic MCP Server is used to validate OpenAPI specifications using APIMatic. The server processes OpenAPI files and returns validation summaries by leveraging APIMatic’s API.
One shared context layer for AI agents and humans — live API specs, DB schemas, and versioned contracts across repos so every agent and teammate works from the same source of truth.
Build and deploy full-stack Next.js apps with 98 tools for React, AWS, and MongoDB
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





