Skip to main content

MCP server for multi-database access — SQLite, PostgreSQL, MySQL. Query, inspect schema, and manage databases through Claude.

Project description

mcp-database

Python License MCP

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=True and MCP_DATABASE_READ_ONLY=false to enable
  • Read-only detection — write tool rejects SELECT statements (use query instead)
  • Row limits — configurable max rows to prevent accidental large result sets

Development

# Clone and install
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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_database-0.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_database-0.1.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file mcp_database-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_database-0.1.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for mcp_database-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7d363a3fc0a138be7e4cca76e81ffa2e35c2c0fbd7edeb30bd2127a89f7e7161
MD5 86606f6d8485999c06b516b35a287438
BLAKE2b-256 33173faecf3b384b08b9e79db36504b837041cc64d860b8976e6ad71dd98ee3c

See more details on using hashes here.

File details

Details for the file mcp_database-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_database-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for mcp_database-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47ca6c6a5c83468c9f91d17ade06e77dccc96a90104764edbdb6bc897cb297c2
MD5 8cac2c958a6cd521224dcbdac515b39c
BLAKE2b-256 c957b970cae7c9de2449fbe83637eedeb9b935e752c2c4a3973d5d5f5e3c8d19

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page