Skip to content

Releases

lookfirst 0.2.0 (pre-1.0)

Pre-release

Choose a tag to compare

@marcogernand-hub marcogernand-hub released this 04 Nov 21:03
7eef470

🛡️ lookfirst (formerly "Torwächter")

A gatekeeper between AI agents and the tools they use. Every writing action (transfer money, delete a record, send a
mail, close a ticket) goes through: preview → a human confirms → execution → read-back → tamper-evident audit log.
Reading actions pass through untouched.

lookfirst is an MCP proxy: put it between any MCP client (Claude, ChatGPT, Cursor, your own
agent) and any MCP servers. Nothing changes on either side.

AI client ──MCP──▶ lookfirst ──MCP──▶ upstream servers (bank, CRM, mail, files, …)
                      │
                      ├─ rules.yaml: allow | confirm | deny per tool (defaults from tool annotations)
                      ├─ confirmation: in-client (MCP elicitation) · local web page · webhook
                      ├─ read-back: re-read after writing → ok | unklar | fehlgeschlagen
                      └─ audit log: JSONL, hash chain, Ed25519-signed  →  `lookfirst verify-log`

Deutsche Fassung: README.de.md. Architecture: docs/architecture.md.

Status

0.2.0 (pre-1.0). Works end-to-end offline (demo below); tested with Claude Code, Gemini CLI and Antigravity (see docs/clients.md). Not a production release: real production use needs your own targeted tests and sign-off. There is no long-term field experience yet. License: Apache-2.0 (see LICENSE). The license grants rights to use the code; it makes no promise of fitness or security. Known limits are listed below.

Gate readiness can be measured at any time: lookfirst pilot-status --config lookfirst.yaml.

Quick start (60 seconds, offline)

pip install -e .            # or: uvx --from . lookfirst demo
lookfirst demo

The demo starts a fake bank MCP server, puts lookfirst in front of it and plays an agent: a balance check passes through,
a transfer stops for your y/N, the result is read back and verified, then one log line is edited and verify-log
catches it. See demo/VIDEO.md for the screen-recording script.

Use it with a real client (5 minutes)

  1. Install once: pipx install <path-or-git-url> (or pip install). Gives you the lookfirst command. Windows: pure Python, py -m pip install <path-or-git-url> should work, but we have not tested it on Windows yet.
  2. Copy examples/lookfirst.yaml next to where the log should live; set upstreams, rules, confirmation channels.
  3. lookfirst keygen --config lookfirst.yaml – creates the Ed25519 signing key (0600) once.
  4. Connect a client – ready-made snippets for Claude Desktop, Claude Code and Antigravity in docs/clients.md
    (stdio: the client starts lookfirst serve --config …; HTTP: run lookfirst serve --transport http --port 8470 yourself).
  5. Any time: lookfirst verify-log --config lookfirst.yaml.

Who approved (v1.1): every decision is logged as channel:actor – web:<user> from an authenticating reverse-proxy header
(confirm.web.identity_header) or a self-declared name on the page, webhook:<actor> from the decision body, elicitation:<client>
from the MCP client's name. Details and trust levels: docs/clients.md.

How a call is decided

Situation Default Why
tool declares readOnlyHint: true allow reading is harmless
tool declares destructiveHint: true confirm a human decides
tool declares destructiveHint: false (a write, but reversible) confirm still a write
no annotations confirm unknown = ask
explicit rule rules.tools.<name>.action that rules beat annotations; deny never executes

Confirmation channels, tried in order: (1) MCP elicitation inside the client, if the client supports it and the arguments
fit in full (argument JSON ≤ 800 characters – longer previews are never cut; they go to the web page or webhook, without one the
call is denied); (2) the local
web page (confirm.web); (3) a webhook (confirm.webhook) that receives the preview and answers on
POST /decision/<id> with a per-call token (HMAC of the call id – a leaked token opens nothing else; webhook URLs must be
https://) and the args_sha256 from the preview – missing or different → 403, so a decision applies only to the exact
arguments shown; the web page binds its buttons the same way). A webhook receiver must show tool_display, summary and arguments_display to the human – never the raw tool or arguments: the display fields are escaped (invisible, bidi and look-alike-space characters appear as \uXXXX), the raw fields are not, and a receiver that shows them can be fooled – this is where a system like AETHELGARD's "Braucht dich" plugs in. Every channel shares one timeout; a timeout
is a denial
.

