Runs on Node.js runtime with platform-specific configuration options for different operating systems.
Enables SQL operations on SQLite-compatible databases with full query capabilities, table management, and schema inspection.
Supports authenticated connections to Turso cloud databases, with comprehensive SQL operations, transaction support, and secure token handling.
MCP libSQL by xexr
A Model Context Protocol (MCP) server for libSQL database operations, providing secure database access through Claude Desktop, Claude Code, Cursor, and other MCP-compatible clients.
Runs on Node, written in TypeScript
🔧 Quick Start
Install:
pnpm install -g @xexr/mcp-libsqlTest locally:
mcp-libsql --url file:///tmp/test.db --log-mode consoleConfigure Claude Desktop with your Node.js path and database URL (see configuration examples below)
🚀 Status
✅ Complete database management capabilities - All 6 core tools implemented and tested
✅ Comprehensive security validation - 67 security tests covering all injection vectors
✅ Extensive test coverage - 244 total tests (177 unit + 67 security) with 100% pass rate
✅ Production deployment verified - Successfully working with MCP clients
✅ Robust error handling - Connection retry, graceful degradation, and audit logging
🛠️ Features
Available Tools
read-query: Execute SELECT queries with comprehensive security validation
write-query: INSERT/UPDATE/DELETE operations with transaction support
create-table: DDL operations for table creation with security measures
alter-table: Table structure modifications (ADD/RENAME/DROP operations)
list-tables: Database metadata browsing with filtering options
describe-table: Table schema inspection with multiple output formats
Security & Reliability
Multi-layer SQL injection prevention with comprehensive security validation
Connection pooling with health monitoring and automatic retry logic
Transaction support with automatic rollback on errors
Comprehensive audit logging for security compliance
🔐 Security details: See docs/SECURITY.md for comprehensive security features and testing.
Developer Experience
Beautiful table formatting with proper alignment and NULL handling
Performance metrics displayed for all operations
Clear error messages with actionable context
Parameterized query support for safe data handling
Development mode with enhanced logging and hot reload
📋 Prerequisites
Node.js 20+
pnpm (or npm) package manager
libSQL database (file-based or remote)
Claude Desktop (for MCP integration)
Platform Requirements
macOS: Native Node.js installation
Linux: Native Node.js installation
Windows: Native Node.js installation or WSL2 with Node.js installation
🔧 Installation
🚀 Usage
Local Testing
Global installation assumed below, replace "mcp-libsql" with "node dist/index.js" if using local build
Claude Desktop Integration
Configure the MCP server in Claude Desktop based on your operating system:
macOS Configuration
Create configuration file at
~/Library/Application Support/Claude/claude_desktop_config.json
:
Global install
Alternative configuration for local build installation:
Alternative configuration for global install using nvm lts for node
Important: The global installation method is recommended as it handles PATH automatically.
Linux Configuration
Create configuration file at
~/.config/Claude/claude_desktop_config.json
:
Global install
Alternative configuration for local build installation:
Windows (WSL2) Configuration
Create configuration file at
%APPDATA%\Claude\claude_desktop_config.json
:
Global install
Alternative configuration for local build installation:
Alternative configuration for global install using nvm for node
Important: Use wsl.exe -e
(not just wsl.exe
) to ensure proper command handling and avoid issues with server command reception on Windows.
Database Authentication
For Turso (and other credentialed) databases, you'll need an authentication token. There are two secure ways to provide it:
Global installation shown below, adjust accordingly for your setup
Method 1: Environment Variable (Recommended)
Configure Claude Desktop with environment variable (macOS/Linux example):
Method 2: CLI Parameter
Getting Your Turso Auth Token
Install Turso CLI:
curl -sSfL https://get.tur.so/install.sh | bashLogin to Turso:
turso auth loginCreate an auth token:
turso auth token create --name "mcp-libsql"Get your database URL:
turso db show your-database-name --url
Security Best Practices
Environment variables are safer than CLI parameters (tokens won't appear in process lists)
MCP config files may contain tokens - ensure they're not committed to version control
Consider using external secret management for production environments
Use scoped tokens with minimal required permissions
Rotate tokens regularly for enhanced security
Monitor token usage through Turso dashboard
Example: Complete Turso Setup
Create and configure database:
# Create database turso db create my-app-db # Get database URL turso db show my-app-db --url # Output: libsql://my-app-db-username.turso.io # Create auth token turso auth token create --name "mcp-libsql-token" # Output: your-long-auth-token-stringConfigure Claude Desktop:
export LIBSQL_AUTH_TOKEN="your-turso-auth-token-here"{ "mcpServers": { "mcp-libsql": { "command": "mcp-libsql", "args": [ "--url", "libsql://my-app-db-username.turso.io" ] } } }Test the connection:
# Test locally first mcp-libsql --url "libsql://my-app-db-username.turso.io" --log-mode console
Configuration Notes
File paths: Use absolute paths to avoid path resolution issues
Database URLs:
File databases:
file:///absolute/path/to/database.db
HTTP databases:
http://hostname:port
libSQL/Turso:
libsql://your-database.turso.io
Node.js path: Use
which node
to find your Node.js installation pathWorking directory: Set
cwd
to ensure relative paths work correctlyAuthentication: For Turso databases, use environment variables for secure token handling
Logging modes:
Default
file
mode prevents JSON parsing errors in MCP protocolUse
--log-mode console
for development debuggingUse
--log-mode both
for comprehensive loggingUse
--log-mode none
to disable all logging
Restart Claude Desktop completely after updating the configuration
Test the integration by asking Claude to run SQL queries:
Can you run this SQL query: SELECT 1 as test
📋 Available Tools
read-query - Execute SELECT queries with security validation
write-query - INSERT/UPDATE/DELETE with transaction support
create-table - CREATE TABLE with DDL security
alter-table - Modify table structure (ADD/RENAME/DROP)
list-tables - Browse database metadata and objects
describe-table - Inspect table schema and structure
📖 Detailed API documentation: See docs/API.md for complete input/output examples and parameters.
🧪 Testing
Test Coverage: 403 tests covering all functionality including edge cases, error scenarios, CLI arguments, authentication, and comprehensive security validation.
⚠️ Common Issues
1. Build Failures
2. Node.js Version Issues (macOS)
Problem: Claude Desktop may default to using an older Node.js version on your system which doesn't support the required feature set.
Solution: Use global installation and nvm node selection method shown above.
3. Server Won't Start
For global installation:
pnpm install -g @xexr/mcp-libsql
For local installation: Ensure
pnpm build
was run anddist/index.js
existsTest locally:
mcp-libsql --url file:///tmp/test.db
Restart Claude Desktop after config changes
4. Tools Not Available
Verify database URL is accessible
Check Claude Desktop logs for connection errors
Test with simple file database:
file:///tmp/test.db
5. JSON Parsing Errors (Resolved)
Resolved: This issue is caused by stdout console logging. The --log-mode
option now defaults to file
mode which prevents this issue. If you see these errors, ensure you're using the default --log-mode file
or not specifying --log-mode
at all. Note, the error is harmless, and the tool will still work with it if you wish to have console logging.
6. Database Connection Issues
🔧 Full troubleshooting guide: See docs/TROUBLESHOOTING.md for detailed solutions to all issues.
🏗️ Architecture
Built with TypeScript and modern Node.js patterns:
Connection pooling with health monitoring and retry logic
Tool-based architecture with consistent validation and error handling
Security-first design with multi-layer input validation
Comprehensive testing with 244 tests covering all scenarios
🤝 Contributing
Follow TypeScript strict mode and existing code patterns
Write tests for new features
Maintain security measures
Update documentation
Development: pnpm dev
• Build: pnpm build
• Test: pnpm test
📄 License
MIT License - see LICENSE file for details.
🔗 Links
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
mcp-libsql
Related MCP Servers
- MIT License
- MIT License
- -securityAlicense-qualityMySQL MCP Server by CDataLast updated -1MIT License
- -securityAlicense-qualityMicrosoft SQL Server MCP Server by CDataLast updated -MIT License