Provides analytics database operations for ClickHouse including table listing and SQL query execution.
Enables NoSQL database operations for Couchbase including data access and query execution.
Provides graph database operations for Dgraph including data querying and management.
Enables search and analytics operations for Elasticsearch including data querying and index management.
Provides integration with Looker cloud service for business intelligence and analytics operations.
Provides database operations for MongoDB including table/collection listing and query execution.
Enables database operations for MySQL including table listing, SQL query execution, and connection management with support for Cloud SQL variants.
Enables graph database operations for Neo4j including node and relationship querying.
Provides database operations for PostgreSQL including table listing, SQL query execution, and connection management with support for Cloud SQL and AlloyDB variants.
Enables operations for Redis data store including data access and query execution.
Provides database operations for SingleStore analytics warehouse including table listing and SQL query execution.
Offers comprehensive SQLite database operations including 15 built-in introspection tools for schema exploration, CRUD operations, and SQL query execution with support for unknown database discovery.
Enables distributed SQL query engine operations for Trino including cross-database analytics and query execution.
mcp-database
A Node.js MCP (Model Context Protocol) server that provides database operations for AI assistants and agents. Supports 40+ databases through genai-toolbox.
Features
✅ Easy Installation: Install via npm/npx - no manual binary downloads
✅ Universal Database Support: PostgreSQL, MySQL, MongoDB, Redis, SQLite, and 35+ more
✅ Simple Configuration: YAML config or environment variables
✅ MCP Standard: Full MCP protocol implementation
✅ Production Ready: Connection pooling, auth, and observability built-in
Installation
Install from npm and pick the bundle that fits your environment:
Core package (no bundled binaries, ~50KB):
npm install -g @adversity/mcp-databasePlatform-specific (includes binary for one OS/CPU, ~15MB):
macOS ARM64:
npm install -g @adversity/mcp-database-darwin-arm64macOS Intel:
npm install -g @adversity/mcp-database-darwin-x64Linux x64:
npm install -g @adversity/mcp-database-linux-x64Windows x64:
npm install -g @adversity/mcp-database-win32-x64
No install:
npx @adversity/mcp-database --help
Quick Start
Using Prebuilt Configurations
The easiest way to get started is with prebuilt database configurations:
Using Custom Configuration
Create a tools.yaml file:
Run with custom config:
SQLite Built-in Introspection Tools (Recommended for AI)
Designed for AI to explore unknown databases without schema knowledge:
15 Built-in Introspection Tools:
Tool Set | Tool Name | Function |
Basic Exploration |
| List all tables and views |
| View table structure (columns, types, keys) | |
| List all column information | |
| Preview first N rows of data | |
| Complete database summary (tables, indexes, views) | |
Advanced Analysis |
| List all indexes |
| View indexes for a specific table | |
| View columns in an index | |
| View foreign key relationships | |
| Get table's CREATE statement | |
Statistics |
| Count total rows in a table |
| Get statistics for all tables | |
| Database basic information | |
| Get schema version number |
Typical AI Workflow:
MCP Client Configuration Example:
SQLite Custom YAML Example
Copy the example:
cp tools.example.yaml tools.yamlVerify sample database exists:
ls sample.sqliteRun:
DATABASE_NAME=$(pwd)/sample.sqlite \ npx @adversity/mcp-database --config tools.yaml --verboseThe MCP client can access
sqlite_crudtoolset fromtools.example.yaml:sqlite_list_recent_users: List recent 20 user recordssqlite_get_user_by_id: Query by IDsqlite_find_user_by_email: Search by emailsqlite_create_user/sqlite_update_user_email/sqlite_delete_user: Create/Update/Delete
Example YAML snippet (from tools.example.yaml):
Unified Environment Variables and CLI Override
All prebuilt databases use simple, unified environment variables:
DATABASE_HOST- Database host (default: localhost)DATABASE_PORT- Database port (default: depends on database type)DATABASE_NAME- Database nameDATABASE_USER- Database userDATABASE_PASSWORD- Database password
You can also override via CLI:
自定义 toolbox 端口
默认使用 STDIO 模式,不占用 TCP 端口;当需要切换到 HTTP(例如调试或远程访问)时,可指定传输方式与端口:
对应环境变量:
变量 | 说明 |
|
|
| HTTP 监听地址,默认 |
| HTTP 端口,默认 |
CLI 也保留 --stdio(布尔)用于兼容旧脚本;推荐使用 --transport 来切换模式。
MCP Integration
Claude Code / Claude Desktop
Add to your .mcp.json or claude_desktop_config.json:
Cursor IDE
Create .cursor/mcp.json:
VS Code (Copilot)
Create .vscode/mcp.json:
Windsurf
Configure via the Cascade assistant's MCP settings with the same JSON format as Cursor.
Supported Databases
Relational Databases
PostgreSQL
MySQL
SQL Server
SQLite
Oracle
Cloud SQL (Postgres, MySQL, SQL Server)
AlloyDB for PostgreSQL
Spanner
TiDB
OceanBase
YugabyteDB
NoSQL Databases
MongoDB
Redis
Valkey
Firestore
Bigtable
Cassandra
Couchbase
Neo4j
Dgraph
Analytics & Warehouses
BigQuery
ClickHouse
Trino
Serverless Spark
Elasticsearch
SingleStore
Cloud Services
Looker
MindsDB
Dataplex
Cloud Healthcare API
Cloud Monitoring
See genai-toolbox documentation for complete list and configuration details.
Available Tools
When connected via MCP, the following tools are available to AI assistants:
list_tables
List all tables in the database with their descriptions.
Example:
execute_sql
Execute any SQL statement on the database.
Parameters:
sql(string, required): The SQL statement to execute
Example:
Environment Variables
All database types use the same unified environment variables:
DATABASE_HOST- Database host (default: localhost)DATABASE_PORT- Database port (default: varies by database type)PostgreSQL: 5432
MySQL: 3306
MongoDB: 27017
Redis: 6379
MSSQL: 1433
DATABASE_NAME- Database name or file pathDATABASE_USER- Database userDATABASE_PASSWORD- Database password
For cloud services (Cloud SQL, AlloyDB, BigQuery, Spanner, Firestore), additional GCP-specific variables are required:
GCP_PROJECT- GCP project IDGCP_REGION- GCP region (default: us-central1)CLOUD_SQL_INSTANCE/ALLOYDB_CLUSTER/ etc. - Service-specific identifiers
CLI Reference
Programmatic Usage
You can also use mcp-database programmatically:
Testing
The project includes comprehensive test coverage, especially for SQLite features:
SQLite Test Coverage:
✅ 63 test cases, 100% passing
✅ Configuration loading and environment variable handling
✅ 15 built-in introspection tools validation
✅ CRUD operations and parameterized queries
✅ Toolset integration tests
Development
How It Works
This package wraps the genai-toolbox binary and exposes it as an MCP server:
Binary Management: Automatically downloads the correct genai-toolbox binary for your platform
Configuration: Generates or loads YAML configuration with environment variable substitution
MCP Protocol: Implements MCP server protocol over stdio
Tool Execution: Proxies tool calls to genai-toolbox subprocess
Requirements
Node.js 18 or higher
Internet connection (for initial binary download)
Database credentials for your target database
License
MIT
Related Projects
genai-toolbox - The underlying database connectivity engine
Model Context Protocol - The protocol specification
@modelcontextprotocol/sdk - MCP SDK
Contributing
Contributions are welcome! Please open an issue or pull request.
Support
GitHub Issues: Report bugs or request features
Documentation: genai-toolbox docs