Overview
n8n-MCP uses SQLite to store node documentation, properties, operations, and workflow templates. The database supports two adapters for maximum compatibility across environments.Database Architecture
Schema Overview
The database contains:- nodes table - 1,084 nodes (537 core + 547 community)
- node_versions table - Version tracking and migration detection
- templates table - 2,709 workflow templates
- template_node_configs table - 2,646 pre-extracted configurations
- workflow_versions table - Rollback and version history
- FTS5 indexes - Full-text search capabilities
Database Size
- Typical size: ~70MB (includes templates and community nodes)
- Location: Configurable via
NODE_DB_PATH - Format: SQLite 3 with FTS5 extension
Database Adapters
n8n-MCP supports two SQLite adapters with automatic fallback:better-sqlite3 (Default)
Native C++ bindings for best performancePerformance
Direct disk I/O with native bindings
Memory
~100-120 MB stable usage
Compatibility
Requires compatible Node.js version
Features
Full FTS5, WAL mode, transactions
- Direct disk writes (no memory overhead)
- Fastest query performance (~12ms average)
- Enabled by default in Docker images (v2.20.2+)
- Automatic compilation for your Node.js version
sql.js (Fallback)
Pure JavaScript implementationCompatibility
Works on any Node.js version
Memory
~150-200 MB stable usage
Persistence
Periodic saves to disk
Features
Most SQLite features (no FTS5)
- In-memory database with periodic saves
- Used when better-sqlite3 compilation fails
- Automatic memory management
- Configurable save interval
Automatic Adapter Selection
The adapter is selected automatically:database-adapter.ts
Configuration
Database Path
Path to the SQLite database file. Must end with
.db.Examples:Rebuild on Start
Rebuild database on server startup.When to enable:
- After n8n version upgrades
- Testing database changes
- CI/CD environments
sql.js Save Interval
Save interval for sql.js adapter (milliseconds).Range: 100-60000ms (1 minute max)Tradeoffs:
- Lower values = more frequent saves = higher memory churn
- Higher values = less frequent saves = lower memory usage
Memory Optimization
better-sqlite3 Memory Usage
- Direct disk I/O (no memory buffering)
- Memory-mapped file I/O
- Automatic memory management
- No configuration needed
sql.js Memory Usage
- Increase Save Interval
- Docker Configuration
- Memory Monitoring
Reduce save frequency for lower memory churn:
Data Loss Considerations
sql.js data loss window: Up to 5 seconds (default) of database changes may be lost if the process crashes before the save timer fires.This is acceptable because:
close()saves immediately on graceful shutdown- Docker/Kubernetes SIGTERM provides 30s for cleanup
- MCP server is primarily read-heavy (writes are rare)
- The alternative (100ms interval) caused 2.2GB memory leaks in production
Database Maintenance
Rebuilding the Database
- npm
- Docker
- Production
Database Validation
Backup Strategy
Performance Tuning
Query Performance
Average Query
~12ms response time
Full-Text Search
~20-30ms with FTS5
Template Search
~15-25ms with caching
Node Info
~5-10ms (cached)
FTS5 Full-Text Search
better-sqlite3 supports FTS5 for fast full-text search:schema.sql
sql.js does not support FTS5. Searches will use standard SQL LIKE queries with reduced performance.
Indexing Strategy
Optimized indexes for common queries:Troubleshooting
Adapter Selection Issues
Module Version Mismatch
Module Version Mismatch
Symptom:
NODE_MODULE_VERSION mismatch errorsCause: better-sqlite3 compiled for different Node.js versionSolution: Automatic fallback to sql.js - no action neededForce Adapter Selection
Force Adapter Selection
Force better-sqlite3:Note: Will fail if compilation incompatible
Check Active Adapter
Check Active Adapter
Look for log messages:
Database Corruption
Memory Issues
- sql.js High Memory
- Monitor Memory
- Switch Adapters
Increase save interval:
Performance Degradation
Slow Queries
Slow Queries
Check for missing indexes:
Database Fragmentation
Database Fragmentation
Vacuum the database:
Rebuild Database
Rebuild Database
Next Steps
Environment Variables
All configuration options
Performance
Performance optimization guide
Troubleshooting
Database troubleshooting
API Reference
Database API documentation