officialstdio

SQLite MCP Server

Give Claude Code and Cursor full read and write access to a local SQLite database through MCP.

Updated: April 15, 2026

Install

npx @modelcontextprotocol/server-sqlite
~/.claude/settings.json
{
  "mcpServers": {
    "mcp-server-sqlite": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sqlite",
        "/Users/you/mydb.db"
      ]
    }
  }
}

Capabilities

  • + Run any SQL query including both reads and writes
  • + Create and modify tables with DDL statements
  • + Insert, update, and delete rows
  • + Describe database schema and column types
  • + Run migrations and index maintenance

Limitations

  • - File path must be specified at config time and cannot change without restart
  • - Single-file databases only - no network or cloud SQLite
  • - Concurrent write access conflicts with other processes holding the file
  • - No user isolation - the model has the same access as the file

SQLite MCP server setup for Claude Code and Cursor

Quick answer: The SQLite MCP server exposes a single local SQLite database file to Claude Code and Cursor as an MCP tool. Unlike the Postgres server which is read-only, this one supports full read and write. Pass the file path as an argument, restart the editor, and the model can query, insert, update, and run migrations. Setup takes about 3 minutes. Tested with server version 0.6.2 on April 15, 2026.

SQLite is the right database when you need something local, fast, and zero-config. A single .db file is the entire database. This MCP server is how you let Claude reason about and modify that file directly.

This guide covers installation, both editor configs, how write access changes the safety story, 8 example prompts, and a comparison against the Postgres and MongoDB servers.

What this server does

The server wraps the better-sqlite3 Node library with 4 MCP tools: query for SELECT, execute for INSERT, UPDATE, DELETE, and DDL, list_tables to enumerate every table, and describe_table to return column info. Together they cover about 95% of what you need to do with a local database.

What you get:

  • Full SQL, including joins, CTEs, subqueries, window functions
  • Write operations without any safety wrapper - the model can run UPDATE and DELETE
  • Schema management via CREATE, ALTER, DROP
  • Index management and query planning via EXPLAIN
  • Transaction support through explicit BEGIN, COMMIT, ROLLBACK

The write access is a double-edged point. It is useful for iterating on a database schema with Claude. It is dangerous if you point the server at a production database. Treat the configured file as disposable, or at least back it up before pointing the model at it.

Installing the SQLite MCP server

The package is @modelcontextprotocol/server-sqlite. Install uses the npx -y pattern. The package ships native bindings for better-sqlite3 which means it needs to compile on platforms without prebuilt binaries. On macOS and Linux x64 you get a binary wheel. On Linux ARM or Windows ARM you may need node-gyp, python3, and a C++ toolchain - about 2 to 3 minutes of install time on first run.

Before you configure, pick a database file path. The file does not need to exist - if it is missing, the server creates an empty one on first query. Absolute paths only. Relative paths resolve against the MCP server's working directory, which is not predictable.

Configuring for Claude Code

Claude Code reads from ~/.claude/mcp.json or a per-project .mcp.json. Add a sqlite entry with the absolute file path as the last argument:

{
  "mcpServers": {
    "sqlite": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sqlite",
        "/Users/you/mydb.db"
      ],
      "env": {}
    }
  }
}

Restart Claude Code. Run /mcp and confirm the server is attached and the 4 tools are listed.

For project-local databases, put the file in the repo (or a .local/ folder that is gitignored) and use a path like /absolute/path/to/repo/.local/dev.db. That way everyone on the team has the same DB shape even if the data differs.

Configuring for Cursor

Cursor reads from ~/.cursor/mcp.json on macOS and Linux, %USERPROFILE%\.cursor\mcp.json on Windows. Same shape:

{
  "mcpServers": {
    "sqlite": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sqlite",
        "/Users/you/mydb.db"
      ],
      "env": {}
    }
  }
}

Toggle on in Cursor settings. First query takes 2 to 3 seconds for cold start. Subsequent calls land in under 20 ms on a file under 100 MB.

Example prompts and workflows

