Skip to content

Documentation · Task

API, CLI and MCP

Ask The Warden about the commit you are standing on, from a terminal or a coding agent, without copying change IDs or reading CI logs.

Overview

Developer preview — live acceptance pending

One authenticated API serves every client. The PowerShell script and the MCP server are thin clients over it: they never evaluate policy and never decide clearance. They read the decision The Warden already recorded for the exact build.

  • Transport: Forge App REST APIs with Atlassian OAuth 2.0 (3LO) and the custom scopes below. A site administrator opts in to App REST APIs first.
  • Identity: the signed-in Jira user. Reads need a current Jira role of tester or higher and an active repository grant for that user.
  • Targeting: repository and commit are inferred from your Git workspace. Without a commit, the latest indexed change for the repository is used and the response is marked inferredTarget. An explicit commit that matches several builds is refused rather than guessed.
  • Access, the base URL and tokens are provisioned during pilot onboarding. See Onboarding and Permissions.
Never put a token in a prompt, a command argument, a tool argument or source control. The clients accept only a short-lived user access token, supplied through the process environment or a vault. A CI token, personal access token, client secret or refresh token is not accepted.

The six operations

OperationRouteScopeReturns
warden.statusGET /developer/v1/statusread:warden-developer:customCurrent decision, target, failures, evidence
verification.obligationsGET /developer/v1/obligationsread:warden-developer:customUnsatisfied obligations and next actions
verification.plan.getGET /developer/v1/planread:warden-developer:customConfigured contracts before you code
evidence.listGET /developer/v1/evidenceread:warden-developer:customUp to 20 provenance-linked receipts
quality.explainGET /developer/v1/explainread:warden-developer:customDeterministic explanation and remedies
verification.run.requestPOST /developer/v1/verification/requestrequest:warden-verification:customSee Not yet available

GET query parameters for the four decision reads: repositoryRef (owner/repo), optional 40-character commitSha and optional environmentRef. The plan read takes repositoryRef, targetType (branch, jira_issue or change_set), targetId, and optionally contractName and expectedCommitSha. The plan never generates policy and never returns clearance. Responses are capped at 64 KiB.

PowerShell client

Requires Windows PowerShell 5.1 or PowerShell 7, and Node.js 24 on the path. Configure the base URL (the exact HTTPS Forge App REST URL listed in Atlassian Connected apps; webtrigger URLs are not accepted) and the token:

PowerShell
$env:TESTWARDEN_API_BASE_URL = "<exact HTTPS base URL from Connected apps>"
$env:TESTWARDEN_OAUTH_ACCESS_TOKEN = "<short-lived user access token>"   # or use -SecretName
PowerShell
# From inside your Git checkout; repository and commit are inferred
.\scripts\testwarden.ps1 status
.\scripts\testwarden.ps1 obligations
.\scripts\testwarden.ps1 evidence
.\scripts\testwarden.ps1 explain

# Canonical JSON, unaltered
.\scripts\testwarden.ps1 explain -Format json

# Token from a PowerShell SecretManagement vault instead of the environment
.\scripts\testwarden.ps1 status -SecretName TestWardenOAuth

# Before coding: the configured obligations for your branch
.\scripts\testwarden.ps1 plan

Commands: status, obligations, evidence, explain and plan. Parameters: -Repository, -Commit, -Environment, -TargetType, -TargetId, -ContractName, -Format (compact or json) and -SecretName. Optional environment overrides: TESTWARDEN_REPOSITORY, TESTWARDEN_COMMIT_SHA, TESTWARDEN_ENVIRONMENT, TESTWARDEN_BRANCH and TESTWARDEN_FORMAT=json. The script restores your original environment on exit.

Expected output

In compact mode a fresh CLEARED status prints nothing, so a clean state is silent. HELD prints the failure, the CI assertion link when one is available, the next action and what to verify:

