Skip to main content
RapidDev - Software Development Agency
mcp-tutorial

How to use the SQLite MCP server

The SQLite MCP server lets your AI assistant query and manage local SQLite databases directly from the chat window. Point it at any .db or .sqlite file on your machine, and the AI can run SQL queries, explore schemas, create tables, and analyze data — no separate database server required. It is the simplest way to give your AI access to structured data for local development, prototyping, and data analysis.

What you'll learn

  • How to install and configure the SQLite MCP server
  • How to point the server at an existing or new SQLite database
  • How to query, explore, and manage databases through natural language
  • How to set up the server in Claude Desktop, Cursor, and VS Code
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner7 min read10 minutesClaude Desktop, Cursor, Windsurf, VS Code (Copilot)March 2026RapidDev Engineering Team
TL;DR

The SQLite MCP server lets your AI assistant query and manage local SQLite databases directly from the chat window. Point it at any .db or .sqlite file on your machine, and the AI can run SQL queries, explore schemas, create tables, and analyze data — no separate database server required. It is the simplest way to give your AI access to structured data for local development, prototyping, and data analysis.

Query Local SQLite Databases from Your AI Assistant

The SQLite MCP server connects your AI assistant to a local SQLite database file. SQLite is the most widely deployed database engine in the world — it powers mobile apps, desktop applications, browsers, and many local-first tools. With this MCP server, your AI can explore schemas, run read and write queries, create tables, and analyze data in any SQLite database on your machine. Since SQLite is just a file, there is no database server to install or configure — just point the server at a .db file and start querying. This makes it perfect for prototyping, analyzing app data, working with exported datasets, and local development.

Prerequisites

  • Node.js 18 or later installed on your machine
  • Claude Desktop, Cursor, or another MCP-compatible AI host
  • An existing SQLite database file, or a path where you want to create one

Step-by-step guide

1

Locate or create a SQLite database file

Identify the SQLite database you want your AI to access. Common locations include application data directories, project folders, and exported data files. SQLite databases typically have .db, .sqlite, or .sqlite3 file extensions. If you do not have one yet, the server can create a new database at the path you specify.

typescript
1Common SQLite database locations:
2- iOS apps: ~/Library/Developer/CoreSimulator/.../Documents/*.db
3- Android apps: data/data/<package>/databases/*.db
4- Browser data: ~/.config/chromium/Default/History
5- Project data: ./data/app.db
6- New database: any path you choose, e.g., ~/Projects/my-data.db

Expected result: You have the absolute path to an existing SQLite database, or a path where a new one should be created.

2

Add the SQLite MCP server to your configuration

Open your MCP host's configuration file and add a sqlite entry. The database file path is passed as the last argument in the args array. Use the @modelcontextprotocol/server-sqlite package with npx -y for automatic installation.

typescript
1{
2 "mcpServers": {
3 "sqlite": {
4 "command": "npx",
5 "args": [
6 "-y",
7 "@modelcontextprotocol/server-sqlite",
8 "/Users/me/Projects/my-data.db"
9 ]
10 }
11 }
12}

Expected result: Your configuration file contains the SQLite MCP server entry pointing to your database file.

3

Restart your AI host and verify the connection

Fully quit and reopen Claude Desktop, Cursor, or VS Code. The SQLite server will open (or create) the database file at the specified path. Its tools should appear in the available tools list. In Claude Desktop, the hammer icon indicates the tools are ready.

Expected result: The SQLite MCP server shows as connected with query and schema tools available.

4

Explore the database schema

Start by asking the AI to list tables and describe the schema. This is the safest first step and helps you understand what data is available before running queries.

typescript
1Example prompts:
2
3"What tables are in this database and what columns does each have?"
4
5"Describe the schema of the users table including data types"
6
7"How many rows are in each table?"

Expected result: The AI lists all tables, their columns, data types, and row counts from the SQLite database.

5

Query and analyze data with natural language

Ask questions about your data in plain English. The AI translates your questions into SQL queries, executes them against the SQLite database, and presents the results. Unlike the PostgreSQL MCP server, the SQLite server typically allows both read and write operations since SQLite databases are local files.

typescript
1Example prompts:
2
3"Show me the 10 most recent entries in the activity_log table"
4
5"How many users signed up each month? Show a breakdown"
6
7"Find all records where the status column is 'pending' and the amount is over 100"

Expected result: The AI generates SQL, executes it, and returns formatted query results.

6

Create tables and modify data

Since SQLite databases are local files, the server allows write operations. You can ask the AI to create tables, insert data, update records, and even design schemas from scratch. This makes the SQLite MCP server ideal for prototyping database designs.

typescript
1Example prompts:
2
3"Create a table called 'bookmarks' with columns for id, url, title, tags, and created_at"
4
5"Insert 5 sample bookmark records with realistic data"
6
7"Add an 'archived' boolean column to the bookmarks table with a default of false"

Expected result: The AI creates tables, inserts data, or modifies the schema in the SQLite database.

Complete working example

claude_desktop_config.json
1{
2 "mcpServers": {
3 "sqlite": {
4 "command": "npx",
5 "args": [
6 "-y",
7 "@modelcontextprotocol/server-sqlite",
8 "/Users/me/Projects/my-data.db"
9 ]
10 }
11 }
12}
13
14// VS Code variant (.vscode/mcp.json):
15// {
16// "servers": {
17// "sqlite": {
18// "command": "npx",
19// "args": [
20// "-y",
21// "@modelcontextprotocol/server-sqlite",
22// "/Users/me/Projects/my-data.db"
23// ]
24// }
25// }
26// }
27
28// No API keys or environment variables required.
29// The database file is created if it doesn't exist.
30
31// Available tools:
32// - read_query: Run SELECT queries
33// - write_query: Run INSERT/UPDATE/DELETE/CREATE queries
34// - list_tables: List all tables in the database
35// - describe_table: Get column details for a table
36// - create_table: Create a new table with specified schema
37// - append_insight: Store AI-generated analysis notes
38
39// SQLite database file locations:
40// macOS: ~/Library/Application Support/<app>/
41// Linux: ~/.local/share/<app>/
42// Windows: %APPDATA%\<app>\

Common mistakes when using the SQLite MCP server

Why it's a problem: Using a relative path to the database file

How to avoid: Always use an absolute path like /Users/me/Projects/data.db. Relative paths may not resolve correctly because the server process starts in an unpredictable working directory.

Why it's a problem: Pointing at a database that is locked by another application

How to avoid: SQLite allows only one writer at a time. If another application has the database open with a write lock, the MCP server may fail to write. Close other applications or use a copy of the database.

Why it's a problem: Modifying a production SQLite database without a backup

How to avoid: Always copy the .db file before letting the AI make changes. SQLite backups are just file copies. If something goes wrong, restore from the backup.

Why it's a problem: Expecting PostgreSQL-specific SQL syntax to work

How to avoid: SQLite has a different SQL dialect from PostgreSQL. Features like SERIAL, arrays, JSONB, and some JOIN types differ. The AI should handle this automatically, but if you paste SQL from a Postgres project, it may need adaptation.

Best practices

  • Back up your database file before allowing write operations
  • Use absolute paths to avoid working directory issues
  • Start with schema exploration before running data queries
  • Use the SQLite server for prototyping database designs before migrating to PostgreSQL
  • Close other applications that might lock the database before starting the MCP server
  • Combine with the filesystem MCP server to export query results to CSV or JSON files
  • Use WAL mode (Write-Ahead Logging) for better concurrent read performance
  • Ask the AI to explain the SQL it generates to learn and verify correctness

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I want to set up the SQLite MCP server so my AI assistant can query a local SQLite database. Walk me through configuring it in Claude Desktop and show me how to explore the schema and run queries.

MCP Prompt

List all tables in the database, describe the schema of each one, then find the 5 most recent records from the events table and summarize the patterns you see.

Frequently asked questions

Can the AI create a new SQLite database from scratch?

Yes. If the database file does not exist at the specified path, the SQLite server creates a new empty database. You can then ask the AI to create tables and insert data through natural language.

What is the difference between the SQLite and PostgreSQL MCP servers?

The SQLite server works with local database files — no server process needed, supports read and write operations. The PostgreSQL server connects to a running Postgres server, typically enforces read-only access, and is better suited for production and remote databases.

Can I query a SQLite database from a mobile app or Electron app?

Yes. Many mobile and desktop apps use SQLite for local storage. Find the .db file in the app's data directory and point the MCP server at it. Be careful not to modify databases that are actively being used by another application.

How large of a database can the SQLite server handle?

SQLite can handle databases up to 281 terabytes. The MCP server should work fine with databases of any reasonable size. For very large query results, ask the AI to use LIMIT clauses to keep response sizes manageable.

Can I switch between different database files?

The database path is set in the configuration at startup time. To switch databases, update the path in your config file and restart your AI host. You can also add multiple sqlite entries with different names for different databases.

Is SQLite sufficient for my project, or should I use PostgreSQL?

SQLite is excellent for local development, prototyping, mobile apps, and single-user applications. For multi-user web applications with concurrent writes, PostgreSQL is the better choice. RapidDev can help you decide on the right database architecture and migrate between SQLite and PostgreSQL when your project is ready to scale.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.