DB Gateway
БесплатноНе проверенProvides governed, read-only PostgreSQL access for AI agents via MCP. Enforces schema/table allowlists, query limits, and audit events.
Описание
Provides governed, read-only PostgreSQL access for AI agents via MCP. Enforces schema/table allowlists, query limits, and audit events.
README
Governed database access for AI agents.
MCP DB Gateway sits between MCP clients and your database. It gives agents enough context to work while keeping database access narrow, read-only, limited, and auditable.
The goal is not another universal SQL connector. The goal is a practical governance boundary for tools such as Cursor, Claude Code, and Claude Desktop.
Early-stage software. Do not treat v0.1 as a complete security boundary without reviewing it for your environment.
Why this exists
Giving an AI agent a database connection creates two opposing problems:
- Too little access forces developers to paste schemas and data into prompts.
- Too much access lets an agent explore or expose far more than the task requires.
MCP DB Gateway makes that boundary explicit through allowlists, read-only transactions, query limits, and audit events.
v0.1 scope
- PostgreSQL
- MCP over stdio
list_tablesdescribe_tableexecute_query- Schema and table allowlists
- Read-only SQL validation and transactions
- Row and statement-timeout limits
- JSON audit events written to stderr
MySQL, SQLite, PII masking, role-based access, and a remote gateway are intentionally deferred.
Quick start
Requirements: Node.js 20+ and PostgreSQL.
git clone https://github.com/altsys/mcp-db-gateway.git
cd mcp-db-gateway
npm install
cp mcp-db-gateway.example.json mcp-db-gateway.json
Edit mcp-db-gateway.json so it contains only the schemas and tables the agent needs. Then build and run:
export DATABASE_URL="postgresql://user:password@localhost:5432/database"
npm run build
MCP_DB_GATEWAY_CONFIG=./mcp-db-gateway.json node dist/index.js
Example MCP client configuration:
{
"mcpServers": {
"database": {
"command": "node",
"args": ["/absolute/path/to/mcp-db-gateway/dist/index.js"],
"env": {
"DATABASE_URL": "postgresql://user:password@localhost:5432/database",
"MCP_DB_GATEWAY_CONFIG": "/absolute/path/to/mcp-db-gateway/mcp-db-gateway.json"
}
}
}
}
Configuration
{
"databaseUrlEnv": "DATABASE_URL",
"governance": {
"allowedSchemas": ["public"],
"allowedTables": ["public.customers", "public.orders"],
"maxRows": 100,
"statementTimeoutMs": 5000
}
}
An empty allowedTables array permits every table inside allowedSchemas. For a real deployment, prefer an explicit table allowlist.
Security model
The gateway provides defense in depth, not magic. Use a dedicated PostgreSQL role with SELECT access only. The application also validates SQL, opens a read-only transaction, limits execution time, and caps returned rows.
SQL parsing is deliberately conservative in v0.1. A proper PostgreSQL parser and table-level query enforcement belong on the near-term roadmap.
Roadmap
- Enforce table policy inside arbitrary SQL queries
- Replace conservative string validation with an AST-based PostgreSQL policy engine
- Mask configured PII columns
- Add structured file or HTTP audit sinks
- Add MySQL and SQLite adapters behind a shared provider interface
- Add named context packs for task-specific access
- Add RBAC and remote transport
Contributing
Issues and focused pull requests are welcome. Please keep changes aligned with the central idea: agents should receive the least database access necessary to complete the task.
License
MIT
Установка DB Gateway
У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.
▸ github.com/altsys/mcp-db-gatewayFAQ
DB Gateway MCP бесплатный?
Да, DB Gateway MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для DB Gateway?
Нет, DB Gateway работает без API-ключей и переменных окружения.
DB Gateway — hosted или self-hosted?
Self-hosted: сервер запускается локально на твоей машине командой из раздела установки.
Как установить DB Gateway в Claude Desktop, Claude Code или Cursor?
Открой DB Gateway на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
Fetch
Web content fetching and conversion for efficient LLM usage.
AWS KB Retrieval
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
автор: modelcontextprotocolSpring AI MCP Server
Provides auto-configuration for setting up an MCP server in Spring Boot applications.
llm-analysis-assistant
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
автор: xuzexin-hzMCP-Agent
A simple, composable framework to build agents using Model Context Protocol by [LastMile AI](https://www.lastmileai.dev)
автор: lastmile-aiSpring AI MCP Client
Provides auto-configuration for MCP client functionality in Spring Boot applications.
mcp.natoma.ai
A Hosted MCP Platform to discover, install, manage and deploy MCP servers by [Natoma Labs](https://www.natoma.ai)
MCPHub
Website to list high quality MCP servers and reviews by real users. Also provide online chatbot for popular LLM models with MCP server support.
MCP Servers Rating and User Reviews
Website to rate MCP servers, write authentic user reviews, and [search engine for agent & mcp](http://www.deepnlp.org/search/agent)
mkinf
An Open Source registry of hosted MCP Servers to accelerate AI agent workflows.
Compare DB Gateway with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории ai