Compact output for a HELD change (illustrative)
HELD: JUnit completed run: 4 test observations; 1 failed, 0 error, 0 skipped. Not passed: failed: payment > declines an expired card.
CI assertion: https://github.com/acme/checkout-service/actions/runs/1000000002/attempts/1
Next: resolve_failing_evidence
Verification: Run fresh CI for this exact new commit; the Warden evaluates independent evidence.
The client exits non-zero when a request fails (for example forbidden), not when a decision is HELD. To fail a pipeline on the decision, use the CI gate, which exits zero only for CLEARED.

MCP server

A standard MCP stdio server for VS Code, Claude Code, Codex and other MCP clients. It speaks newline-delimited JSON-RPC, negotiates protocol versions 2025-06-18 and 2025-11-25, and supports initialize, ping, tools/list and tools/call. All stdout is protocol JSON.

mcp-config.json
{
  "mcpServers": {
    "testwarden": {
      "command": "node",
      "args": ["/path/to/testwarden/scripts/testwarden-mcp.mjs"],
      "cwd": "/path/to/your/git/checkout"
    }
  }
}
  1. Point args at scripts/testwarden-mcp.mjs and set cwd to your Git checkout so the repository and commit are inferred.
  2. Supply TESTWARDEN_API_BASE_URL and TESTWARDEN_OAUTH_ACCESS_TOKEN through your launcher's secured process environment, never in the config text and never in tool arguments.
  3. Ask the agent to call warden.status or quality.explain.

The tools are typed and bounded: warden.status, verification.obligations, verification.plan.get, evidence.list, quality.explain and verification.run.request. Five are read-only. There is no shell, SQL, clearance or approval tool, and tool arguments are limited to 4 KiB. A tool call that is refused returns an error result with a short code instead of remote text.

Download the entry: mcp-config.json.

Reading a response

Every successful result carries schemaVersion: 1, a source of canonical_warden (or the plan source), the exact target (repository, commit, build, environment) and the canonical decision id. States use the API spelling CLEARED, VERIFYING, HELD, NEEDS_APPROVAL and INCOMPLETE.

quality.explain returns mode: "deterministic" and modelInvoked: false: the summary, failed requirement, assertion link and suggested remedies come from recorded evidence and fixed next actions. For a CLEARED change it is quiet (quiet: true, empty summary). Managers can also receive a decision-pinned diagnosis. See AI and data handling for the optional AI explanation.

Full HELD example: explain-response.json.

Errors

The PowerShell client prints TestWarden: <code> and exits non-zero. Common codes:

CodeFix
oauth_required, unauthenticatedThe access token is missing, malformed or expired. Provide a fresh short-lived token. No fallback credential is used.
forbiddenScope, Jira role (tester or higher) or repository grant is missing, or REST APIs are not enabled. See Permissions.
invalid_repositoryUse a single owner/repo. Check your origin remote or set TESTWARDEN_REPOSITORY.
target_not_foundNo change matches that repository, commit and environment. Check that CI has submitted evidence for the commit.
ambiguous_targetSeveral builds match the commit. Add -Environment.
invalid_commitThe commit must be 40 hexadecimal characters.
network_unavailable, developer_unavailableConnection failed or the interface is unavailable. Retry; if it persists, contact support.

Not yet available

  • Approved rerun requests. verification.run.request and rerun exist in the clients but no dispatcher is installed, so the service answers 503 (rerun_unavailable). When enabled it requires the manager role, entitlement and a separately human-approved run, and it returns REQUESTED with progressionAllowed: false, never CLEARED.
  • Repair adapters, autonomous repair, customer-authored contracts and live provider connectors are not part of this surface.

Related tasks

  • Onboarding

    Choose a path, enable access, confirm the first change appears.

  • CI evidence

    Submit JUnit, SARIF or JSON and gate on the exact build.

  • Decisions and approvals

    States, reason codes, next actions and preserved history.

  • Permissions

    Roles, custom scopes and who can read, write or request.

  • AI and data handling

    What is optional, what is consented and what never changes a decision.