fastmcp-sqlite
Production-grade, token-optimized FastMCP SQLite Server with sub-millisecond O(1) schema discovery, opcode execution watchdog, and fuzzy self-healing.
Install / Use
claude mcp add kenb38291-tech -- npx -y github:kenb38291-tech/fastmcp-sqliteIf the server publishes to npm under a different name, use that package instead — check the repo README.
MCP Server
Model Context Protocol server
Quality Score
Category
AI & Machine LearningSupported Platforms
Skill content
View source on GitHubfastmcp-sqlite
A High-Performance, Token-Optimized SQLite Model Context Protocol (MCP) Server Built for AI Coding Agents.
Zero Native Build Toolchain · Sub-15ms Cold Start · Prompt Cache Prefix Stability (>97%) · VDBE Opcode Watchdog · Fast Non-Blocking Schema Discovery
Overview and Design Principles
Many SQLite Model Context Protocol (MCP) servers in the ecosystem rely on Node.js native addons (better-sqlite3) or unbounded serialization formats, introducing distinct operational challenges in autonomous AI agent environments:
- Native Build Toolchain Overhead: Relying on
node-gypor platform-specific C++ build toolchains (such as MSVC on Windows) introduces installation friction in minimal container environments, restricted CI/CD runners, and locked-down developer workstations. - Context Token Inefficiency: Formatting query results as verbose JSON object arrays repeats schema keys for every record, consuming 2.2x to 3.7x more context tokens than compact tabular representations.
- Prompt Cache Invalidation: Injecting dynamic execution timestamps or metrics into response headers alters the message prefix, preventing KV-cache reuse on Claude, GPT-4o, and Gemini architectures.
- Unbounded Query Execution: Executing full
SELECT COUNT(*)table scans on multi-gigabyte databases creates prolonged disk read locks, while unconstrained recursive Common Table Expressions (WITH RECURSIVE) or Cartesian joins can stall agent stdio subprocesses.
fastmcp-sqlite addresses these challenges through a lightweight, standard-library architecture:
- Zero Native Build Dependencies: Pure Python implementation using the standard library
sqlite3and the officialmcpSDK, eliminating C/C++ compilation requirements. - Non-Blocking Schema Probing: Inspects
sqlite_stat1and performs rightmost Table B-Tree leaf seeks (MAX(_rowid_)) in $O(\log N)$ time, avoiding sequential disk scans. - VDBE Opcode Watchdog: Employs SQLite's
sqlite3_progress_handlerbytecode instruction counter to halt runaway recursive queries within milliseconds without freezing the agent process. - Prefix-Stable Serialization: Relocates execution timing metrics strictly to response footers, preserving >97% byte invariance across schema inspections for prompt cache retention.
- Token-Budgeted Serialization: Provides compact GitHub-flavored Markdown tables, vertical record inspection for wide schemas, 200-character cell truncation, and a 24KB UTF-8 payload ceiling.
┌─── MODEL CONTEXT PROTOCOL: INTERACTION TRACE ─────────────────────────────────────────────┐
│ │
│ 🤖 AI AGENT (Claude / Cursor / Antigravity / Windsurf / Cline) │
│ └─▶ Tool Call: schema(db="production.db") │
│ │
│ ⚡ fastmcp-sqlite Engine (Non-Blocking B-Tree Leaf Probe: 0.82 ms) │
│ ┌────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ # SQLite Schema Overview: production.db (400 MB, WAL Mode, 256MB MMAP) │ │
│ │ | Table Name | Type | Columns | Est. Rows | Primary Key | Foreign Keys | │
│ │ | :--------- | :---- | :-----: | :---------- | :---------- | :-------------------- | │
│ │ | `users` | table | 12 | ~2,500,000 | id (INTEGER)| None | │
│ │ | `events` | table | 8 | ~2,070,000 | id (INTEGER)| `user_id` -> users.id | │
│ │ *Discovery Latency: 0.82 ms (B-Tree Leaf Probe: MAX(_rowid_) | 12 Shadows Hidden)* │ │
│ └────────────────────────────────────────────────────────────────────────────────────┘ │
│ │
│ 🤖 AI AGENT (Typo in SQL Query: `SELECT user_nam FROM users`) │
│ └─▶ Tool Call: query(sql="SELECT user_nam FROM users") │
│ │
│ 💡 Schema Diagnostics (<1.2 ms via difflib) │
│ ┌────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ SQLite OperationalError: no such column: user_nam │ │
│ │ └─ Suggestion: Column 'user_nam' does not exist. Did you mean: `username`? │ │
│ └────────────────────────────────────────────────────────────────────────────────────┘ │
│ │
│ 🤖 AI AGENT (Runaway Accidental Cartesian / Recursive CTE Query) │
│ └─▶ Tool Call: query(sql="WITH RECURSIVE loop(n) AS (SELECT 1 UNION ALL...)") │
│ │
│ 🛑 VDBE Opcode Watchdog Interruption (3.6 ms) │
│ ┌────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ OperationalError: Query execution aborted by watchdog: exceeded 1,000,000 opcodes. │ │
│ │ └─ Execution halted gracefully · Zero process hang · Transaction rolled back │ │
│ └────────────────────────────────────────────────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────┘
Quickstart
fastmcp-sqlite runs as a headless standard I/O (stdio) JSON-RPC Model Context Protocol server directly managed by your AI coding assistant (Claude Desktop, Cursor, Antigravity, Windsurf, Cline).
Run instantly with uvx (Recommended)
Execute with uvx without pre-installing dependencies:
# Start with a specific SQLite database (read-only by default)
uvx fastmcp-sqlite --db /path/to/database.db
# Enable write operations (INSERT, UPDATE, DELETE, CREATE, DROP)
uvx fastmcp-sqlite --db /path/to/database.db --allow-write
# Load SQLite extensions (e.g. sqlite-vec) with automatic post-init security lockdown
uvx fastmcp-sqlite --db /path/to/database.db --extension /path/to/vec0.so --allow-write
[!NOTE] When executed directly in a terminal,
fastmcp-sqlitelistens quietly onstdiofor JSON-RPC messages from MCP clients. To interactively inspect and test tools in a visual browser UI, launch with the MCP Inspector:npx @modelcontextprotocol/inspector uvx fastmcp-sqlite --db /path/to/database.db
Or install via pip / pipx:
pip install fastmcp-sqlite
fastmcp-sqlite --db /path/to/database.db --allow-write
🤖 1-Prompt AI Agent Bootstrapper
If you are using Claude Code, Cursor, Google Antigravity, Windsurf, or Cline, copy and paste this single prompt into your chat window to let your agent configure and verify fastmcp-sqlite automatically:
Please inspect my workspace for any SQLite database files (*.db, *.sqlite, *.sqlite3). Once located, configure fastmcp-sqlite in our MCP configuration file (e.g. .cursor/mcp.json, claude_desktop_config.json, or mcp_config.json) using command 'uvx' and args ['fastmcp-sqlite', '--db', '<ABSOLUTE_OR_WORKSPACE_PATH>', '--allow-write']. Then call the 'schema' tool to verify connectivity and show me an overview of the tables.
Multi-Agent Client Configuration
Connect fastmcp-sqlite to your AI coding assistant using the configuration blocks below:
<details open> <summary><strong>Claude Desktop (<code>claude_desktop_config.json</code>)</strong></summary>[!IMPORTANT] Windows Path Formatting: In JSON configuration files on Windows, use forward slashes (e.g.,
"C:/path/to/database.db") or escaped backslashes ("C:\\path\\to\\database.db").
Path Resolution: Providing an absolute path guarantees reliable database resolution across all client environments.
Configuration file location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json(or via Claude Settings → Developer → Edit Config) - Linux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"sqlite": {
"command": "uvx",
"args": ["fastmcp-sqlite", "--db", "/absolute/path/to/database.db", "--allow-write"]
}
}
}
</details> <details> <summary><strong>Cursor IDE (<code>.cursor/mcp.json</code>)</strong></summary>[!TIP] Windows Store / MSIX Virtualization Note: If Claude Desktop was installed via the Windows Store package, Windows may virtualize the configuration path to
%LOCALAPPDATA%\Packages\Claude_pzs8sxrjxfjjc\LocalCache\Roaming\Claude\claude_desktop_config.json. Opening the file via Claude Settings → Developer → Edit Config always opens the active configuration.
Add to your project root .cursor/mcp.json or configure under Cursor Settings → Features → MCP:
{
"mcpServers": {
"sqlite": {
"command": "uvx",
"args": ["fastmcp-sqlite", "--db", "/absolute/path/t
Truncated for display — read the full file on GitHub.
Related Skills
claude-mem
93.3kPersistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
Understand-Anything
81.6kGraphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
Agent-Reach
78.2kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
ruflo
70.6k🌊 The original agent meta-harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
