sqlite-mcp-server
A read-only MCP server that enables LLMs to safely explore and query any SQLite database via natural language. It exposes tools for listing tables, describing schemas, and executing SELECT/WITH queries with built-in safety guards like write prevention and row limits.
README
SQLite MCP Server
A read-only Model Context Protocol (MCP) server that lets an LLM (like Claude) safely explore and query any SQLite database in natural language.
What is this?
MCP is the open standard that connects LLMs to external tools and data. This server speaks MCP and exposes a SQLite database to any MCP client (Claude Desktop, IDEs, custom agents) through three small, safe tools.
Ask "Which product category generated the most revenue last quarter?" and the model discovers the schema, writes the SQL itself, runs it through this server, and answers — without you writing a single query.
Why it's safe by design
Giving an LLM database access is risky if done naively. This server is read-only on two independent levels:
- The connection is opened with SQLite's
file:...?mode=roURI — the OS-level handle physically cannot write. - Every query is validated to be a single
SELECT/WITHstatement before execution. Writes (INSERT/UPDATE/DELETE/DROP) and multi-statement injections (SELECT 1; DROP TABLE ...) are rejected with a clear error.
Results are also capped (SQLITE_MAX_ROWS, default 100) so a careless SELECT * can't flood the context window.
Tools exposed
| Tool | Description |
|---|---|
list_tables() |
List all user tables. |
describe_table(table) |
Show a table's columns, types and keys. |
read_query(sql, limit) |
Run a read-only SELECT / WITH query and return a Markdown table. |
Plus a schema://database resource exposing the full DDL, so the model can load the whole schema at once.
Architecture
┌────────────────┐ MCP (stdio) ┌──────────────────────┐ read-only ┌────────────┐
│ Claude / MCP │ ◄────────────► │ sqlite-mcp-server │ ◄───────────► │ SQLite DB │
│ client │ tool calls │ list/describe/query │ mode=ro │ (*.db) │
└────────────────┘ └──────────────────────┘ └────────────┘
Quickstart
# 1. Install
git clone https://github.com/helmi75/mcp-sqlite-server.git
cd mcp-sqlite-server
pip install -e .
# 2. Create the demo e-commerce database (customers, products, orders, order_items)
python scripts/seed_db.py
# 3. Run the server (stdio)
python -m sqlite_mcp_server.server
Point it at your own database instead with the SQLITE_DB_PATH environment variable.
Use it with Claude Desktop
Add this to your claude_desktop_config.json (see examples/):
{
"mcpServers": {
"sqlite-explorer": {
"command": "python",
"args": ["-m", "sqlite_mcp_server.server"],
"env": { "SQLITE_DB_PATH": "/absolute/path/to/demo.db" }
}
}
}
Restart Claude Desktop, then try:
- "What tables are in the database?"
- "Show me the schema of the orders table."
- "Top 3 customers by total spend, with their country."
- "Monthly revenue trend for delivered orders."
Configuration
| Variable | Default | Description |
|---|---|---|
SQLITE_DB_PATH |
./demo.db |
Path to the SQLite database to serve. |
SQLITE_MAX_ROWS |
100 |
Maximum rows returned by read_query. |
Testing
pip install -e ".[dev]"
python scripts/seed_db.py
pytest -v
The suite covers schema introspection, query execution, the row limit, and — importantly — that writes and multi-statement injections are rejected at both the SQL-guard and connection levels. CI runs on Python 3.10–3.12 via GitHub Actions.
Project structure
mcp-sqlite-server/
├── src/sqlite_mcp_server/
│ └── server.py # MCP server: tools + read-only safety
├── scripts/seed_db.py # Reproducible demo database
├── tests/test_server.py # Pytest suite (incl. security tests)
├── examples/ # Claude Desktop config
├── .github/workflows/ci.yml # CI: pytest on 3.10–3.12
└── pyproject.toml
Roadmap
- [ ]
EXPLAIN QUERY PLANtool to help the model optimise queries - [ ] Optional per-table allowlist / column masking
- [ ] PostgreSQL backend behind the same interface
License
MIT — see LICENSE.
Built by Helmi Chiha — AI / Backend Engineer (RAG · LLM agents · MCP · FastAPI).
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。