ashlr

ashlr__sql

Run SQL against SQLite or Postgres and return a compact, token-dense text result.

Server: ashlr-sql — servers/sql-server.ts

Collapses the typical "shell out to psql/sqlite3 + reparse stdout" loop into one tool call. Supports SQLite (via bun:sqlite) and Postgres (via porsager/postgres). Returns results as a compact table, truncating large result sets.

Input schema

FieldTypeRequiredDescription
querystringnoSQL query to execute
connectionstringnoConnection URL (postgres://…) or SQLite path. If omitted, reads $DATABASE_URL, then looks for *.db / *.sqlite files in cwd.
explainbooleannoWrap in EXPLAIN ANALYZE (postgres) / EXPLAIN QUERY PLAN (sqlite). Default false.
limitnumbernoMax rows to return in the compact output (default 20). Total row count is always reported.
schemabooleannoSkip the query and instead list tables, columns, and row counts. Cheaper than many \d / SHOW TABLES round-trips.
bypassSummarybooleannoSkip LLM summarization of long output

Output format

A header line gives the connection (passwords redacted), elapsed time and result shape, then a compact table. Rows past limit (default 20) are elided, and the total row count is still reported. With limit: 2 against a 49-row table:

sqlite://demo.db · 0.000s · 49 rows × 3 cols
  id | name  | created_at
  ───┼───────┼───────────
  1  | tool1 | 2026-01-02
  2  | tool2 | 2026-01-03
  [49 rows total · 47 elided; set limit:N to see more]

Driver detection

  • postgres:// or postgresql://: Postgres driver
  • mysql://, mssql:// or sqlserver://: rejected with an "is not supported" error
  • sqlite://<path>, or any other string: treated as a SQLite file path (:memory: works too)
  • connection omitted: reads DATABASE_URL, then looks for a *.db, *.sqlite, *.sqlite3 or *.s3db file in the cwd (not recursive). If there are several, it prefers the one named after the directory, then the most recently modified.

Example

Use ashlr__sql to run: SELECT tool, SUM(tokens_saved) FROM savings GROUP BY tool ORDER BY 2 DESC

Unsupported

MySQL and MSSQL are not supported. Passing a mysql://, mssql:// or sqlserver:// connection returns a clear error.

  • ashlr__bash — raw shell fallback if you need psql flags

On this page