Skip to content
Chris edited this page Jun 6, 2026 · 12 revisions

SQLite MCP Server Wiki

Status: Production/Stable

GitHub GitHub Release npm Docker Pulls License: MIT Status


πŸ€– Can't find what you're looking for? Try our AI-Powered Wiki Search β€” Ask questions in natural language and get instant answers with source attribution.


πŸ” Overview

The db-mcp SQLite MCP Server enables AI assistants (AntiGravity, Claude, Cursor, etc.) to interact with SQLite databases through the Model Context Protocol. It features 181 native / 154 WASM specialized tools, dual SQLite backends (WASM and Native), Code Mode for token efficiency, deterministic error handling, dual HTTP transport (Streamable HTTP + legacy SSE), OAuth 2.1 authentication, flexible tool filtering, audit logging with DDL backup snapshots, and support for SQLite extensions including FTS5, SpatiaLite, and CSV virtual tables.


πŸ“‹ Wiki Navigation

πŸš€ Getting Started

  • Quick Start β€” Installation, configuration, and first queries
  • HTTP Transport β€” Streamable HTTP and legacy SSE endpoints for remote access
  • Tool Filtering β€” Stay within AI IDE tool limits with shortcuts and group filters
  • Code Mode β€” 70–90% token reduction via sandboxed JavaScript execution
  • Tool Reference β€” Complete reference of all tools organized by group

πŸ”Œ SQLite

  • Extensions β€” Built-in and loadable SQLite extensions (FTS5, SpatiaLite, CSV)

πŸ€– AI Integration

πŸ” Enterprise Features

πŸ—οΈ Architecture

The codebase is organized into modular components under src/:

  • adapters/ β€” SQLite specific logic, implementing both Native (better-sqlite3) and WASM (sql.js) backends, plus prompt and resource handlers.
  • audit/ β€” Audit types and constants.
  • auth/ β€” OAuth 2.1 implementation and granular scope enforcement.
  • cli.ts β€” CLI argument parsing, server bootstrap, and entry point.
  • codemode/ β€” Code Mode API constants and V8 isolate sandbox runtime.
  • constants/ β€” System-wide configurations and limits.
  • filtering/ β€” Tool filtering logic, dynamic group selection, and configuration.
  • observability/ β€” JSONL audit logging, pre-mutation DDL snapshots, and Prometheus metrics.
  • server/ β€” Core MCP server implementation, tool registration, and resource subscription management.
  • transports/ β€” HTTP (Streamable + SSE) and standard Stdio transport layers.
  • types/ β€” Core type definitions.
  • utils/ β€” Core utilities including cache management.
  • index.ts β€” Package exports and entry point.
  • version.ts β€” Package version.

🎯 What Sets Us Apart

Feature Description
Code Mode (V8 Isolate) Massive Token Savings: Execute complex, multi-step operations inside a secure V8 isolate with process-level isolation and hard timeouts. Stop burning tokens on back-and-forth tool calls β€” reduce AI overhead by 70–90%.
Deterministic Error Handling No more cryptic SQLite error codes. Every tool returns structured {success, error, code, category, suggestion, recoverable} responses with actionable remediation so agents recover without guessing.
181 Token-Optimized Tools The most comprehensive SQLite MCP server available. Every response includes _meta.tokenEstimate and tools support compact, nodesOnly, maxOutliers parameters β€” letting agents control payload size.
Dual SQLite Backends WASM (sql.js) for zero-compilation portability, Native (better-sqlite3) for full features including transactions, window functions, and SpatiaLite GIS.
OAuth 2.1 + Granular Control Enterprise-ready security with RFC 9728/8414 compliance, granular scopes (full, read, write, admin), and Keycloak integration.
Audit Trails & DDL Snapshots Track what AI is doing with JSONL logs, automatically snapshot schemas before destructive operations, and review diffs before restoring.
Observability & Metrics Expose Prometheus metrics at /metrics and persist a structured system.db sidecar for telemetry across server restarts.
Resources & Prompts Agents automatically read real-time schema, health, and configuration metadata. Built-in prompt workflows guide schema exploration, query building, optimization, and migration.
Smart Tool Filtering 10 tool groups + 7 shortcuts let you stay within IDE limits while exposing exactly what you need. Code Mode provides access to all tools through a single endpoint.
Enterprise Infrastructure SQL injection protection, sandboxed code execution, CORS deny-all default, fail-closed scope enforcement, 7 security headers, rate limiting, slowloris timeouts, non-root Docker, and build provenance.

Backend Options

Feature WASM (sql.js) Native (better-sqlite3)
Transactions ❌ βœ… 8 tools
Window Functions ❌ βœ… 6 tools
SpatiaLite GIS ❌ βœ… 7 tools
FTS5 ❌ βœ… 5 tools
Cross-platform βœ… Pure JavaScript Compiled natively
Performance ⚠️ Synchronous (blocks loop) πŸš€ High-performance, concurrent

Backend Choice: Use --sqlite-native for full features (transactions, window functions, SpatiaLite). Use --sqlite for WASM mode (zero native dependencies, cross-platform). See Quick Start for configuration.

Tool Groups

Group WASM Native Description
core 25 25 Basic CRUD, schema, tables
json 25 25 JSON/JSONB operations, analysis
text 15 20 Text processing + FTS5 + advanced search
stats 17 23 Descriptive, inference, window functions
vector 11 11 Vector storage, similarity search
admin 30 31 DB maintenance, backup, virtual tables
transactions 0 8 Commit, rollback, savepoints (Native only)
geo 4 11 Geospatial + SpatiaLite (Native only)
introspection 10 10 Schema mapping, FK graph, analysis
migration 6 6 Schema migration tracking (opt-in)

+4 built-in tools (server_info, server_health, list_adapters, sqlite_execute_code) are injected into every group. See Tool Reference for the complete inventory.


πŸŽ›οΈ Quick Start: Tool Filtering

AI IDEs have tool limits. Use Code Mode to bypass limits entirely:

# Recommended (access all tools via sandbox)
--tool-filter codemode

# Combine specific groups
--tool-filter core,json,stats

See Tool Filtering for all customization options.


πŸ› οΈ Development

After cloning the repository:

pnpm install                 # Install dependencies
pnpm run check               # Lint + TypeScript strict-mode
pnpm run bench               # Run performance benchmarks
pnpm test                    # Run full test suite

Benchmarks

The project includes a performance benchmark suite powered by Vitest Bench. Benchmarks cover handler dispatch, identifier sanitization, auth middleware, schema parsing, Code Mode, logging, and more.

pnpm run bench           # Standard output
pnpm run bench:verbose   # Detailed table output

πŸ“š Additional Resources

Clone this wiki locally