SQLite MCP Server

$npx -y github:u1pns/sqlite-mcp
README.md

Provides comprehensive SQLite database interaction for AI agents

SQLite MCP Server

A Model Context Protocol (MCP) server that provides SQLite database interaction capabilities. This server allows AI agents (like Gemini CLI, Claude, etc.) to query and modify SQLite databases.

Features

  • Read Data: Execute SELECT queries to retrieve data.
  • Write Data: Execute INSERT, UPDATE, DELETE, CREATE, and DROP queries.
  • Schema Inspection: List tables and describe table schemas.
  • Logging: Automatically logs queries to daily files in the log/ directory.

Architecture Pattern (The "Memory" System)

This MCP server implements a Context Preservation Pattern designed for autonomous AI agents. Since agents lose context between sessions, this server enforces a self-documenting database structure.

The `_architecture_notes` Table

The server encourages agents to maintain a "meta-table" called _architecture_notes.

  • Architect Agents (who create tables) MUST insert notes explaining why a table exists and how it works.
  • Worker Agents (who process data) MUST read these notes to understand the system rules without needing a huge prompt context.

This turns the SQLite database into a self-contained, self-documented artifact.

Prerequisites

  • Node.js: v14 or higher.

MCP Client Configuration

To use this server with your MCP client, you need to configure it to run the index.js script.

Option 1: Local Installation (Recommended for Development)

  1. Clone the repository:

    git clone https://github.com/u1pns/sqlite-mcp.git
    cd sqlite-mcp
    
  2. Install dependencies:

    npm install
    
  3. Configure Environment Variables:

    Gemini CLI (`settings.json`)

    Add this to your mcpServers object in the .gemini/settings.json file:

    {
      "mcpServers": {
        "sqlite-mcp": {
          "command": "node",
          "args": ["/absolute/path/to/sqlite-mcp/index.js"],
          "env": {
            "SQLITE_DB_PATH": "/absolute/path/to/your/database.sqlite"
          }
        }
      }
    }
    

    If SQLITE_DB_PATH is not provided, it defaults to database.sqlite in the sqlite-mcp directory.

Option 2: Using `npx` (No installation required)

You can run the server directly from GitHub without cloning the repo.

Gemini CLI (`settings.json`)
{
  "mcpServers": {
    "sqlite-mcp": {
      "command": "npx",
      "args": ["-y", "github:u1pns/sqlite-mcp"],
      "env": {
        "SQLITE_DB_PATH": "/absolute/path/to/my/db.sqlite"
      }
    }
  }
}

Note: The -y flag is important to auto-accept the package installation.

Tools

`connect_database`

Connect to a specific SQLite database file.

  • db_path (string): The absolute path to the SQLite database file.
    • Note: If a relative path is provided, the database will be created inside the MCP server's directory, not the user's current directory. Always prefer absolute paths.
  • Feature: Automatically returns custom instructions and best practices (from instructions.md) upon successful connection.

`read_query`

Execute a SELECT query.

  • query (string): The SQL query (must start with SELECT or PRAGMA).

`write_query`

Execute a write query.

  • query (string): The SQL query.

`list_tables`

List all tables in the database.

`describe_table`

Get schema info for a specific table.

  • table_name (string): Name of the table.

`get_schema_ddl`

Returns the full CREATE TABLE statements for the entire database.

  • Use this instead of guessing table structures. It provides the ground truth of the database schema.

`get_custom_instructions`

Returns the content of instructions.md. Useful for re-reading best practices without reconnecting.

License

MIT License

Copyright (c) 2024 u1pns

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Tools (7)

connect_databaseConnect to a specific SQLite database file and retrieve custom instructions.
read_queryExecute a SELECT or PRAGMA query to retrieve data.
write_queryExecute write queries including INSERT, UPDATE, DELETE, CREATE, and DROP.
list_tablesList all tables currently in the database.
describe_tableGet schema information for a specific table.
get_schema_ddlReturns the full CREATE TABLE statements for the entire database.
get_custom_instructionsReturns the content of instructions.md for best practices.

Environment Variables

SQLITE_DB_PATHThe absolute path to the SQLite database file. Defaults to database.sqlite in the server directory.

Configuration

claude_desktop_config.json
{"mcpServers":{"sqlite-mcp":{"command":"npx","args":["-y","github:u1pns/sqlite-mcp"],"env":{"SQLITE_DB_PATH":"/absolute/path/to/your/database.sqlite"}}}}

Try it

List all the tables in my SQLite database.
Show me the full schema DDL for the entire database so you understand the structure.
Read the _architecture_notes table to understand the design rules for this system.
Create a new table for user_profiles and add a note to _architecture_notes explaining its purpose.
Run a SELECT query to find the top 10 most recent entries in the logs table.

Frequently Asked Questions

What are the key features of SQLite MCP Server?

Full CRUD support (SELECT, INSERT, UPDATE, DELETE, CREATE, DROP).. Schema inspection tools including table listing and full DDL retrieval.. Context Preservation Pattern using a dedicated _architecture_notes meta-table.. Automated query logging to daily files for auditability..

What can I use SQLite MCP Server for?

Autonomous AI agents needing to maintain long-term memory via a structured database.. Self-documenting database architectures where agents explain 'why' tables exist.. Local data manipulation and analysis through natural language interfaces.. Automated database schema management and documentation for developer tools..

How do I install SQLite MCP Server?

Install SQLite MCP Server by running: npx -y github:u1pns/sqlite-mcp

What MCP clients work with SQLite MCP Server?

SQLite MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Use SQLite MCP Server with Conare

Manage MCP servers visually, upload persistent context, and never start from zero with Claude Code & Codex.

Try Free