mcp-database
MCP server for querying and managing multiple databases (SQLite, PostgreSQL, MySQL) with read-only mode and schema inspection.
README
mcp-database
MCP server for multi-database access — query, inspect schema, and manage SQLite, PostgreSQL, and MySQL databases through Claude.
Why mcp-database?
| Problem | Solution |
|---|---|
| Need to query a database from Claude Code / Claude Desktop | One MCP server, multiple database support |
| Existing database MCP servers are JS/Go only | Pure Python, uses official mcp SDK |
| Worried about accidental writes | Read-only by default, writes opt-in |
| Don't know the schema | Built-in schema inspection, table info, search |
Quick Start
# Install
pip install mcp-database
# Run with a SQLite database
MCP_DATABASE_URL=sqlite:///path/to/your.db mcp-database
Claude Code Integration
# Add to Claude Code
claude mcp add mcp-database -- mcp-database
# Or with a specific database
claude mcp add mcp-database -e MCP_DATABASE_URL=sqlite:///path/to/db.sqlite -- mcp-database
Claude Desktop Integration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"database": {
"command": "mcp-database",
"env": {
"MCP_DATABASE_URL": "sqlite:///path/to/your.db"
}
}
}
}
Supported Databases
| Database | Status | Install |
|---|---|---|
| SQLite | Built-in | pip install mcp-database |
| PostgreSQL | Optional | pip install 'mcp-database[postgres]' |
| MySQL | Optional | pip install 'mcp-database[mysql]' |
| All | Optional | pip install 'mcp-database[all]' |
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
MCP_DATABASE_URL |
sqlite:///:memory: |
Database connection URL |
MCP_DATABASE_TYPE |
sqlite |
Database type: sqlite, postgresql, mysql |
MCP_DATABASE_READ_ONLY |
true |
Enable read-only mode |
MCP_MAX_ROWS |
100 |
Maximum rows returned per query |
Connection URLs
# SQLite
MCP_DATABASE_URL=sqlite:///path/to/db.sqlite
MCP_DATABASE_URL=sqlite:///:memory:
# PostgreSQL
MCP_DATABASE_URL=postgres://user:password@localhost:5432/mydb
MCP_DATABASE_TYPE=postgresql
# MySQL
MCP_DATABASE_URL=mysql://user:password@localhost:3306/mydb
MCP_DATABASE_TYPE=mysql
Available Tools
Once connected, Claude can use these tools:
| Tool | Description |
|---|---|
list_databases |
List all configured database connections |
list_tables |
List all tables in a database |
get_table_info |
Get detailed table info (columns, types, row count) |
get_schema |
Get full database schema (CREATE TABLE statements) |
query |
Execute a read-only SQL query (SELECT, SHOW, DESCRIBE) |
execute |
Execute a write statement (INSERT, UPDATE, DELETE) — opt-in only |
sample_rows |
Get sample rows from a table |
search_tables |
Search for tables or columns by keyword |
Examples
Ask Claude things like:
- "What tables are in my database?"
- "Show me the schema for the users table"
- "Query the top 10 orders by amount"
- "Find all columns related to 'email'"
- "Sample some rows from the products table"
Security
- Read-only by default — queries are safe, no data modification
- Write opt-in — set
allow_writes=TrueandMCP_DATABASE_READ_ONLY=falseto enable - Read-only detection — write tool rejects SELECT statements (use
queryinstead) - Row limits — configurable max rows to prevent accidental large result sets
Development
# Clone and install for development
git clone https://github.com/Jansen003/mcp-database.git
cd mcp-database
pip install -e ".[dev]"
# Run tests
pytest
# Run with Inspector UI
mcp dev src/mcp_database/server.py
License
MIT — see LICENSE.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.