libSQL Database

libSQL Database

xexr

Connects to libSQL/SQLite databases and lets you execute queries, manage tables, and browse database structure through Claude and other MCP clients.

Provides secure database operations for libSQL/SQLite databases

19265 views5Local (stdio)

What it does

  • Execute SELECT queries with security validation
  • Perform INSERT/UPDATE/DELETE operations
  • Create and modify table structures
  • Browse database metadata and schemas
  • List tables with filtering options
  • Inspect table schemas in multiple formats

Best for

Database administrators managing SQLite databasesDevelopers building applications with libSQLData analysts querying local databases through AI
Multi-layer SQL injection prevention244 comprehensive tests with 100% pass rateConnection pooling with automatic retry

About libSQL Database

libSQL Database is a community-built MCP server published by xexr that provides AI assistants with tools and capabilities via the Model Context Protocol. libSQL Database enables secure operations on libSQL and SQLite databases. Compatible with popular SQLite browser tools f It is categorized under databases.

How to install

You can install libSQL Database in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.

License

libSQL Database is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.

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

  1. Install:

    pnpm install -g @xexr/mcp-libsql
    
  2. Test locally:

    mcp-libsql --url file:///tmp/test.db --log-mode console
    
  3. Configure 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

# Use your package manager of choice, e.g. npm, pnpm, bun etc

# Install globally
pnpm install -g @xexr/mcp-libsql
mcp-libsql -v # check version

# ...or build from the repository
git clone https://github.com/Xexr/mcp-libsql.git
cd mcp-libsql
pnpm install # Install dependencies
pnpm build # Build the project
node dist/index.js -v  # check version

๐Ÿš€ Usage

Local Testing

Global installation assumed below, replace "mcp-libsql" with "node dist/index.js" if using local build

# Test with file database (default: file-only logging)
mcp-libsql --url file:///tmp/test.db

# Test with HTTP database
mcp-libsql --url http://127.0.0.1:8080

# Test with Turso database (environment variable, alternatively export the env var)
LIBSQL_AUTH_TOKEN="your-token" mcp-libsql --url "libsql://your-db.turso.io"

# Test with Turso database (CLI parameter)
mcp-libsql --url "libsql://your-db.turso.io" --auth-token "your-token"

# Development mode with console logging
mcp-libsql --dev --log-mode console --url file:///tmp/test.db

# Test with different logging modes
mcp-libsql --url --log-mode both file:///tmp/test.db

Claude Desktop Integration

Configure the MCP server in Claude Desktop based on your operating system:

macOS Configuration

  1. Create configuration file at ~/Library/Application Support/Claude/claude_desktop_config.json:

Global install


{
  "mcpServers": {
    "mcp-libsql": {
      "command": "mcp-libsql",
      "args": [
        "--url",
        "file:///Users/username/database.db"
      ]
    }
  }
}

Alternative configuration for local build installation:

{
  "mcpServers": {
    "mcp-libsql": {
      "command": "node",
      "args": [
        "/Users/username/projects/mcp-libsql/dist/index.js",
        "--url", 
        "file:///Users/username/database.db"
      ],
    }
  }
}

Alternative configuration for global install using nvm lts for node

{
  "mcpServers": {
    "mcp-libsql": {
      "command": "zsh",
      "args": [
        "-c",
        "source ~/.nvm/nvm.sh && nvm use --lts > /dev/null && mcp-libsql --url file:///Users/username/database.db",
      ],
    }
  }
}

Important: The global installation method is recommended as it handles PATH automatically.

Linux Configuration

  1. Create configuration file at ~/.config/Claude/claude_desktop_config.json:

Global install

{
  "mcpServers": {
    "mcp-libsql": {
      "command": "mcp-libsql",
      "args": [
        "--url",
        "file:///home/username/database.db"
      ]
    }
  }
}

Alternative configuration for local build installation:

{
  "mcpServers": {
    "mcp-libsql": {
      "command": "node",
      "args": [
        "/home/username/projects/mcp-libsql/dist/index.js",
        "--url",
        "file:///home/username/database.db"
      ],
    }
  }
}

Windows (WSL2) Configuration

  1. Create configuration file at %APPDATA%\Claude\claude_desktop_config.json:

