🔌

SQLite MCP

Database720

Query and analyze SQLite databases directly from your AI agent.

Claude DesktopCursorWindsurf

Overview

Query and analyze SQLite databases directly from your AI agent.

Setup

Run with npx:

npx -y @modelcontextprotocol/server-sqlite /path/to/database.db

Configuration

Database path as argument, optional READ_ONLY env var

Documentation

SQLite MCP

Overview

SQLite MCP is a Model Context Protocol server that enables AI agents to interact with SQLite databases directly. It provides tools for querying, analyzing, and managing SQLite databases, making it easy for agents to work with structured data.

Key Features

🗄️ Database Operations

  • SQL Query Execution: Run SELECT, INSERT, UPDATE, DELETE queries
  • Schema Inspection: View database schema and table structures
  • Data Analysis: Query and analyze data directly
  • Safe Execution: Read-only mode available for safety

📊 Query Capabilities

-- Natural language to SQL
"Show me all users who signed up in the last 30 days"

-- Direct SQL
"SELECT * FROM users WHERE created_at > date('now', '-30 days')"

-- Schema exploration
"List all tables and their columns"

🔒 Security Features

  • Read-Only Mode: Prevent accidental data modification
  • Query Validation: Basic SQL injection prevention
  • Connection Isolation: Each agent session isolated
  • Audit Logging: Track all queries for debugging

Installation

# Using npx (recommended)
npx -y @modelcontextprotocol/server-sqlite

# With database path
npx -y @modelcontextprotocol/server-sqlite path/to/database.db

Configuration

Basic Setup

  1. Configure in Claude Desktop:
    {
      "mcpServers": {
        "sqlite": {
          "command": "npx",
          "args": ["-y", "@modelcontextprotocol/server-sqlite", "/path/to/database.db"]
        }
      }
    }
    

Read-Only Mode

{
  "mcpServers": {
    "sqlite": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-sqlite", "/path/to/database.db"],
      "env": {
        "READ_ONLY": "true"
      }
    }
  }
}

Multiple Databases

{
  "mcpServers": {
    "sqlite-main": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-sqlite", "/path/to/main.db"]
    },
    "sqlite-analytics": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-sqlite", "/path/to/analytics.db"]
    }
  }
}

Available Tools

ToolDescription
queryExecute a SQL query and return results
list_tablesList all tables in the database
get_schemaGet the schema for a specific table
executeExecute a SQL statement (INSERT, UPDATE, DELETE)

Usage Examples

Explore Database Structure

List all tables in the database

Returns:

Tables: users, orders, products, order_items

View Table Schema

Show me the schema for the users table

Returns:

CREATE TABLE users (
  id INTEGER PRIMARY KEY,
  email TEXT NOT NULL,
  name TEXT,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)

Natural Language Queries

How many users signed up last month?

Agent translates to SQL:

SELECT COUNT(*) FROM users 
WHERE created_at >= date('now', 'start of month', '-1 month')
  AND created_at < date('now', 'start of month');

Data Analysis

Show me the top 10 products by sales volume

Agent executes:

SELECT p.name, SUM(oi.quantity) as total_sold
FROM products p
JOIN order_items oi ON p.id = oi.product_id
GROUP BY p.id
ORDER BY total_sold DESC
LIMIT 10;

Update Data

Update John's email to john.new@example.com

Agent executes:

UPDATE users SET email = 'john.new@example.com' WHERE name = 'John';

Integration with AI Agents

Claude Desktop

Claude: "Let me check the database for that information..."
[Queries SQLite via MCP]
Claude: "I found 42 users who signed up last week..."

Custom Agent Integration

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

# Connect to SQLite MCP
server_params = StdioServerParameters(
    command="npx",
    args=["-y", "@modelcontextprotocol/server-sqlite", "/path/to/database.db"]
)

async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        await session.initialize()
        
        # List tables
        tables = await session.call_tool("list_tables", arguments={})
        
        # Query data
        results = await session.call_tool(
            "query",
            arguments={"sql": "SELECT * FROM users LIMIT 5"}
        )

Pros

  • Simple Setup: Single npx command
  • Direct Access: No ORM or abstraction layer
  • Full SQL Support: Execute any valid SQLite query
  • Schema Discovery: Auto-discover database structure
  • Natural Language: Agents can write SQL from prompts
  • Lightweight: SQLite is embedded and fast

Cons

  • SQLite Only: Doesn't support PostgreSQL, MySQL, etc.
  • No Connection Pooling: Each query opens connection
  • Limited Transactions: No explicit transaction support
  • No Migrations: Schema changes must be done manually
  • File-Based: Database must be accessible as a file

When to Use

Choose SQLite MCP when:

  • You're working with SQLite databases
  • You need quick database access for analysis
  • You want agents to query data naturally
  • You're building local-first applications

Consider alternatives when:

  • You need PostgreSQL or MySQL (use postgres MCP)
  • You need connection pooling for high concurrency
  • You need complex transaction management

Resources

Comparison

FeatureSQLite MCPPostgreSQL MCPMySQL MCP
DatabaseSQLitePostgreSQLMySQL
Setup✅ Very Easy⚠️ Moderate⚠️ Moderate
Performance✅ Fast (local)✅ Fast (network)✅ Fast (network)
Concurrency⚠️ Limited✅ Excellent✅ Good
Features⚠️ Basic✅ Advanced✅ Good
Portability✅ Single file❌ Server required❌ Server required

Last updated: May 2026