Database Server
A Model Context Protocol (MCP) server that provides multi-database query execution capabilities with support for SQLite, PostgreSQL, and MySQL databases. Includes a built-in Web UI for managing database connections.
MCP Database Server
A Model Context Protocol (MCP) server that provides multi-database query execution capabilities with support for SQLite, PostgreSQL, and MySQL databases. Includes a built-in Web UI for managing database connections.
NPM Package
Available on NPM: @ahmetbarut/mcp-database-server
# Use with npx (no installation required)
npx @ahmetbarut/mcp-database-server
# Or install globally
npm install -g @ahmetbarut/mcp-database-server
Features
- Multi-Database Support: SQLite, PostgreSQL, and MySQL with real connections
- Web UI: Built-in browser interface for managing database connections
- SQLite Config Store: All connection configs persisted locally in
~/.mcp-database-server/connections.db - MCP Protocol Compliance: Full JSON-RPC implementation with complete tool support
- Smart Auto-Detection: Automatically selects single active connection for queries
- Connection Recovery: Retry failed connections with detailed error reporting
- Security First: Parameterized queries, SQL injection protection, audit logging
- SSL Support: Configurable SSL per connection
- Type Safety: Full TypeScript implementation with Zod validation
- Node.js v23 Compatible: Works with latest Node.js versions
Quick Start
npx @ahmetbarut/mcp-database-server
Server starts and Web UI opens at http://localhost:3693. Add your database connections from the browser.
Web UI
The built-in Web UI provides a visual interface for managing database connections:
- Add/Edit/Delete database connections (SQLite, PostgreSQL, MySQL)
- Test connections before saving
- SSL toggle for network databases
- Persistent storage — connections survive server restarts
Access it at http://localhost:3693 when the server is running.
Environment Variables
| Variable | Default | Description |
|---|---|---|
WEB_UI_PORT | 3693 | Web UI port |
WEB_UI_ENABLED | true | Enable/disable Web UI |
LOG_LEVEL | info | Logging level (debug, info, warn, error) |
MCP Client Configuration
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "@ahmetbarut/mcp-database-server"]
}
}
}
Cursor IDE
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "@ahmetbarut/mcp-database-server"]
}
}
}
Custom Port
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["-y", "@ahmetbarut/mcp-database-server"],
"env": {
"WEB_UI_PORT": "4000"
}
}
}
}
After starting, open the Web UI in your browser to add database connections.
MCP Tools
execute_query
Execute SQL queries on a database connection with parameterized query support.
{
"connection_name": "my-postgres",
"query": "SELECT * FROM users WHERE status = $1",
"parameters": ["active"]
}
list_databases
List databases from a specific connection or all configured connections. Supports smart auto-detection when only one connection is active.
{
"connection_name": "my-postgres"
}
list_connections
List all database connections with status and details.
{
"include_credentials": false
}
retry_failed_connections
Retry failed database connections.
{
"connection_name": "my-postgres"
}
Connection Configuration
All database connections are managed through the Web UI and stored in a local SQLite database at ~/.mcp-database-server/connections.db.
Supported Database Types
SQLite
- Path to database file
PostgreSQL
- Host, port, database, username, password
- SSL support (optional)
MySQL
- Host, port, database, username, password
- SSL support (optional)
Connection Settings
| Setting | Default | Description |
|---|---|---|
maxConnections | 10 | Maximum connection pool size |
timeout | 30000 | Connection timeout in milliseconds |
ssl | false | Enable SSL for the connection |
Development
# Clone the repository
git clone https://github.com/ahmetbarut/mcp-database-server.git
cd mcp-database-server
# Install dependencies
npm install
# Development mode (hot-reload)
npm run dev
# Build
npm run build
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Lint
npm run lint
# Type check
npm run type-check
Project Structure
mcp-database-server/
├── src/
│ ├── index.ts # CLI entry point
│ ├── server/
│ │ └── mcp-server.ts # MCP server, tool handlers
│ ├── database/
│ │ ├── base.ts # Abstract base driver
│ │ ├── factory.ts # Driver factory & connection manager
│ │ └── drivers/ # SQLite, PostgreSQL, MySQL drivers
│ ├── config/
│ │ ├── settings.ts # Config manager (loads from SQLite store)
│ │ └── config-store.ts # SQLite-backed connection storage
│ ├── web/
│ │ ├── web-server.ts # HTTP server for Web UI
│ │ ├── routes.ts # REST API endpoints
│ │ └── ui.ts # Embedded HTML/CSS/JS interface
│ ├── types/ # TypeScript types & Zod schemas
│ └── utils/ # Logger, exceptions, helpers
├── tests/unit/ # Jest test suites
└── dist/ # Compiled output
Architecture
npx @ahmetbarut/mcp-database-server
│
├── MCPDatabaseServer
│ ├── MCP stdio transport (JSON-RPC)
│ ├── DatabaseConnectionManager
│ └── WebUIServer (http://localhost:3693)
│
└── ConnectionConfigStore (~/.mcp-database-server/connections.db)
└── SQLite database with connection configs
- Config Store loads saved connections from local SQLite DB
- Connection Manager initializes database drivers for each config
- MCP Server exposes tools via JSON-RPC over stdio
- Web UI provides browser-based CRUD for connections via REST API
Security
- Parameterized queries — prevents SQL injection
- Credential masking — passwords hidden in
list_connectionsoutput - Audit logging — all operations logged via Winston
- Input validation — Zod schemas for all configuration
Testing
Test Suites: 2 passed, 2 total
Tests: 23 passed, 23 total
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage report
Troubleshooting
Web UI not accessible
- Check if port 3693 is already in use
- Try a different port:
WEB_UI_PORT=4000
Connection failed
- Use the "Test Connection" button in Web UI before saving
- Verify database server is running and accessible
- Check credentials and network connectivity
- For PostgreSQL: disable SSL if server doesn't support it
MCP client can't connect
- Ensure
npx @ahmetbarut/mcp-database-serverruns without errors - Restart the MCP client after config changes
- Check MCP client logs for error details
License
MIT License - see LICENSE file for details.
Contributing
- Follow TypeScript coding standards
- Add tests for new functionality
- Update documentation for API changes
- Follow security guidelines
Support
For issues and questions, use the GitHub issue tracker.
相關伺服器
Acumatica MCP Server by CData
A read-only MCP server for querying live Acumatica data using the CData JDBC Driver.
MCP MySQL Server
An MCP server based on Spring AI that executes arbitrary SQL queries against a configured MySQL database.
MySQL MCP
A secure MCP service for accessing and managing MySQL databases, featuring multi-layer security and high-performance connection pooling.
MariaDB
An MCP server for retrieving data from a MariaDB database.
Claude Conversation Memory System
Provides searchable local storage for Claude conversation history, enabling context retrieval during sessions.
Supabase
Connects to Supabase platform for database, auth, edge functions and more.
OrionBelt Semantic Layer
API-first engine and MCP server that transforms declarative YAML model definitions into optimized SQL for Postgres, Snowflake, ClickHouse, Dremio, and Databricks
UK Crime MCP
An MCP server for accessing UK police crime data, deployable on Cloudflare Workers.
AlphaFold MCP Server
Access the AlphaFold Protein Structure Database for protein structure prediction and analysis.
Project Synapse MCP Server
Transforms raw text into interconnected knowledge graphs and generates insights using a Neo4j database.