writ

v0.2.8
io.github.withwrit/writ Checked 1 day ago Published 6 days ago

Policy checks for AI agent writes (ALLOW/DENY/STEP_UP) with a tamper-evident audit log.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

writ_check

Ask Writ whether an action may proceed. CALL THIS BEFORE any consequential write. A consequential write is anything hard to undo: sending money or messages, changing access or identity records, deleting data, calling an external API that acts in the world. Args: sponsor_id: The human sponsor accountable for this action (e.g. a user id or email). agent_id: The agent or workflow performing the action. verb: What is being done (e.g. "verify_human", "send_payment"). target: What it acts on (e.g. "benefit-case-123"). purpose:…

ParameterTypeDescription
agent_id *string
purpose *string
sponsor_id *string
target *string
verb *string
environmentstring

writ_verify_token

Verify a Writ auth token against the write you are about to execute. Call this IMMEDIATELY before executing an ALLOWed write, with the exact verb/target/purpose you intend. If valid is false — expired, tampered, or bound to a different purpose — do NOT execute the write; call writ_check again. This is the point-of-action enforcement: the check authorizes, the token proves the authorization still matches what you are actually doing.

ParameterTypeDescription
auth_token *string
purpose *string
target *string
verb *string

writ_lease

Convert an ALLOW token into a single-use gated-execution lease. Call this AFTER writ_check returns ALLOW, passing that ALLOW's authToken. The lease is bound to the exact upstream request you intend to run: the same method, path, and body bytes you will later pass to writ_execute. A lease is single-use; once executed (or expired) it is spent. Args: auth_token: The authToken from a writ_check ALLOW decision. system_id: The registered upstream system: "stripe", "github", or "salesforce". A vaulted credential must be active…

ParameterTypeDescription
auth_token *string
method *string
path *string
system_id *string
body
ttl_seconds

writ_execute

Run one gated upstream request with a lease or ALLOW token. Pass exactly one of lease_id (from writ_lease) or auth_token (from a writ_check ALLOW). Pass the SAME method, path, and body as the lease: the gate compares the request bytes against the lease, and on any mismatch it fails closed: no upstream call is made and the answer is {"ok": false, "reason": ..., "upstreamCalled": false}. Args: lease_id: The leaseId from writ_lease. Mutually exclusive with auth_token. auth_token: An ALLOW authToken from writ_check. Mut…

ParameterTypeDescription
auth_tokenstring
body
idempotency_keystring
lease_idstring
methodstring
pathstring
system_idstring

writ_grant

SPONSOR ONLY. Mint a one-time grant approving a specific action. Use this when writ_check returned STEP_UP and the human sponsor approves. The grant is single-use: the next writ_check consumes it and returns ALLOW. The grant is scoped to your tenant. Requires WRIT_SPONSOR_TOKEN.

ParameterTypeDescription
agent_id *string
purpose *string
sponsor_id *string
target *string
verb *string
ttl_secondsinteger

writ_revoke

SPONSOR ONLY. Kill switch: immediately deny all future checks for this principal. Revocation overrides live grants and tenant policy. Use when a principal is compromised, misbehaving, or its task is done. Scoped to your tenant. Requires WRIT_SPONSOR_TOKEN.

ParameterTypeDescription
agent_id *string
sponsor_id *string

writ_reinstate

SPONSOR ONLY. Undo writ_revoke: the principal is evaluated by policy again. Scoped to your tenant. Requires WRIT_SPONSOR_TOKEN.

ParameterTypeDescription
agent_id *string
sponsor_id *string

writ_receipts

List recent decision receipts (audit trail). Newest first.

ParameterTypeDescription
limitinteger

writ_verify_receipts

Verify the tenant audit-log hash chain and report whether it is intact. Walks the tenant's receipt chain from its head, recomputing every visited receipt's HMAC. This is the endpoint behind `./writ verify-chain`: use it to prove the audit log has not been tampered with. Args: limit: Max receipts to verify, newest first. Default 200, clamped to the range 1..1000. Returns the gate payload verbatim: ok (chain intact), checked (receipts verified), tip and tipReceipt (chain head), chainedFrom, legacyCount, and complete. Verification stops at legacy…

ParameterTypeDescription
limitinteger

writ_policy

Read the tenant's verb policy: which verbs allow, deny, require a grant, or step up.

writ_policies

List every policy object for the tenant. Returns the gate payload verbatim: the tenant default first (scope "tenant"), then each configured per-environment override (scope "environment"), then each per-principal override (scope "principal" with principalId). Environments without an override are not listed; checks naming them evaluate against the tenant default.

writ_policy_env

