Skip to main content
Glama
moaaz01

MCP SQLite Server

by moaaz01

๐Ÿ—„๏ธ MCP SQLite Server

Query, explore, and manage SQLite databases through the Model Context Protocol. Connect any MCP-compatible AI client to your databases โ€” Claude Desktop, Cursor, VS Code, and more.

License: MIT Python 3.10+


โœจ Features

  • ๐Ÿ” 3 Tools: query, execute, list_tables โ€” full database interaction

  • ๐Ÿ“„ 2+ Resources: sqlite://tables (full schema), sqlite://{table}/schema (per-table)

  • ๐Ÿ’ฌ 1 Prompt: database_analyst(question) โ€” guided analysis workflow

  • ๐Ÿ”’ Security-First: Read-only by default, explicit --allow-write flag for mutations

  • ๐Ÿ“Š WAL Mode: Write-Ahead Logging for better concurrent access

  • ๐Ÿ–ฅ๏ธ Dual Transport: stdio (local) and Streamable HTTP (remote)

  • ๐ŸŽฒ Sample Data: Seed script included for instant testing


Related MCP server: SQLite MCP Server

๐Ÿš€ Quick Start

# 1. Setup
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# 2. Create sample database
python seed_data.py --db-path /tmp/sample.db

# 3. Start server (read-only mode)
python sqlite_server.py --db-path /tmp/sample.db

๐Ÿ› ๏ธ Tools

query(sql: str) -> str

Execute a SELECT query. Only SELECT and PRAGMA statements are allowed.

Example: query("SELECT name, price FROM products WHERE category = 'Electronics'")

execute(sql: str) -> str

Run INSERT, UPDATE, or DELETE. Requires --allow-write flag.

Example (with --allow-write):
  execute("INSERT INTO products (name, price, category, stock) VALUES ('Webcam 4K', 129.99, 'Electronics', 50)")

list_tables() -> str

List all tables with row counts.


๐Ÿ”’ Security Model

Feature

Default

With --allow-write

SELECT/PRAGMA queries

โœ… Allowed

โœ… Allowed

INSERT/UPDATE/DELETE

โŒ Blocked

โœ… Allowed

DROP/ALTER/CREATE

โŒ Blocked

โŒ Blocked

Row factory protection

โœ… Enabled

โœ… Enabled

โš ๏ธ Production tip: Always use read-only mode for public-facing or shared databases. Only enable --allow-write in trusted environments.


๐Ÿ“„ Resources

sqlite://tables

Returns complete database schema with column types, nullability, defaults, and primary keys.

sqlite://{table}/schema

Returns schema for a specific table.


๐Ÿ’ฌ Prompts

database_analyst(query_question: str)

Creates a structured prompt for analyzing database data.


๐Ÿ”Œ Connecting to Clients

Claude Desktop

{
  "mcpServers": {
    "sqlite": {
      "command": "python",
      "args": ["/ABSOLUTE/PATH/mcp-sqlite-server/sqlite_server.py", "--db-path", "/tmp/sample.db"]
    }
  }
}

Cursor

Settings โ†’ Features โ†’ MCP โ†’ Add Server:

  • Name: sqlite

  • Type: command

  • Command: python /ABSOLUTE/PATH/mcp-sqlite-server/sqlite_server.py --db-path /tmp/sample.db


๐Ÿ“ Project Structure

mcp-sqlite-server/
โ”œโ”€โ”€ sqlite_server.py      # Main server (FastMCP)
โ”œโ”€โ”€ seed_data.py          # Sample database creator
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ setup.sh
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ .gitignore

๐Ÿ“œ License

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server implementation that enables AI assistants to execute SQL queries and interact with SQLite databases through a structured interface.
    7
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to interact with SQLite databases by executing read and write queries, listing tables, and inspecting schemas. It provides a secure, local interface for database management and data retrieval through the Model Context Protocol.
    2
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to connect to and query an SQLite database through the Model Context Protocol, allowing natural language interaction with database tables and data.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    MCP server that provides SQLite database operations. Allows AI assistants to query, modify and manage SQLite databases through the Model Context Protocol.
    -