Skip to main content

Sqlite Component

The <Sqlite> component configures an MCP (Model Context Protocol) server that gives Claude access to SQLite databases.

Basic Usage

import { Sqlite } from "smithers/components/MCP";

<Claude model="sonnet" maxTurns={5}>
  <Sqlite path="./analytics.db">
    The database contains user_events and sessions tables.
  </Sqlite>
  What are the top 10 most common user actions this week?
</Claude>

Props

path
string
required
Path to the SQLite database file.
<Sqlite path="./data/app.db" />
readOnly
boolean
default:"false"
Open database in read-only mode.
<Sqlite path="./data.db" readOnly>
  Query-only access.
</Sqlite>
children
string
Schema description or context for Claude.

Query Example

<Claude model="sonnet" maxTurns={10}>
  <Sqlite path="./ecommerce.db">
    Schema:
    - users(id, name, email, created_at)
    - orders(id, user_id, total, status, created_at)
    - order_items(id, order_id, product_id, quantity, price)
    - products(id, name, category, price)
  </Sqlite>

  Generate a report showing:
  1. Total revenue by category
  2. Top 10 customers by lifetime value
  3. Monthly order trends for the past year

  Export the results to a markdown file.
</Claude>

Read-Only Analysis

<Claude model="sonnet" maxTurns={5}>
  <Sqlite path="./production.db" readOnly>
    Production database - read-only access.
    Tables: users, transactions, audit_log
  </Sqlite>

  Analyze the audit log for unusual patterns.
  Do not modify any data.
</Claude>

Multiple Databases

<Claude model="sonnet" maxTurns={10}>
  <Sqlite path="./users.db">
    User database: users, profiles, preferences
  </Sqlite>

  <Sqlite path="./analytics.db">
    Analytics database: events, sessions, pageviews
  </Sqlite>

  Cross-reference user activity between the two databases.
  Find users who signed up but never logged an event.
</Claude>

Data Pipeline Example

function DataWorkflow() {
  const [phase, setPhase] = createSignal("analyze");

  return (
    <Ralph maxIterations={5}>
      {phase() === "analyze" && (
        <Claude
          model="sonnet"
          onFinished={() => setPhase("report")}
        >
          <Sqlite path="./data.db" readOnly>
            Sales database with orders and customers.
          </Sqlite>

          Analyze Q4 sales performance.
          Identify trends and anomalies.
        </Claude>
      )}

      {phase() === "report" && (
        <Claude
          allowedTools={["Write"]}
          onFinished={() => setPhase("done")}
        >
          Create a formatted markdown report with the findings.
          Save to reports/q4-analysis.md
        </Claude>
      )}
    </Ralph>
  );
}