Skip to main content
Glama
enesmanan

SQLite MCP Server

by enesmanan
README.md
# SQLite MCP Server

A general-purpose Model Context Protocol (MCP) server for SQLite databases. This server provides read and write access to any SQLite database in the `database` folder through Claude Desktop and other MCP clients.

## Features

- Multi-Database Support: Work with multiple SQLite databases in a single server
- Read Operations: Query tables, list databases, describe schemas
- Write Operations: Insert, update, and delete data safely
- Safety Features: Parameterized queries, validation, and required WHERE clauses for destructive operations

## Available Tools

### Database Discovery
- `list_databases` - List all available .db files in the database folder
- `list_tables` - List all tables in a specific database
- `describe_table` - Get detailed table structure (columns, types, constraints)

### Read Operations
- `query_database` - Execute SELECT queries with automatic LIMIT protection

### Write Operations
- `insert_data` - Insert new rows into tables
- `update_data` - Update existing rows (requires WHERE clause)
- `delete_data` - Delete rows (requires WHERE clause)
- `execute_raw_sql` - Execute any SQL query (use with caution)

## Installation

### Prerequisites
- Python 3.10 or higher
- pip (Python package manager)

### Setup

1. Clone or download this repository

2. Install dependencies:
```bash
pip install -r requirements.txt
```

3. Add your databases:
   - Place your SQLite `.db` files in the `database/` folder
   - The server will work with any `.db` file you add to this folder
   - You can add multiple databases and switch between them

## Usage

### Running Locally

Test the server locally:

```bash
python sqlite_mcp.py
```

### Claude Desktop Integration

Add the server to your Claude Desktop configuration file:

**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`  
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`  
**Linux**: `~/.config/Claude/claude_desktop_config.json`

#### Option A: Using Python directly

```json
{
  "mcpServers": {
    "sqlite-mcp-server": {
      "command": "python",
      "args": [
        "C:/Users/YOUR_USERNAME/path/to/sqlite-mcp-server/sqlite_mcp.py"
      ]
    }
  }
}
```

#### Option B: Using uv with fastmcp

```json
{
  "mcpServers": {
    "sqlite-mcp-server": {
      "command": "uv",
      "args": [
        "run",
        "--with", "fastmcp",
        "fastmcp", "run",
        "C:/Users/YOUR_USERNAME/path/to/sqlite-mcp-server/sqlite_mcp.py"
      ]
    }
  }
}
```

Replace `C:/Users/YOUR_USERNAME/path/to/sqlite-mcp-server/` with your actual project path.

### Restart Claude Desktop

After updating the configuration:
1. Completely quit Claude Desktop
2. Restart the application
3. The SQLite MCP Server should now be available

## Example Usage in Claude

Once connected, you can interact with your databases through Claude:

```
"List all available databases"
"Show me the tables in ecommerce.db"
"Describe the structure of the users table in ecommerce.db"
"Query the top 10 products from the products table in ecommerce.db"
"Insert a new user with name 'John Doe' and email 'john@example.com' into ecommerce.db"
```

## Security Notes

- The server uses parameterized queries to prevent SQL injection
- Write operations require explicit WHERE clauses to prevent accidental mass updates/deletes
- Query results are limited to 1000 rows by default

## Project Structure

```
sqlite-mcp-server/
├── sqlite_mcp.py         # Main MCP server
├── database/             # SQLite database files go here
│   └── *.db              # Your database files
├── requirements.txt      # Python dependencies
├── .gitignore            # Git ignore rules
└── README.md            
```

Maintenance

ActivityInactive
ResponsivenessNo issues