Limits to know: (a) elicitation is answered by the client. An autonomous client that auto-answers elicitation would approve
its own calls – for such clients set confirm.elicitation: false so the decision must come from the web page or the webhook.
(b) The web page trusts only requests whose Host is this server and that are not cross-site (Origin/Sec-Fetch-Site),
plus a per-process CSRF token; it has no login and is meant for 127.0.0.1 only. (c) With --transport http the gate does
not know who calls. Without http.token_file it only starts on loopback (and warns: every local process can call tools); with
it, each request needs Authorization: Bearer <token>, else 401. Off loopback the token is required. The bearer token is
authentication, not transport encryption: beyond the local trusted host, put TLS or another protected transport (reverse
proxy with TLS, SSH tunnel, VPN) in front of the gate. What the gate does not
protect against (other routes to the same system, same-user access to keys and rules): docs/threat-model.md.

Read-back (rules.tools.<name>.readback): after a confirmed write, lookfirst calls a reading tool and compares expected
fields ($args.x, $result.y placeholders). The result is ok, unklar (could not verify) or fehlgeschlagen (mismatch) and
is returned to the client in structuredContent.lookfirst – a write is never reported as "done" without it.

Known limits (independent counter-check, 2026-11-03)

These are documented limits, not bugs we hide. The ids come from the counter-check and differ from the B-numbers in docs/threat-model.md. Each has a test that pins the current behaviour or marks the wanted one as an expected failure.

Id Limit What to do
B4.1 If the audit log is truncated at the end and the .head sidecar file is deleted, the remaining hash chain still looks intact. lookfirst verify-log then ends with exit 0 and a warning (head sidecar missing). Treat the warning as a failure in your own checks. Keep a copy of the .head file (or just the last sequence number) and update it regularly; verify-log cannot compare against an external copy yet, so the comparison is manual. Keep it outside the write access of whoever can truncate the log — a .head beside the log can be deleted together with it.
B5.1 The privacy filter (schleuse) is a deterministic pattern filter. An IBAN split by a line break, text with zero-width characters, or a secret that is only Base64-encoded in free text is not recognised. It reduces leakage, it does not anonymise. Do not rely on it for secrets; keep secrets out of tool arguments. Also not recognised today: keys such as db_password or access_token (B5.2, pinned as an expected failure).
B7.1 With confirm.elicitation: true, lookfirst serve does not warn at start about autonomous clients that might answer the elicitation themselves (self-approval). For autonomous clients set confirm.elicitation: false, so only the web page or the webhook can approve — and keep the agent away from that page on the network level (other machine, container or network namespace, or a firewall rule per user). A separate OS user is not enough: every local user reaches loopback. Use identity_header only if the backend is reachable solely by the auth proxy; it takes the header unchecked, so an agent that reaches the backend directly can set it and approve itself.

Privacy lock („Schleuse“, v0.3 preview)

Private data leaves only as placeholders. Configure schleuse: (see lookfirst/config.py):

Direction What happens
tool result → AI client IBANs (checksum-validated; invalid-looking ones are masked too), card numbers (Luhn), e-mails, phone numbers, credentials with a known shape (GitHub/OpenAI/Anthropic/AWS/Slack/Stripe/Hugging Face/Google keys, JWTs, private keys; for password=…, api_key: …, Authorization: Bearer … and user:pass@ URLs only the value; in structured results also values under keys such as password/token/api_key). Not detected: free-form secrets without a known shape or key name, your own name list and custom patterns become [[IBAN_3f9a1c]] – in text, structured content, previews, denial texts and the audit log
AI client → local tool a placeholder in arguments is resolved inside the gate – only placeholders this gate issued; an unknown or expired one is refused, nothing executes

Deterministic (no AI), random 128-bit placeholders (not hashes of the value), mapping only in memory with expiry and
bound to the client connection – another client cannot resolve them; after 3 unknown placeholders resolution is locked
for that connection. All tool metadata from upstreams except the tool name (title, description, schemas, annotations,
_meta, icons) and all free-text audit fields are masked too; non-text content is withheld. Session isol...

Read more