Skip to content

simpsonxavier937-code/database-mcp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Database MCP Server

An MCP (Model Context Protocol) server that exposes a SQLite database as tools — letting any MCP client (Claude Desktop, Claude Code, etc.) inspect the schema and run read-only SQL queries. The client's own model generates the SQL.

Ships with the Chinook sample database (a fictional digital music store with 11 tables: artists, albums, tracks, customers, invoices, etc.) so you can demo it immediately.

What it exposes

Tools

  • list_tables() — returns all table names
  • describe_table(table_name) — returns column names and types for a given table
  • read_query(sql) — executes a SELECT statement and returns columns + rows

Resources

  • db://schema — full CREATE TABLE DDL for every table

Security: only SELECT is allowed; other statement types return an error.

Install

Requires Python 3.10+.

git clone https://github.com/simpsonxavier937-code/database-mcp-server.git
cd database-mcp-server
pip install -r requirements.txt

Run standalone (stdio)

python mcp_server.py

By default it serves the bundled chinook.db. Point it at any SQLite file with the DB_PATH env var:

DB_PATH=/path/to/your.db python mcp_server.py

Wire it into Claude Desktop

Add to claude_desktop_config.json:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "database": {
      "command": "python",
      "args": ["C:/path/to/database-mcp-server/mcp_server.py"],
      "env": {
        "DB_PATH": "C:/path/to/database-mcp-server/chinook.db"
      }
    }
  }
}

Restart Claude Desktop. Then try:

  • "What tables are in the database?"
  • "Show me the top 10 customers by total spend."
  • "Which genre has the most tracks?"

Claude will call list_tables / describe_table to learn the schema, then generate and run SELECT queries via read_query.

Test

python -m pytest tests/ -v

Project layout

mcp_server.py         # the MCP server
db.py                 # SQLite helpers (connection, schema, query execution)
chinook.db            # bundled sample database
requirements.txt
tests/
  test_mcp_server.py

About

An MCP server for all your database needs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages