/ Каталог / Песочница / SQLite
● Официальный modelcontextprotocol ⚡ Сразу

SQLite

автор modelcontextprotocol · modelcontextprotocol/servers

Query a local SQLite file. Perfect for personal projects, exported data dumps, or analytics on a journal/log/db file.

The reference SQLite MCP. Points at a single SQLite file and exposes schema introspection, read queries, and write queries (configurable). Zero setup, no server, no network — and unlike Postgres MCP, it can also write if you let it.

Зачем использовать

Ключевые функции

Живое демо

Как выглядит на практике

sqlite.replay ▶ готово
0/0

Установка

Выберите клиент

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "sqlite": {
      "command": "uvx",
      "args": [
        "mcp-server-sqlite",
        "--db-path",
        "/data/sample.db"
      ]
    }
  }
}

Откройте Claude Desktop → Settings → Developer → Edit Config. Перезапустите после сохранения.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "sqlite": {
      "command": "uvx",
      "args": [
        "mcp-server-sqlite",
        "--db-path",
        "/data/sample.db"
      ]
    }
  }
}

Cursor использует ту же схему mcpServers, что и Claude Desktop. Конфиг проекта приоритетнее глобального.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "sqlite": {
      "command": "uvx",
      "args": [
        "mcp-server-sqlite",
        "--db-path",
        "/data/sample.db"
      ]
    }
  }
}

Щёлкните значок MCP Servers на боковой панели Cline, затем "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "sqlite": {
      "command": "uvx",
      "args": [
        "mcp-server-sqlite",
        "--db-path",
        "/data/sample.db"
      ]
    }
  }
}

Тот же формат, что и Claude Desktop. Перезапустите Windsurf для применения.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "sqlite",
      "command": "uvx",
      "args": [
        "mcp-server-sqlite",
        "--db-path",
        "/data/sample.db"
      ]
    }
  ]
}

Continue использует массив объектов серверов, а не map.

~/.config/zed/settings.json
{
  "context_servers": {
    "sqlite": {
      "command": {
        "path": "uvx",
        "args": [
          "mcp-server-sqlite",
          "--db-path",
          "/data/sample.db"
        ]
      }
    }
  }
}

Добавьте в context_servers. Zed перезагружается автоматически.

claude mcp add sqlite -- uvx mcp-server-sqlite --db-path /data/sample.db

Однострочная команда. Проверить: claude mcp list. Удалить: claude mcp remove.

Сценарии использования

Реальные сценарии: SQLite

Analyze a CSV/JSON dump by loading it into SQLite

👤 Analysts, engineers exploring exported data ⏱ ~15 min beginner

Когда использовать: Someone sent you a CSV with 200k rows and the question 'which segment converts best?' — too big for spreadsheets, too small for a real DB.

Предварительные требования
  • Source file on disk — Save as .csv or .json under a working folder
  • An empty SQLite file path — Choose a location like /tmp/analysis.db; the MCP will create it
Поток
  1. Create the table and load
    Create a table signups in /tmp/analysis.db matching the columns of /data/signups.csv. Load all rows. Tell me the row count.✓ Скопировано
    → Table created, row count matches file
  2. Explore the schema
    What columns exist? For each, what's the value distribution (top 5 distinct values for categoricals; min/max/avg for numerics)?✓ Скопировано
    → Per-column profile
  3. Answer the actual question
    Group by signup_source. For each, compute: total signups, conversion rate (signups with completed_onboarding=true / total). Sort by conversion rate.✓ Скопировано
    → Decision-grade table with the SQL shown

Итог: Defensible answers in 5 minutes, with a .db file you can re-query as new questions come up.

Подводные камни
  • CSV columns auto-typed wrong (numbers as TEXT) — After load, run PRAGMA table_info(signups) and CAST or recreate columns with explicit types if needed
  • Date strings don't sort/compare correctly as TEXT — Store dates as ISO 8601 (YYYY-MM-DDTHH:MM:SSZ) so lexicographic = chronological; or use julianday() for math
Сочетать с: filesystem · antv-chart

Inspect and edit a personal app's SQLite database

👤 Devs building CLI tools, journal apps, or local-first software ⏱ ~10 min beginner

Когда использовать: You're building a local-first app, you want to see what's in the DB without writing a CLI for it.

Поток
  1. Survey the schema
    List every table in /Users/me/Library/Application Support/MyApp/data.db. For each, show schema and row count.✓ Скопировано
    → Inventory of the live app DB
  2. Investigate a row
    Find the user record where email = '[email protected]'. Show the row and any related rows in other tables (orders, sessions).✓ Скопировано
    → Full picture of one user's data
  3. Fix bad data
    There's a stuck order in 'pending' state for that user from 2 days ago. Update it to 'cancelled'. Show the SQL before running.✓ Скопировано
    → SQL preview before mutation, then row updated

Итог: App debugging without writing throwaway SQL scripts.

Подводные камни
  • App may have the DB locked open with WAL mode — If you get 'database is locked', stop the app, or query the WAL-merged read-only snapshot via ?mode=ro&immutable=1
Сочетать с: filesystem

Build deterministic test fixtures from a sample of prod data

👤 Engineers writing integration tests ⏱ ~25 min intermediate

Когда использовать: You want repeatable test data that resembles prod but is small and safe.

Поток
  1. Sample anonymized rows
    From /prod-export/orders.db, sample 100 rows from orders covering each status. Anonymize names and emails.✓ Скопировано
    → Sample with anonymized PII
  2. Save as a fixture file
    Write the sampled rows to /test/fixtures/orders.db as a fresh SQLite file. Include schema.✓ Скопировано
    → New fixture file created
  3. Verify against your test loader
    Run my test suite (npm test) — does it pick up the new fixture? If not, what's the first failing test?✓ Скопировано
    → Tests run; failures pinpointed

Итог: Realistic fixtures that don't drift from real data shapes.

Подводные камни
  • Anonymization that breaks referential integrity — Anonymize join keys consistently (same hash) across tables; never randomize per-row
Сочетать с: filesystem · github

Analyze a SQLite-backed log/event file

👤 Engineers debugging CLI tools or apps that log to SQLite ⏱ ~10 min beginner

Когда использовать: Many modern tools (homebrew, some browsers, app caches) store state in SQLite. You want to query them.

Поток
  1. Confirm it's the right file
    Open ~/Library/Application Support/SomeApp/cache.db. List tables and a sample of recent rows.✓ Скопировано
    → Recognizable schema confirms you have the right file
  2. Find the answer
    How many entries does the cache hold per source domain? Top 20.✓ Скопировано
    → Aggregation result
  3. Optionally clean up
    Delete entries from domains that haven't been accessed in 90 days. Show count first, ask before deleting.✓ Скопировано
    → Preview, confirmation, then delete

Итог: Answers about app behavior with no need for a built-in 'stats' command.

Подводные камни
  • Modifying an app's live DB while the app is running can corrupt it — Always close the app first, or work on a copy of the .db file
Сочетать с: filesystem

Комбинации

Сочетайте с другими MCP — эффект x10

sqlite + filesystem

Read a CSV from disk and load into SQLite for analysis

Read /data/orders.csv with filesystem MCP, infer types, and load into /tmp/analysis.db as table orders via sqlite MCP.✓ Скопировано
sqlite + antv-chart

Query a SQLite DB and chart the results

From /tmp/analysis.db, get monthly signups for 2026. Render as a bar chart via antv-chart.✓ Скопировано
sqlite + github

Analyze data, write findings into a GitHub Issue

Run my churn analysis on /tmp/users.db. Create a GitHub Issue in acme/analytics summarizing the top 3 findings with the SQL appendix.✓ Скопировано

Инструменты

Что предоставляет этот MCP

ИнструментВходные данныеКогда вызыватьСтоимость
list_tables none First step in any session free
describe_table table_name: str Inspect a single table's schema free
read_query query: str (SELECT only) Run a SELECT — safe by default free
write_query query: str (INSERT/UPDATE/DELETE) Mutate data — gated; requires explicit consent in most clients free
create_table query: str (CREATE TABLE ...) DDL — create or alter schema free
append_insight insight: str Add a finding to the session memo (used by some clients to build a report) free

Стоимость и лимиты

Во что обходится

Квота API
Unlimited — local
Токенов на вызов
Schema queries: small. Result sets scale with row count — always LIMIT for exploratory queries
Деньги
Free
Совет
Add LIMIT 100 to every exploratory query and only remove it when you know what you're getting back.

Безопасность

Права, секреты, радиус поражения

Хранение учётных данных: No credentials. The DB file is whatever path you launch with via --db-path.
Исходящий трафик: None from the server. Query results ship to your LLM provider as context.
Никогда не давайте: never point at a file holding sensitive data unless you intend the model to see it

Устранение неполадок

Частые ошибки и исправления

database is locked

Another process (often the app that owns the DB) holds the lock. Close that process or copy the .db file and query the copy.

Проверить: lsof <db file>
no such table: X

Wrong DB file or schema not what you think. Run list_tables to see what's actually there. Check the launch arg --db-path in your MCP client config.

datatype mismatch / unexpected NULL

SQLite is dynamically typed — a column declared INTEGER can hold TEXT. Use CAST(col AS INTEGER) defensively, or fix at load.

Disk image is malformed

DB corrupted, often from killing a process during a write. Try sqlite3 file.db .recover > out.sql and rebuild from the dump.

Альтернативы

SQLite в сравнении

АльтернативаКогда использоватьКомпромисс
Postgres MCPMulti-user concurrent access, networked DB, or you're already on PostgresNeeds a server; Postgres MCP is read-only by design
DuckDB (via shell)Same one-file model but for OLAP-shaped analytics with much faster scansNo first-party MCP yet; columnar so different perf characteristics
dbHubYou need one MCP for SQLite + Postgres + MySQL + othersNewer; less battle-tested

Ещё

Ресурсы

📖 Читать официальный README на GitHub

🐙 Открытые задачи

🔍 Все 400+ MCP-серверов и Skills