mcp-enterprise-starter
A production-grade MCP server that gives AI agents safe, authenticated access to a PostgreSQL database.
README
mcp-enterprise-starter
A production-grade MCP (Model Context Protocol) server that gives AI agents safe, authenticated access to a PostgreSQL database. Built as a reference implementation for teams building custom MCP servers for enterprise workflows.
Architecture
┌─────────────────┐ ┌──────────────────────────────────┐ ┌────────────┐
│ Claude Desktop │ │ MCP Enterprise Server │ │ │
│ VS Code │────▶│ │────▶│ PostgreSQL │
│ Any MCP Client │ │ Auth → Validation → Tool Logic │ │ │
└─────────────────┘ └──────────────────────────────────┘ └────────────┘
Security layers:
- API key authentication on every request
- SQL query sandboxing (SELECT only, keyword blocklist)
- Parameterized queries (no SQL injection)
- Sensitive column masking (email, SSN)
- Row limit enforcement
- Per-key rate limiting
- Structured JSON audit logging
Quick Start
Option 1: Docker Compose (recommended)
git clone https://github.com/agrgroup/mcp-enterprise-starter.git
cd mcp-enterprise-starter
cp .env.example .env
docker compose up --build
PostgreSQL starts with seeded sample data. The MCP server connects automatically.
Option 2: Local Development
git clone https://github.com/agrgroup/mcp-enterprise-starter.git
cd mcp-enterprise-starter
npm install
cp .env.example .env
# Start PostgreSQL separately, then seed it:
psql $DATABASE_URL < seed.sql
# Run the server
npm run dev
Connect Claude Desktop
Copy the Claude Desktop config from mcp-config.json into your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"enterprise-db": {
"command": "node",
"args": ["dist/server.js"],
"cwd": "/path/to/mcp-enterprise-starter",
"env": {
"DATABASE_URL": "postgres://mcp_user:mcp_password@localhost:5432/mcp_enterprise",
"API_KEYS": "your-api-key",
"ALLOWED_TABLES": "departments,users,projects",
"SENSITIVE_COLUMNS": "email,ssn"
}
}
}
}
Restart Claude Desktop. Ask: "What tables are available?" to verify the connection.
Connect VS Code
Add to your .vscode/settings.json or user settings:
{
"mcp": {
"servers": {
"enterprise-db": {
"command": "node",
"args": ["dist/server.js"],
"cwd": "${workspaceFolder}/../mcp-enterprise-starter",
"env": {
"DATABASE_URL": "postgres://mcp_user:mcp_password@localhost:5432/mcp_enterprise",
"API_KEYS": "your-api-key",
"ALLOWED_TABLES": "departments,users,projects",
"SENSITIVE_COLUMNS": "email,ssn"
}
}
}
}
}
Tools
| Tool | Description |
|---|---|
query_database |
Execute read-only SQL queries with automatic row limiting and sensitive column masking |
list_tables |
List all tables available for querying (from the configured allowlist) |
get_schema |
Get column definitions, types, and constraints for a specific table |
Resources
| URI Pattern | Description |
|---|---|
db://schema/{table_name} |
Table schema as structured JSON |
Configuration
| Variable | Default | Description |
|---|---|---|
DATABASE_URL |
— | PostgreSQL connection string |
API_KEYS |
— | Comma-separated list of valid API keys |
ALLOWED_TABLES |
departments,users,projects |
Tables the agent can access |
SENSITIVE_COLUMNS |
email,ssn |
Columns to mask in query results |
ROW_LIMIT |
100 |
Default row limit for queries |
MAX_ROW_LIMIT |
1000 |
Maximum row limit (even if query specifies higher) |
RATE_LIMIT_RPM |
60 |
Requests per minute per API key |
MCP_TRANSPORT |
stdio |
Transport mode: stdio or sse |
LOG_LEVEL |
info |
Logging level |
Testing
npm test # Run all tests
npm run test:watch # Watch mode
Tests mock the PostgreSQL connection so no database is needed.
Adapt for Your Own Database
- Update
ALLOWED_TABLESin.envto expose your tables - Update
SENSITIVE_COLUMNSto mask your sensitive fields - Update
seed.sqlwith your schema (or remove it and use an existing database) - Add new tools in
src/tools/following the pattern inquery-database.ts - Update
src/server.tsto register your new tools - Add write operations cautiously — start read-only, add writes with explicit confirmation patterns
Security Notes
- API keys are checked on every tool call. No key = no access.
- Only SELECT queries are allowed. DROP, DELETE, INSERT, UPDATE, and other write operations are blocked at the query level.
- Sensitive columns are masked before results reach the agent. The agent never sees raw PII.
- Row limits prevent accidental full-table scans on large tables.
- All requests are logged as structured JSON to stderr for audit trails.
- The production Docker image runs as a non-root user.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。