A Model Context Protocol (MCP) server that provides SQLite database operations through MCP tools and resources.
This project implements an MCP server using FastMCP that allows clients to interact with a SQLite database. It provides tools for executing SQL queries, listing tables, retrieving table schemas, and accessing database information.
- execute_sql: Execute arbitrary SQL queries on the database
- list_tables: List all tables in the database
- get_table_schema: Get detailed schema information for a specific table
- sqlite://tables: Provides an overview of the database including table names and count
- Clone or download this repository
- Install dependencies:
pip install -r requirements.txt
- Ensure you have a Python virtual environment set up (optional but recommended)
- Run the server:
python app.py
Or use the provided script:
./run_mcp.sh
Build and run using Docker:
docker build -t sqlite-mcp-server .
docker run -v $(pwd)/app/data:/app/app/data sqlite-mcp-server
The database file is stored in app/data/mcp.db
and can be mounted as a volume for persistence.
- Python 3.7+
- mcp>=1.14.0
The server uses a SQLite database located at app/data/mcp.db
. The database is automatically initialized on first run with WAL mode enabled for better concurrency.
Executes an SQL query.
- sql: The SQL query string
- params: Optional parameters for parameterized queries
- Returns: Query results for SELECT statements, or affected row count for other operations
Lists all tables in the database.
- Returns: List of table names
Gets schema information for a table.
- table_name: Name of the table
- Returns: Column details including name, type, nullability, default values, and primary key status
Provides a text summary of the database structure.