Global install

{
  "mcpServers": {
    "mcp-libsql": {
      "command": "wsl.exe",
      "args": [
        "-e",
        "bash",
        "-c",
        "mcp-libsql --url file:///home/username/database.db",
      ]
    }
  }
}

Alternative configuration for local build installation:

{
  "mcpServers": {
    "mcp-libsql": {
      "command": "wsl.exe",
      "args": [
        "-e",
        "bash",
        "-c",
        "/home/username/projects/mcp-libsql/dist/index.js --url file:///home/username/database.db",
      ]
    }
  }
}

Alternative configuration for global install using nvm for node

{
  "mcpServers": {
    "mcp-libsql": {
      "command": "wsl.exe",
      "args": [
        "-e",
        "bash",
        "-c",
        "source ~/.nvm/nvm.sh && mcp-libsql --url file:///home/username/database.db",
      ]
    }
  }
}

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):

export LIBSQL_AUTH_TOKEN="your-turso-auth-token-here"
{
  "mcpServers": {
    "mcp-libsql": {
      "command": "mcp-libsql",
      "args": [
        "--url",
        "libsql://your-database.turso.io"
      ]
    }
  }
}

Method 2: CLI Parameter

{
  "mcpServers": {
    "mcp-libsql": {
      "command": "mcp-libsql",
      "args": [
        "--url",
        "libsql://your-database.turso.io",
        "--auth-token",
        "your-turso-auth-token-here"
      ]
    }
  }
}

Getting Your Turso Auth Token

  1. Install Turso CLI:

    curl -sSfL https://get.tur.so/install.sh | bash
    
  2. Login to Turso:

    turso auth login
    
  3. Create an auth token:

    turso auth token create --name "mcp-libsql"
    
  4. 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

  1. 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-string
    
  2. Configure 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"
          ]
        }
      }
    }
    
  3. 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 path
  • Working directory: Set cwd to ensure relative paths work correctly
  • Authentication: For Turso databases, use environment variables for secure token handling
  • Logging modes:
    • Default file mode prevents JSON parsing errors in MCP protocol
    • Use --log-mode console for development debugging
    • Use `--log-mode b

README truncated. View full README on GitHub.

Alternatives

Related Skills

Browse all skills
literature-review

Conduct comprehensive, systematic literature reviews using multiple academic databases (PubMed, arXiv, bioRxiv, Semantic Scholar, etc.). This skill should be used when conducting systematic literature reviews, meta-analyses, research synthesis, or comprehensive literature searches across biomedical, scientific, and technical domains. Creates professionally formatted markdown documents and PDFs with verified citations in multiple citation styles (APA, Nature, Vancouver, etc.).

377
postgresql-psql

Comprehensive guide for PostgreSQL psql - the interactive terminal client for PostgreSQL. Use when connecting to PostgreSQL databases, executing queries, managing databases/tables, configuring connection options, formatting output, writing scripts, managing transactions, and using advanced psql features for database administration and development.

38
fullstack-developer

Modern web development expertise covering React, Node.js, databases, and full-stack architecture. Use when: building web applications, developing APIs, creating frontends, setting up databases, deploying web apps, or when user mentions React, Next.js, Express, REST API, GraphQL, MongoDB, PostgreSQL, or full-stack development.

11
supabase-rls-policy-generator

This skill should be used when the user requests to generate, create, or add Row-Level Security (RLS) policies for Supabase databases in multi-tenant or role-based applications. It generates comprehensive RLS policies using auth.uid(), auth.jwt() claims, and role-based access patterns. Trigger terms include RLS, row level security, supabase security, generate policies, auth policies, multi-tenant security, role-based access, database security policies, supabase permissions, tenant isolation.

10
notion

Notion workspace integration. Use when user wants to read/write Notion pages, search databases, create tasks, or sync content with Notion.

10
biomni

Autonomous biomedical AI agent framework for executing complex research tasks across genomics, drug discovery, molecular biology, and clinical analysis. Use this skill when conducting multi-step biomedical research including CRISPR screening design, single-cell RNA-seq analysis, ADMET prediction, GWAS interpretation, rare disease diagnosis, or lab protocol optimization. Leverages LLM reasoning with code execution and integrated biomedical databases.

9