Skip to content

Tools

pastepile_query

Ask a precise, structured question about the memories and pastes your key reaches, using PQL, a read-only query language with an explain mode.

2 min read · Updated

Runs one PQL query. PQL is a small, typed, read-only language over the memories and pastes the configured API key already reaches. Reach for it when a question has structure the other tools cannot express: pastepile_recall searches, this one filters, orders, projects and bounds.

PQL is read only in the strongest sense available: there is no insert, update or delete in the grammar, and nothing in the engine builds SQL. A query runs through the same functions the memory and paste endpoints use, with the same ownership and scope rules applied inside the database.

Parameters

ParameterTypeDescription
pqlstringrequiredThe query, for example from memory where tags contains "security" since 7d limit 10.
explainbooleanoptionalReturn the plan, the scope in force and the cost class without reading any data. Defaults to false. This is the cheap way to check a query before running it.

Grammar

FROM memory | pastes
WHERE  <conditions>          AND  OR  NOT  and parentheses
SELECT <fields>              defaults to a safe metadata projection
ORDER BY <field> [ASC|DESC]
LIMIT  <n>                   defaults to 20, never unlimited
SINCE / AFTER / BEFORE       a duration such as 7d, or a quoted date

Operators:  =  !=  >  >=  <  <=  IN  CONTAINS  STARTS_WITH

Sources are memory and pastes. Fields, and which of them can be filtered, sorted or selected, are listed in the PQL reference. There is no SELECT *, no joins, no aggregates and no functions.

Example

What did we decide about security in the last week?
Request
{
  "name": "pastepile_query",
  "arguments": {
    "pql": "from memory where kind = \"decision\" and tags contains \"security\" since 7d order by updated_at desc limit 10"
  }
}
Response
{
  "source": "memory",
  "select": ["slug", "title", "kind", "tags", "updated_at", "encrypted"],
  "count": 2,
  "exact": false,
  "truncated": false,
  "effective_scope": "proj/acme",
  "cost": "medium",
  "results": [
    {
      "slug": "k3n1p2",
      "title": "Rotate the webhook secret quarterly",
      "kind": "decision",
      "tags": ["security", "webhooks"],
      "updated_at": "2026-08-05T09:12:44Z",
      "encrypted": false
    }
  ],
  "note": "Results were ordered and filtered over a bounded window of what this key can see, not the whole store. Do not describe them as complete."
}

Behavior notes

  • A query can only narrow. If the key is confined to a project, a query naming anything outside it is refused with pql_insufficient_scope rather than silently returning nothing. effective_scope in the response says what was actually in force.
  • `exact: false` matters. It means the page was ordered or filtered over a bounded window of what the key can see, not over everything. Say so rather than presenting the page as complete.
  • Encrypted memories keep their secrets. title and preview come back empty for them, and full-text matching never reaches them, because Pastepile holds only ciphertext. See Security.
  • Content is opt in. The default projection is metadata. preview has to be named in SELECT, and doing so raises the query's cost class.
  • An expensive query is refused before it runs. pql_too_expensive means narrowing helps and waiting does not.
An API key is required. Trial memory has no PQL surface, because a query language over a device-local store would answer a different question with the same words.

Related documentation