Skip to main content
Glama
mcp-sqlite-server

mcp-sqlite-server

by graduenz

mcp-sqlite-server

An MCP (Model Context Protocol) server that provides tools and resources for interacting with SQLite databases via better-sqlite3.

Quality Gate Status Bugs Vulnerabilities Code Smells Coverage Lines of Code

Table of Contents

Related MCP server: mcp-sql-explorer

Features

  • Query & Execute -- run read and write SQL statements

  • Schema Introspection -- list tables, describe columns/indexes, view full DDL

  • Project-Level Configuration -- database settings live in a .mcp-sqlite.json file, not in the MCP client config

  • WAL Mode -- enabled by default for better concurrency

  • Read-Only Mode -- optionally prevent write operations

Configuration

Create a .mcp-sqlite.json file in the project/workspace that will use this MCP server:

{
  "database": "./data.sqlite",
  "readonly": false,
  "wal": true
}

Field

Type

Default

Description

database

string

—

Required. Path to the SQLite file (relative to config file)

readonly

boolean

false

Open the database in read-only mode

wal

boolean

true

Enable WAL journal mode

The server resolves the config file in this order:

  1. --config <path> CLI argument

  2. .mcp-sqlite.json in the current working directory

Tools

query

Execute a read-only SQL query (SELECT) and return results as JSON.

Input: { "sql": "SELECT * FROM users LIMIT 10" }

execute

Execute a write SQL statement (INSERT, UPDATE, DELETE, CREATE TABLE, etc.). Disabled in read-only mode.

Input: { "sql": "INSERT INTO users (name) VALUES ('Alice')" }

list_tables

List all tables and views in the database.

Input: none

describe_table

Get detailed schema for a specific table including columns, types, constraints, and indexes.

Input: { "table": "users" }

Resources

URI

Description

sqlite://schema

Full database schema (all DDL statements)

sqlite://tables

List of all tables and views

sqlite://tables/{name}/schema

Schema details for a specific table

Contributing

See CONTRIBUTING.md for setup, release/publish workflow, build instructions, testing, code conventions, and guidance on adding new tools, resources, and config fields.

Cursor MCP Configuration

Add the following to .cursor/mcp.json in any project that wants to use this server:

{
  "mcpServers": {
    "mcp-sqlite-server": {
      "command": "npx",
      "args": ["-y", "@graduenz/mcp-sqlite-server"]
    }
  }
}

The server will look for .mcp-sqlite.json in the workspace root (the working directory Cursor launches the server from).

To use an explicit config path:

{
  "mcpServers": {
    "mcp-sqlite-server": {
      "command": "npx",
      "args": [
        "-y",
        "@graduenz/mcp-sqlite-server",
        "--config",
        ".mcp-sqlite.json"
      ]
    }
  }
}

Then create .mcp-sqlite.json in the project root:

{
  "database": "./data.sqlite",
  "readonly": false,
  "wal": true
}

Multiple Databases (Two MCP Servers)

If your project has multiple SQLite databases, run one MCP server instance per database. Each instance needs its own server name in .cursor/mcp.json and its own config file passed with --config.

{
  "mcpServers": {
    "sqlite-main": {
      "command": "npx",
      "args": [
        "-y",
        "@graduenz/mcp-sqlite-server",
        "--config",
        ".mcp-sqlite.main.json"
      ]
    },
    "sqlite-analytics": {
      "command": "npx",
      "args": [
        "-y",
        "@graduenz/mcp-sqlite-server",
        "--config",
        ".mcp-sqlite.analytics.json"
      ]
    }
  }
}

Create a config file for each database:

.mcp-sqlite.main.json:

{
  "database": "./data/main.sqlite",
  "readonly": false,
  "wal": true
}

.mcp-sqlite.analytics.json:

{
  "database": "./data/analytics.sqlite",
  "readonly": true,
  "wal": true
}

When prompting in Cursor, specify which MCP server to use (sqlite-main or sqlite-analytics) based on the database you want to query.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables LLM clients to safely explore SQLite databases through schema discovery, sampling, read-only querying, and query-plan analysis, with schema resources and an analysis prompt.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables an LLM to explore and query a SQLite database through tools for listing tables, describing schemas, sampling rows, and running bounded read-only SELECT queries, with table/column restrictions, resource limits, and audit logging.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables MCP clients to explore a SQLite database through safe, read-only tools for listing tables, describing schemas, and running SELECT/WITH queries, with optional guarded write support when enabled.
      3
      MIT