Supported Databases¶
ContextForge supports two database backends: SQLite for development and PostgreSQL for production.
Database Support Matrix¶
| Database | Support Level | Production Ready | Connection String Example | Notes |
|---|---|---|---|---|
| SQLite | β Full | β οΈ Dev only | sqlite:///./mcp.db |
Default, file-based |
| PostgreSQL | β Full | β Yes | postgresql+psycopg://postgres:changeme@localhost:5432/mcp |
Recommended for production |
PostgreSQL Configuration¶
Connection String Format¶
DATABASE_URL=postgresql+psycopg://[username]:[password]@[host]:[port]/[database]
# Examples:
DATABASE_URL=postgresql+psycopg://postgres:changeme@localhost:5432/mcp
DATABASE_URL=postgresql+psycopg://mcpuser:secret123@pg.example.com:5432/mcpgateway
Version Requirements¶
- PostgreSQL: 14+ (recommended)
Driver Requirements¶
The psycopg driver is used for PostgreSQL connections:
Known Limitations¶
General Database Limitations¶
-
SQLite Connection Limits
-
SQLite is limited to 50 connections in pool (vs 200 for other databases)
-
Recommendation: Use PostgreSQL for high-concurrency deployments
-
SQLite Write Concurrency
-
SQLite uses file-level locking, limiting concurrent writes
- Recommendation: Use PostgreSQL for multi-worker or multi-instance deployments
Performance Considerations¶
PostgreSQL Optimization¶
# Recommended connection pool settings for PostgreSQL
DB_POOL_SIZE=200 # Maximum persistent connections
DB_MAX_OVERFLOW=20 # Additional connections beyond pool_size
DB_POOL_TIMEOUT=30 # Seconds to wait for connection
DB_POOL_RECYCLE=3600 # Seconds before recreating connection
Index Optimization¶
PostgreSQL benefits from these additional indexes for large deployments:
-- Recommended indexes for high-performance deployments
CREATE INDEX idx_tools_team_created ON tools(team_id, created_at);
CREATE INDEX idx_resources_owner_uri ON resources(owner_email, uri);
CREATE INDEX idx_prompts_team_name ON prompts(team_id, name);
Migration Between Databases¶
SQLite to PostgreSQL Migration¶
# 1. Export SQLite data
sqlite3 mcp.db .dump > mcp_backup.sql
# 2. Update your DATABASE_URL
DATABASE_URL=postgresql+psycopg://postgres:changeme@localhost:5432/mcp
# 3. Start ContextForge with the new database URL
# The gateway will automatically handle schema creation and migrations
Troubleshooting¶
Common PostgreSQL Issues¶
-
Connection Refused
-
Authentication Failures
-
Permission Denied
Related Documentation¶
- Configuration Reference - Complete database configuration options
- Docker Compose Deployment - PostgreSQL container setup
- Kubernetes Deployment - PostgreSQL in Kubernetes
- Performance Tuning - Database optimization guidelines