SQLite plus Claude is a tight feedback loop for learning SQL, prototyping schemas, or building small internal tools. Some prompts:

  • "Create a users table with id, email, created_at columns, then insert 10 test users."
  • "Read the CSV at /tmp/sales.csv (via the filesystem MCP) and import it into a new sales table with the right types."
  • "What is the distribution of total in the orders table? Show a histogram with 10 buckets."
  • "Add an index on orders.user_id and tell me if the EXPLAIN plan changes."
  • "Find duplicate rows in users where email matches, keep the one with the lowest id, and delete the rest."
  • "Write a migration that adds a status column with default 'pending' and backfills existing rows to 'active'."
  • "Describe every table and give me an ER diagram as Mermaid."
  • "Run EXPLAIN QUERY PLAN for SELECT * FROM orders WHERE user_id = 42 and tell me if the index helps."

Because writes are allowed, the model can be asked to "clean up" data, which is fast but risky. Always make a copy of the file first with cp mydb.db mydb.db.backup before any destructive session.

Troubleshooting

SQLITE_CANTOPEN: unable to open database file. The path is wrong or the directory is not writable. SQLite creates the file on first write if the parent directory exists - mkdir the parent first.

database is locked. Another process has an open transaction. SQLite uses file-level locking. Close your IDE SQLite browser or any other tool before running the MCP server.

Native module build fails on install. You are on ARM Linux or Windows ARM and need to build better-sqlite3 from source. Install python3, make, and g++ (or the equivalent MSVC tools on Windows), then retry.

Changes are not visible from another tool. SQLite writes go through a write-ahead log by default (mydb.db-wal). Other processes see the changes but need to re-open the DB handle. Checkpoint with PRAGMA wal_checkpoint(FULL) if you want the WAL flushed immediately.

File grows much larger than expected. SQLite does not reclaim space after DELETE without a VACUUM. Ask the model to run VACUUM after any large delete, or set PRAGMA auto_vacuum = FULL on a fresh database.

Cannot change the DB file without restart. The file path is fixed at config time. To switch, edit mcp.json and restart the editor, or register 2 SQLite MCP servers with different names pointing at different files.

Alternatives

Close neighbors:

  • mcp-server-postgres for read-only Postgres - better when you already have Postgres and want safety by default
  • mysql-mcp for MySQL
  • mongodb-mcp for document data
  • neon-mcp for serverless Postgres with branching - nice for agent workflows that need disposable databases

The SQLite server shines when you want a throwaway local database, a fast prototype, or a file-backed store for a small tool. It is the right choice for most "help me build a CLI with a database" projects. The verdict from 4 months of use: attach it in any project where you want Claude to own the schema and data end to end.

Guides

Frequently asked questions

Can I point the server at a read-only database file?

Yes. Set file permissions to read-only (`chmod 444 mydb.db`) and SQLite will refuse writes at the file system layer. The server will return an error on any write attempt. This is the simplest way to get read-only safety.

Does the server handle databases larger than 1 GB?

SQLite scales well to several hundred GB per file. The server streams results, so large queries do not load everything into memory. Practical limit is the model context window - queries returning millions of rows will not fit.

How do I use extensions like FTS5 or spatialite?

`better-sqlite3` includes FTS5 and JSON1 by default. For other extensions, set `SQLITE_ENABLE_LOAD_EXTENSION=1` in env and call `SELECT load_extension('/path/to/ext.so')` from the model. This requires a custom build of `better-sqlite3` on some platforms.

Is the server safe for production data?

Not by default - writes are allowed and there is no audit log. For production use, point the server at a copy of the production DB, or use the Postgres MCP server which is read-only by design. Defense in depth: file permissions plus a dedicated DB user.

Why does the database file have a `-journal` or `-wal` sidecar?

SQLite uses journal or WAL files for crash recovery. They are normal and safe to leave in place. Do not copy `.db` without also copying the sidecar - the copy may be missing recent writes. Use `sqlite3 db .backup` for a safe copy.

Can the model run VACUUM or other maintenance commands?

Yes. Pragmas and maintenance commands like VACUUM, REINDEX, and ANALYZE run through the `execute` tool. Ask explicitly: "run VACUUM on the database" and the model will call it. These commands hold an exclusive lock so avoid running during active writes.