SQLite Read-Only MCP Server

SQLite Read-Only MCP Server

Enables safe, read-only SQL access to SQLite databases for AI agents, allowing schema exploration and SELECT queries with defense-in-depth protections.

Category
Visit Server

README

MCP Server for SQLite (read-only) — safe SQL for your AI agent

tests python MCP license

A small, production-minded MCP server (Model Context Protocol) that gives an AI agent — Claude Desktop, Claude Code, or any MCP client — safe, read-only SQL access to a SQLite database. Point it at a .db file and the agent can explore schemas and run SELECT queries — but never write, drop, or escape the database.

Built on the official MCP Python SDK (FastMCP). The read-only safety core has zero MCP dependency and is unit-tested on its own — the server is a thin, auditable wrapper.

Why read-only matters

Handing an LLM a raw database connection is how you get a DROP TABLE in production. This server enforces read-only at two independent layers:

  1. OS-level — the connection is opened with SQLite ?mode=ro + PRAGMA query_only, so any write fails at the engine.
  2. Statement-levelquery rejects anything that isn't a single SELECT/WITH (no multi-statements, no INSERT/UPDATE/DELETE/DROP/PRAGMA writes), and caps row counts.

Defense in depth: even if one layer is bypassed, the other still holds. (There's a test that proves it.)

What the agent gets (all 3 MCP primitives)

Primitive Name Does
🔧 tool list_tables List the tables in the database
🔧 tool describe_table Column schema (name, type, nullability, PK)
🔧 tool query Run a single read-only SELECT/WITH, capped at max_rows
📄 resource schema://tables The whole DB schema as text
💬 prompt explore_database A ready-made "explore this DB" prompt

Quick start (≈ 1 minute)

git clone https://github.com/skycandykey1/mcp-sqlite-server
cd mcp-sqlite-server
pip install -r requirements.txt

# make a sample DB to play with
python examples/make_sample_db.py

# inspect it live in the MCP dev inspector
SQLITE_DB_PATH=examples/sample.db mcp dev mcp_sqlite/server.py
# ...or run the server directly
SQLITE_DB_PATH=examples/sample.db python -m mcp_sqlite.server

Use it from Claude Desktop

Add this to your Claude Desktop config (Settings → Developer → Edit Config), using absolute paths — see examples/claude_desktop_config.example.json:

{
  "mcpServers": {
    "sqlite-readonly": {
      "command": "python",
      "args": ["-m", "mcp_sqlite.server"],
      "cwd": "/absolute/path/to/mcp-sqlite-server",
      "env": { "SQLITE_DB_PATH": "/absolute/path/to/your.db" }
    }
  }
}

Restart Claude Desktop, then ask: "What tables are in my database? Show me the top 5 orders by amount."

How it fits together

  MCP client (Claude Desktop / Claude Code)
            │  MCP over stdio
            ▼
  mcp_sqlite/server.py   ← thin FastMCP wrapper (tools / resource / prompt)
            │
            ▼
  mcp_sqlite/db.py       ← read-only core (no MCP dep, fully unit-tested)
            │  ?mode=ro + query_only + SELECT-only guard
            ▼
        your .db  (read-only)

Run the tests

pip install -r requirements-dev.txt
python -m pytest -q       # offline — no MCP client, no API key needed

License

MIT — see LICENSE.


💼 Built by skycandykey1 — available for AI agent & automation contract work. I build agents, MCP servers, and LLM automation. → skycandykey456@gmail.com · https://github.com/skycandykey1

<!-- After publishing (SEO): About: "Read-only SQLite MCP server (Model Context Protocol) — safe SQL access for AI agents" Topics (≥5): mcp, mcp-server, model-context-protocol, sqlite, claude, anthropic, ai-agent, python Add a social preview image. Pin this repo on your profile, next to ai-agent-starter. -->

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured