SQLite

SQLite

A SQLite database MCP service provided by Hawa Code (@dahawa/hawa-sqlite-mcp), based on the MCP (Model Context Protocol) protocol over stdio transport, giving AI the ability to query table schemas and execute SQL.

Recommended for use with Hawa Code Code Mode.


Quick Start

The package is published to npm and can be run directly via npx — no local build required.

Option 1: Specify the database path via command-line arguments

{
"mcpServers": {
"sqlite": {
"command": "npx",
"args": [
"-y",
"@dahawa/hawa-sqlite-mcp",
"/absolute/path/to/data.sqlite"
]
}
}
}

Option 2: Specify the database path via environment variable

{
"mcpServers": {
"sqlite": {
"command": "npx",
"args": ["-y", "@dahawa/hawa-sqlite-mcp"],
"env": {
"SQLITE_DB_PATH": "/absolute/path/to/data.sqlite"
}
}
}
}

Database path priority: SQLITE_DB_PATH environment variable > command-line argument in args > default ./data.sqlite (relative to the MCP client’s working directory). If the client cannot find npx/node, use the absolute path returned by which node instead.


Tools Overview

Tool Description
list_tables List all tables/views, optionally including CREATE DDL and column structure
execute_ddl Execute DDL statements (CREATE / ALTER / DROP, supports batch execution of multiple statements)
execute_sql Execute SQL (SELECT / INSERT / UPDATE / DELETE), supports ? parameter binding

list_tables

Lists all tables and views in the SQLite database, optionally including the CREATE DDL and column structure for each table.

Input

Field Type Required Default Description
includeSchema boolean No true Whether to include the CREATE DDL statement and column structure for each table

Output

Field Type Description
database string Database file path
tables array<TableInfo> List of tables/views, sorted by name
error string (optional) Error message on failure; tables is [] on failure

TableInfo

Field Type Description
name string Table/view name
type string Object type: "table" or "view"
sql string | null CREATE DDL statement; null when includeSchema=false
columns array<ColumnInfo> | null Column structure; null when includeSchema=false or for non-table objects

ColumnInfo

Field Type Description
name string Column name
type string Declared column type (e.g. INTEGER, TEXT)
notnull boolean Whether the column has a NOT NULL constraint
defaultValue string | null Default value SQL expression
primaryKey boolean Whether the column is a primary key column

Example

Request:

{ "includeSchema": true }

Successful response (excerpt):

{
"database": "./data.sqlite",
"tables": [
{
"name": "users",
"type": "table",
"sql": "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT NOT NULL)",
"columns": [
{
"name": "id",
"type": "INTEGER",
"notnull": false,
"defaultValue": null,
"primaryKey": true
}
]
}
]
}

Failed response (isError: true):

{
"database": "./data.sqlite",
"tables": [],
"error": "<error message>"
}

execute_ddl

Executes DDL statements (CREATE / ALTER / DROP TABLE, CREATE INDEX, etc.), supporting batch execution of multiple statements.

Input

Field Type Required Description
sql string Yes The DDL statement(s) to execute; multiple statements can be submitted at once separated by ;

Output

Field Type Description
success boolean Whether execution succeeded
changes number Number of affected rows (always 0 for DDL)
error string (optional) Error message on failure

Example

Request:

{ "sql": "CREATE INDEX IF NOT EXISTS idx_users_name ON users(name)" }

Successful response:

{ "success": true, "changes": 0 }

Failed response (isError: true):

{
"success": false,
"changes": 0,
"error": "incomplete input"
}

execute_sql

Executes arbitrary SQL statements (SELECT / INSERT / UPDATE / DELETE, etc.), supporting parameter binding.

Input

Field Type Required Description
sql string Yes The SQL statement to execute, using ? placeholders for parameter binding
params array<string | number | boolean | null> No Parameter values bound to the SQL placeholders, in order

Output

Field Type Description
columns array<string> List of column names
rows array<object> Result rows, each row is a “column name → value” object
rowCount number Number of result rows (number of affected rows for write operations)
error string (optional) Error message on failure; columns/rows are [] and rowCount is 0 on failure

Behavior

  • Query statements (SELECT, etc.): columns contains the result set column names, rows contains the query results, rowCount = rows.length
  • Write statements (INSERT / UPDATE / DELETE, etc.): columns is always ["changes", "lastInsertRowid"], rows is a single row [{ changes, lastInsertRowid }], rowCount = changes

Example

SELECT

Request:

{ "sql": "SELECT * FROM users WHERE age > ?", "params": [18] }

Response:

{
"columns": ["id", "name", "age"],
"rows": [
{ "id": 1, "name": "Alice", "age": 30 }
],
"rowCount": 1
}

INSERT

Request:

{ "sql": "INSERT INTO users (name, age) VALUES (?, ?)", "params": ["Alice", 30] }

Response:

{
"columns": ["changes", "lastInsertRowid"],
"rows": [
{ "changes": 1, "lastInsertRowid": 1 }
],
"rowCount": 1
}

Execution failure (isError: true)

{
"columns": [],
"rows": [],
"rowCount": 0,
"error": "NOT NULL constraint failed: users.name"
}