Read or set one environment's sparse policy override (dev, staging, or prod). With policy empty: GET the override. Returns the gate payload verbatim - the sparse override in policy (only the verbs it explicitly sets; empty with version 0 when never configured), effectivePolicy (the tenant default with the override applied on top, which is what checks naming this environment evaluate against), and policyProvenance naming the winning layer (tenant or environment) per verb. With policy given: PUT the override. Pass a JSON object string of verb to mode, e.g. '{"re…

ParameterTypeDescription
environment *string
policystring

writ_policy_principal

Read or set one principal's sparse policy override (the top policy layer). With policy empty: GET the override. Returns the gate payload verbatim - the sparse override in policy (only the verbs it explicitly sets; empty with version 0 when never configured), effectivePolicy it resolves to, and policyProvenance naming the winning layer (principal, environment, or tenant) per verb. Pass environment to fold that environment's override into the middle layer, exactly as a check naming it would evaluate. Tombstoned principals still return 200 with "inert": true - the…

ParameterTypeDescription
principal_id *string
environmentstring
policystring

writ_me

Who the configured API key is acting as. This is the Writ "who am I": returns who the configured API key belongs to (tenant id and name, key email and plan), the policy summary, and the monthly receipt usage (monthlyChecks). Never returns the raw key. Returns the gate payload verbatim: tenant (id, name), key (email, plan), policy (per-verb modes), and monthlyChecks. Free tier is 10,000 receipts/month; checks return 402 payment_required once it is exhausted or billing is past due.

writ_sandbox

Get a free 90-second sandbox grant for a demo write. No API key needed. Issues a live grant for verb "demo_write" on a target starting with "demo-", then runs writ_check so you get back an ALLOW decision plus auth token to practice the verify-before-write flow end to end.

ParameterTypeDescription
agent_id *string
purpose *string
sponsor_id *string
target *string

writ_github_installations

List the GitHub App installations for this tenant. Returns each installation's id, status, PR-comment bot setting, and the per-installation check-run fail threshold (checkFailUngated). Use this to discover installation ids before calling writ_github_set_threshold or writ_github_toggle_pr_comments.

writ_github_set_threshold

Set the per-installation check-run fail threshold. A positive number N makes the GitHub check run fail when the ungated-site count is greater than N; a zero-ungated scan passes. Omit threshold (or set it to None) to clear the override and restore neutral-only check runs.

ParameterTypeDescription
installation_id *string
thresholdinteger

writ_github_toggle_pr_comments

Enable or disable the optional PR-comment bot for a GitHub App installation. Default is OFF. No TOTP step-up is required. Use writ_github_installations to find installation_id.

ParameterTypeDescription
enabled *boolean
installation_id *string

writ_manifests

List scanned repos and their risk profiles, or fetch one manifest. With no repo_id, returns a table of repos with writScore, scanStatus, and riskDigest (counts per risk class). With repo_id, returns the full signed manifest for that repo.

ParameterTypeDescription
repo_idstring

writ_scan

Scan a local directory for consequential writes (no gate call). LOCAL-ONLY: this tool never calls the Writ gate, needs no API key, and never rewrites files. It runs the pywrit scanner in-process over the directory: Python (ast, always available), plus TypeScript/JavaScript and Go (tree-sitter, scan-only exactly as the CLI reports them - the scanner never instruments those files). Prerequisite: the pywrit scanner must be installed in the same Python environment as this server; TS/JS and Go parsing additionally needs the polyglot extra: pip install "pyw…

ParameterTypeDescription
path *string
include_non_productboolean
max_findingsinteger

writ_explain_receipt

Fetch a receipt and explain it in plain language. Use this to understand why a writ_check returned ALLOW, DENY, STEP_UP, or REVOKED. Returns the receipt with a human-readable breakdown.

ParameterTypeDescription
receipt_id *string

writ_tenant_notify

Get or update step-up notification settings. With no arguments, returns the current settings. With arguments, updates them: step_up_email enables/disables step-up emails; step_up_webhook_url sets a generic or Slack webhook URL; use an empty string to clear.

ParameterTypeDescription
step_up_emailboolean
step_up_webhook_typestring
step_up_webhook_urlstring

writ_principals

List the tenant's principals (identity directory).

writ_verbs

List the tenant's verb vocabulary, including custom verbs.

writ_keys

List API key metadata for the tenant (never raw keys).

writ_badge_token

Mint a public badge token for the tenant and return its embed snippet. The badge renders the tenant's live gated-write count over the trailing 30 days. The token is shown exactly once: store it, it is needed to revoke the badge. It is public by design (it lives in a README image URL) and cannot be used as an API key. See https://docs.withwrit.com/readme-badge for the verification model. Args: label: Optional private label for your own bookkeeping (max 40 chars, letters/digits/space/_/.-). Never rendered on the badge. Returns the gate payload v…

ParameterTypeDescription
labelstring

writ_badge_revoke

Revoke one of the tenant's badge tokens. Its badge image URL 404s from that moment on, so embeds show a broken image rather than a stale claim. Only tokens belonging to the caller's tenant can be revoked. Args: badge_token: The writ_badge_ token to revoke (shown once at mint time).

ParameterTypeDescription
badge_token *string

writ_tenant_invite

Mint a team invite code (writ_inv_...) for your tenant. Share the code with teammates: they pass it as invite_code to writ_join_tenant (POST /v1/keys) to join this tenant instead of creating their own. Creating a new code ROTATES and invalidates the old one, so there is only ever one live invite code per tenant, and only mint when the team needs a fresh code. Returns the gate payload verbatim: inviteCode, tenantId, and a note.

writ_join_tenant

Join an existing Writ tenant with a team invite code. No API key needed. This is the join flow: the endpoint is unauthenticated (the caller has no key yet, that is the point) and issues a fresh API key on the invited tenant instead of creating a new one. This tool is not general key issuance: invite_code is required. Args: email: Contact email for the new key. invite_code: The team's live writ_inv_... code (from writ_tenant_invite, shared by a teammate). tenant_name: Optional display name; only sent when non-empty. R…

ParameterTypeDescription
email *string
invite_code *string
tenant_namestring