db-mcp is a comprehensive SQLite server for AI-driven database interactions, offering 122 specialized tools across analytics, search, and administration with dual backends and enterprise-grade security.
Database Operations: CRUD operations, schema management, indexing, views, and constraints with 8 core tools
Transaction Support: Full ACID compliance with begin, commit, rollback, and savepoints (7 tools, native backend)
JSON Processing: Full JSON/JSONB manipulation, schema analysis, and operations (23 tools)
Text Processing: Regex, fuzzy matching, phonetic search, and similarity analysis (17 tools)
Full-Text Search: FTS5 with BM25 ranking, search optimization, and index management (4 tools)
Statistical Analysis: Descriptive statistics, percentiles, regression, outlier detection (13-19 tools)
Window Functions: ROW_NUMBER, RANK, LAG/LEAD, running totals, moving averages (6 tools, native only)
Vector/Semantic Search: AI embeddings, cosine similarity, hybrid search (11 tools)
Geospatial Operations: Distance calculations, bounding boxes, SpatiaLite GIS capabilities (4-11 tools, native backend)
Virtual Tables: CSV, R-Tree, series, views, vacuum, and dbstat support (13 tools)
Administration: Backup, restore, PRAGMA operations, transaction management, health monitoring (33 tools)
Security: OAuth 2.1 authentication (RFC 9728/8414 compliant) with granular scope-based authorization (read, write, admin, database-specific, table-specific) and SQL injection prevention
Multiple Backends: WASM (102 tools, cross-platform) or Native (122 tools, full features) SQLite implementations
Tool Filtering: Configure tool sets with presets (starter, analytics, search, spatial, minimal, full) or custom groups to manage AI IDE limits
Resources: Read database metadata through 8 resources (schema, tables, indexes, views, health, configuration, insights)
AI Assistance: 10 prompts for schema explanation, query building, data analysis, optimization, migration scripts, debugging, and documentation
Flexible Deployment: Supports STDIO, HTTP/SSE (stateful/stateless), Docker, Node.js, and direct IDE integration (Cursor)
Extensions: Built-in FTS5, JSON1, R-Tree, plus loadable CSV and SpatiaLite extensions
Performance: Configurable metadata caching with automatic invalidation on DDL operations
Provides database operation tools for connecting to and managing MongoDB databases with support for OAuth 2.0 authentication and granular access control
Provides database operation tools for connecting to and managing MySQL databases with support for OAuth 2.0 authentication and granular access control
Provides database operation tools for connecting to and managing PostgreSQL databases with support for OAuth 2.0 authentication and granular access control
Provides database operation tools for connecting to and managing Redis databases with support for OAuth 2.0 authentication and granular access control
Provides database operation tools for connecting to and managing SQLite databases with support for OAuth 2.0 authentication and granular access control
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@db-mcpshow me the top 10 customers by total orders from the PostgreSQL sales database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
db-mcp (SQLite MCP Server)
Last Updated February 23, 2026
SQLite MCP Server with HTTP/SSE Transport, OAuth 2.1 authentication, smart tool filtering, granular access control, 122 specialized tools, 8 resources, and 10 prompts. Available in WASM and better-sqlite3 variants.
🎯 What Sets Us Apart
Feature | Description |
122 Specialized Tools | The most comprehensive SQLite MCP server available — core CRUD, JSON/JSONB, FTS5 full-text search, statistical analysis, vector search, geospatial/SpatiaLite, and admin |
8 Resources | Schema, tables, indexes, views, health status, database metadata, and business insights — always readable regardless of tool configuration |
10 AI-Powered Prompts | Guided workflows for schema exploration, query building, data analysis, optimization, migration, debugging, and hybrid FTS5 + vector search |
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 + Access Control | Enterprise-ready security with RFC 9728/8414 compliance, granular scopes ( |
Smart Tool Filtering | 7 tool groups + 6 shortcuts let you stay within IDE limits while exposing exactly what you need |
HTTP Streaming Transport | SSE-based streaming with |
Structured Error Handling | Tools return |
Production-Ready Security | SQL injection prevention via parameter binding, input validation, non-root Docker execution, and build provenance |
Strict TypeScript | 100% type-safe codebase with strict mode, no |
MCP 2025-11-25 Compliant | Full protocol support with tool safety hints, resource priorities, and progress notifications |
🚀 Quick Start
Option 1: Docker (Recommended)
Pull and run instantly:
docker pull writenotenow/db-mcp:latestRun with volume mount:
docker run -i --rm \
-v $(pwd):/workspace \
writenotenow/db-mcp:latest \
--sqlite-native /workspace/database.dbOption 2: Node.js Installation
Clone the repository:
git clone https://github.com/neverinfamous/db-mcp.gitNavigate to directory:
cd db-mcpInstall dependencies:
npm installBuild the project:
npm run buildRun the server:
# Native backend (better-sqlite3) - Full features, requires Node.js native build
node dist/cli.js --transport stdio --sqlite-native ./database.db
# WASM backend (sql.js) - Cross-platform, no compilation required
node dist/cli.js --transport stdio --sqlite ./database.dbBackend Choice: Use
--sqlite-nativefor full features (122 tools, transactions, window functions, SpatiaLite). Use--sqlitefor WASM mode (102 tools, no native dependencies).
Verify It Works
node dist/cli.js --transport stdio --sqlite-native :memory:Expected output:
[db-mcp] Starting MCP server...
[db-mcp] Registered adapter: Native SQLite Adapter (better-sqlite3) (sqlite:default)
[db-mcp] Server started successfullyRun the test suite:
npm run test⚡ Install to Cursor IDE
One-Click Installation
Click the button below to install directly into Cursor:
Or copy this deep link:
cursor://anysphere.cursor-deeplink/mcp/install?name=db-mcp-sqlite&config=eyJkYi1tY3Atc3FsaXRlIjp7ImFyZ3MiOlsicnVuIiwiLWkiLCItLXJtIiwiLXYiLCIkKHB3ZCk6L3dvcmtzcGFjZSIsIndyaXRlbm90ZW5vdy9kYi1tY3A6bGF0ZXN0IiwiLS1zcWxpdGUtbmF0aXZlIiwiL3dvcmtzcGFjZS9kYXRhYmFzZS5kYiJdLCJjb21tYW5kIjoiZG9ja2VyIn19Prerequisites
✅ Docker installed and running (for Docker method)
✅ Node.js 24+ (LTS) (for local installation)
🎛️ Tool Filtering
AI-enabled IDEs like Cursor have tool limits. With 122 tools in the native backend, you must use tool filtering to stay within limits. Use shortcuts or specify groups to enable only what you need.
AntiGravity Users: Server instructions are automatically sent to MCP clients during initialization. However, AntiGravity does not currently support MCP server instructions. For optimal usage in AntiGravity, manually provide the contents of
src/constants/ServerInstructions.tsto the agent in your prompt or user rules.
Quick Start: Recommended Configurations
⭐ Recommended: Starter (48 tools)
Core + JSON + Text. Best for general development.
{
"mcpServers": {
"db-mcp-sqlite": {
"command": "node",
"args": [
"C:/path/to/db-mcp/dist/cli.js",
"--transport",
"stdio",
"--sqlite-native",
"C:/path/to/database.db",
"--tool-filter",
"starter"
]
}
}
}Custom Groups
Specify exactly the groups you need:
{
"args": [
"--transport",
"stdio",
"--sqlite-native",
"C:/path/to/database.db",
"--tool-filter",
"core,json,stats"
]
}Shortcuts (Predefined Bundles)
Note: Native includes transactions (7), window functions (6), and SpatiaLite (7) not available in WASM.
Shortcut | WASM | Native | + Built-in | What's Included |
| 48 | 48 | +3 | Core, JSON, Text |
| 44 | 50 | +3 | Core, JSON, Stats |
| 36 | 36 | +3 | Core, Text, Vector |
| 23 | 30 | +3 | Core, Geo, Vector |
| 8 | 8 | +3 | Core only |
| 102 | 122 | +3 | Everything enabled |
Tool Groups (7 Available)
Note: +3 built-in tools (server_info, server_health, list_adapters) are always included.
Group | WASM | Native | + Built-in | Description |
| 8 | 8 | +3 | Basic CRUD, schema, tables |
| 23 | 23 | +3 | JSON/JSONB operations, analysis |
| 13 | 17 | +3 | Text processing + FTS5 + advanced search |
| 13 | 19 | +3 | Statistical analysis (+ window funcs) |
| 11 | 11 | +3 | Embeddings, similarity search |
| 26 | 33 | +3 | Backup, restore, virtual tables, pragma |
| 4 | 11 | +3 | Geospatial + SpatiaLite (Native only) |
Syntax Reference
Prefix | Target | Example | Effect |
(none) | Shortcut |
| Whitelist Mode: Enable ONLY this shortcut |
(none) | Group |
| Whitelist Mode: Enable ONLY this group |
| Group |
| Add tools from this group to current set |
| Group |
| Remove tools in this group from current set |
| Tool |
| Add one specific tool |
| Tool |
| Remove one specific tool |
Examples:
# Use a shortcut
--tool-filter "starter"
# Combine groups (whitelist mode)
--tool-filter "core,json,text,fts5"
# Extend a shortcut
--tool-filter "starter,+stats"
# Exclude from a shortcut
--tool-filter "starter,-fts5"Legacy Syntax (still supported):
If you start with a negative filter (e.g., -vector,-geo), it assumes you want to start with all tools enabled and then subtract.
# Legacy: start with all, exclude some
--tool-filter "-stats,-vector,-geo,-backup,-monitoring,-transactions,-window"� SQLite Extensions
SQLite supports both built-in extensions (compiled into better-sqlite3) and loadable extensions (require separate binaries).
Built-in Extensions (work out of box)
Extension | Purpose | Status |
FTS5 | Full-text search with BM25 ranking | ✅ Always loaded |
JSON1 | JSON functions (json_extract, etc.) | ✅ Always loaded |
R-Tree | Spatial indexing for bounding boxes | ✅ Always loaded |
Loadable Extensions (require installation)
Extension | Purpose | Tools | CLI Flag |
CSV | CSV virtual tables | 2 |
|
SpatiaLite | Advanced GIS capabilities | 7 |
|
Installing Extensions
CSV Extension:
# Download precompiled binary or compile from SQLite source:
# https://www.sqlite.org/csv.html
# Set environment variable:
export CSV_EXTENSION_PATH=/path/to/csv.so # Linux
export CSV_EXTENSION_PATH=/path/to/csv.dll # Windows
# Or use CLI flag:
db-mcp --sqlite-native ./data.db --csvSpatiaLite Extension:
# Linux (apt):
sudo apt install libspatialite-dev
# macOS (Homebrew):
brew install libspatialite
# Windows: Download from https://www.gaia-gis.it/gaia-sins/
# Set environment variable:
export SPATIALITE_PATH=/path/to/mod_spatialite.so
# Or use CLI flag:
db-mcp --sqlite-native ./data.db --spatialiteNote: Extension binaries must match your platform and architecture. The server searches common paths automatically, or use the
CSV_EXTENSION_PATH/SPATIALITE_PATHenvironment variables for custom locations.
📁 Resources (8)
MCP resources provide read-only access to database metadata:
Resource | URI | Description | Min Config |
|
| Full database schema |
|
|
| List all tables |
|
|
| Schema for a specific table |
|
|
| All indexes in the database |
|
|
| All views in the database |
|
|
| Database health and status | (read-only) |
|
| Database metadata and PRAGMAs |
|
|
| Business insights memo (analysis) |
|
Efficiency Tip: Resources are always readable regardless of tool configuration. The "Min Config" column shows the smallest configuration that provides tools to act on what the resource exposes. Use
--tool-filter "core,admin"(~18 tools) instead offull(102+) when you only need resource-related functionality.
💬 Prompts (10)
MCP prompts provide AI-assisted database workflows:
Prompt | Description |
| Explain database structure and relationships |
| Help construct SQL queries for common operations |
| Analyze data patterns and provide insights |
| Analyze and suggest database optimizations |
| Help create database migration scripts |
| Debug SQL queries that aren't working |
| Generate documentation for the database schema |
| Intelligent table analysis and summary |
| Hybrid FTS5 + vector search workflow |
| Interactive demo of MCP capabilities |
⚡ Performance Tuning
Schema metadata is cached to reduce repeated queries during tool/resource invocations.
Variable | Default | Description |
|
| Host/IP to bind to (HTTP transport) |
|
| Cache TTL for schema metadata (milliseconds) |
|
| Log verbosity: |
Tip: Lower
METADATA_CACHE_TTL_MSfor development (e.g.,1000), or increase it for production with stable schemas (e.g.,60000= 1 min). Schema cache is automatically invalidated on DDL operations (CREATE/ALTER/DROP).
📚 MCP Client Configuration
Cursor IDE / Claude Desktop
{
"mcpServers": {
"db-mcp-sqlite": {
"command": "node",
"args": [
"C:/path/to/db-mcp/dist/cli.js",
"--transport",
"stdio",
"--sqlite-native",
"C:/path/to/your/database.db",
"--tool-filter",
"starter"
]
}
}
}Notes:
For WASM backend, replace
--sqlite-nativewith--sqliteFor Linux/macOS, use forward-slash Unix paths (e.g.,
/path/to/db-mcp/dist/cli.js)See Tool Filtering to customize which tools are exposed
Native with Extensions (CSV + SpatiaLite)
{
"mcpServers": {
"db-mcp-sqlite": {
"command": "node",
"args": [
"C:/path/to/db-mcp/dist/cli.js",
"--transport",
"stdio",
"--sqlite-native",
"C:/path/to/database.db",
"--csv",
"--spatialite",
"--tool-filter",
"starter"
],
"env": {
"SPATIALITE_PATH": "C:/path/to/extensions/mod_spatialite.dll"
}
}
}
}Notes:
Extension flags (
--csv,--spatialite) require the native backend (--sqlite-native)Set
CSV_EXTENSION_PATHand/orSPATIALITE_PATHenv vars if extensions are not in standard system pathsFor Linux/macOS, use Unix paths and
.soextensions (e.g.,SPATIALITE_PATH=/usr/lib/x86_64-linux-gnu/mod_spatialite.so)
Docker
{
"mcpServers": {
"db-mcp-sqlite": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"/path/to/project:/workspace",
"writenotenow/db-mcp:latest",
"--sqlite-native",
"/workspace/database.db"
]
}
}
}In-Memory Database
Use :memory: for a temporary in-memory database:
{
"args": ["--transport", "stdio", "--sqlite-native", ":memory:"]
}HTTP/SSE Transport (Remote Access)
For remote access, web-based clients, or MCP Inspector testing, run the server in HTTP mode:
node dist/cli.js --transport http --port 3000 --server-host 0.0.0.0 --sqlite-native ./database.dbEndpoints:
Endpoint | Description |
| Server info and available endpoints |
| JSON-RPC requests (initialize, tools/call) |
| SSE stream for server-to-client notifications |
| Session termination |
| Health check (always public) |
Session Management: The server uses stateful sessions by default. Include the mcp-session-id header (returned from initialization) in subsequent requests for session continuity.
Stateless Mode (Serverless)
For serverless deployments (AWS Lambda, Cloudflare Workers, Vercel), use stateless mode:
node dist/cli.js --transport http --port 3000 --server-host 0.0.0.0 --stateless --sqlite-native :memory:Mode | Progress Notifications | SSE Streaming | Serverless |
Stateful (default) | ✅ Yes | ✅ Yes | ⚠️ Complex |
Stateless ( | ❌ No | ❌ No | ✅ Native |
🔐 OAuth 2.1 Implementation
Component | Status | Description |
Protected Resource Metadata | ✅ | RFC 9728 |
Auth Server Discovery | ✅ | RFC 8414 metadata discovery with caching |
Token Validation | ✅ | JWT validation with JWKS support |
Scope Enforcement | ✅ | Granular |
HTTP Transport | ✅ | Streamable HTTP with OAuth middleware |
Supported Scopes
Scope | Description |
| Read-only access to all databases |
| Read and write access to all databases |
| Full administrative access |
| Access to specific database only |
| Access to specific table only |
Keycloak Integration
See docs/KEYCLOAK_SETUP.md for setting up Keycloak as your OAuth provider.
Quick Start with OAuth
1. Start the server with OAuth enabled:
# Set environment variables
export KEYCLOAK_URL=http://localhost:8080
export KEYCLOAK_REALM=db-mcp
export KEYCLOAK_CLIENT_ID=db-mcp-server
# Start server with HTTP transport and OAuth
node dist/cli.js --transport http --port 3000 --server-host 0.0.0.0 --sqlite-native ./database.db2. Get an access token from Keycloak:
# Using cURL
curl -X POST "http://localhost:8080/realms/db-mcp/protocol/openid-connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=db-mcp-server" \
-d "client_secret=YOUR_SECRET" \
-d "username=testuser" \
-d "password=YOUR_PASSWORD" \
-d "grant_type=password" \
-d "scope=openid read write"3. Make authenticated MCP requests:
# Initialize session with Bearer token
curl -X POST "http://localhost:3000/mcp" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{}},"id":1}'Note: OAuth is automatically enabled when running in HTTP mode with OAuth environment variables configured. The
/.well-known/oauth-protected-resourceendpoint provides RFC 9728 metadata for client discovery.
Configuration files: Copy
.env.examplefor a quick-start template. Seeconfig/db-mcp.keycloak.jsonfor a complete Keycloak configuration example.
Contributing
Contributions are welcome! Please read our Contributing Guidelines before submitting a pull request.
Security
For security concerns, please see our Security Policy.
⚠️ Never commit credentials - Store secrets in
.env(gitignored)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Code of Conduct
Please read our Code of Conduct before participating in this project.