sqlite-mcp-server

simonholm/sqlite-mcp-server

3.1

If you are the rightful owner of sqlite-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The SQLite MCP Server is a Model Context Protocol server designed to facilitate SQLite database operations, integrating seamlessly with Anthropic's filesystem MCP for comprehensive file and database workflows.

Tools
8
Resources
0
Prompts
0

SQLite MCP Server

A Model Context Protocol (MCP) server for SQLite database operations. Provides complete database functionality through Claude Desktop.

Features

  • create_database: Create new SQLite databases
  • execute_sql: Run CREATE, INSERT, UPDATE, DELETE statements
  • query_sql: Execute SELECT queries with formatted results
  • import_csv/export_csv: Import/export CSV files
  • list_tables: Show all tables in a database
  • describe_table: Get table schema information
  • backup_database: Create timestamped backups

Installation

Requirements

  • Python 3.7+
  • SQLite3 (included with Python)
  • Claude Desktop with MCP support

Setup Steps

  1. Save the MCP server:

    # Create directory for the server
    mkdir -p /path/to/your/mcp-servers/sqlite
    
    # Copy the server file
    cp sqlite_mcp_server.py /path/to/your/mcp-servers/sqlite/
    
    # Make it executable (Linux/Mac)
    chmod +x /path/to/your/mcp-servers/sqlite/sqlite_mcp_server.py
    
  2. Create database directory:

    mkdir -p /path/to/your/databases
    
  3. Update Claude Desktop configuration: Edit your claude_desktop_config.json:

    {
      "mcpServers": {
        "filesystem": {
          "command": "npx",
          "args": ["-y", "@modelcontextprotocol/server-filesystem", "/your/workspace/path"]
        },
        "sqlite": {
          "command": "python",
          "args": ["/path/to/your/mcp-servers/sqlite/sqlite_mcp_server.py", "/path/to/your/databases"]
        }
      }
    }
    
  4. Restart Claude Desktop

Directory Structure

your-workspace/
├── files/                    # Regular files (filesystem MCP)
├── data/                     # CSV files for import/export
├── databases/                # SQLite databases (SQLite MCP)
│   ├── inventory.db
│   ├── sales.db
│   └── backups/
└── reports/                  # Generated reports

Usage Examples

Basic Database Operations

Create a database called "inventory" and set up a products table with columns for id, name, price, and quantity.

File + Database Integration

Check if there's a products.csv file in the data folder. If there is, import it into the inventory database, then show me the top 10 most expensive products.

Data Analysis Workflows

Query the sales database for all transactions this month, export the results to a CSV file, then create a summary report and save it as a text file.

Database Management

Show me all tables in the customer database, describe the structure of the orders table, and create a backup of the database.

Configuration Options

Windows Example

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "C:\\Users\\YourName\\workspace"]
    },
    "sqlite": {
      "command": "python",
      "args": ["C:\\Users\\YourName\\mcp-servers\\sqlite\\sqlite_mcp_server.py", "C:\\Users\\YourName\\databases"]
    }
  }
}

Linux/Mac Example

{
  "mcpServers": {
    "filesystem": {
      "command": "npx", 
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/username/workspace"]
    },
    "sqlite": {
      "command": "python3",
      "args": ["/home/username/mcp-servers/sqlite/sqlite_mcp_server.py", "/home/username/databases"]
    }
  }
}

Quick Setup Test

After configuration, restart Claude Desktop and verify:

List all available tools. Then create a test database called "demo" and show me it works.

You should see both filesystem and SQLite tools available.

Technical Details

  • Protocol: Implements MCP (Model Context Protocol) 2024-11-05
  • Database: SQLite with WAL (Write-Ahead Logging) mode for better concurrent access
  • Dependencies: Uses only Python standard library (no external packages needed)
  • Security: Uses parameterized queries to prevent SQL injection
  • Error Handling: Comprehensive error handling and logging

Integration Benefits

  1. Seamless Workflows: Both MCPs work with the same file system, enabling smooth data workflows
  2. Data Import/Export: Easy CSV import from files managed by filesystem MCP
  3. Backup and Recovery: Database backups are saved as files accessible via filesystem MCP
  4. Report Generation: Query results can be exported and processed as files
  5. Concurrent Access: Uses WAL mode for better performance when both systems access files

License

MIT License - Feel free to use, modify, and distribute.

Contributing

This is a single-file implementation designed for simplicity and reliability. For contributions:

  1. Test thoroughly with various SQLite operations
  2. Ensure compatibility with the official filesystem MCP
  3. Maintain the single-file design for easy deployment
  4. Add comprehensive error handling for edge cases

Version History

  • v1.0.0: Initial release with all core features
    • Complete MCP protocol implementation
    • All 8 SQLite tools (create, query, import, export, etc.)
    • Seamless integration with filesystem MCP
    • WAL mode support for concurrent access
    • Comprehensive error handling