oz-policy-builder
MCP server

Tools

Nine tools. Five record-and-synthesize core tools, four playground extensions.

Every tool's input and output is a typed Rust struct with full schemars::JsonSchema derives. Fields with Option<T> are optional; all others are required.

record_transaction

Fetch a transaction by hash or simulate a base64-encoded envelope XDR. Returns a typed Recording.

Input

FieldTypeRequiredDescription
network"testnet" | "mainnet"yesNetwork discriminant.
rpc_urlStringnoOverride the default RPC URL for the chosen network.
hashString (hex)one of64-character hex transaction hash. Mutually exclusive with envelope_xdr_base64.
envelope_xdr_base64String (base64)one ofBase64 TransactionEnvelope XDR. Mutually exclusive with hash. Not submitted on chain.
instruction_leewayu64nosimulateTransaction resource budget leeway.

Output

FieldTypeDescription
recording_idStringFresh store ID, rec_<uuid>.
recordingRecordingDecoded recording.
retention_warningOption<String>Soft warning when the source transaction is near retention horizon.

synthesize_policy

Run the decision tree on a stored recording. Returns a PolicySpec.

Input

FieldTypeRequiredDescription
recording_idStringyesRecording ID from record_transaction.
tightness"exact" | "small_margin" | "loose"yesNumeric scaling for i128 constraints.
mode"auto" | "compose_only" | "codegen_only"yesSynthesis path selection.
lifetime_ledgersu32noEmitted as PolicySpec.lifetime_ledgers.
delegated_signerString (C-address)noOverride signer with a contract address.
rule_nameStringnoContext rule name. Defaults to rule-<first-8-of-id>.

Output

FieldTypeDescription
spec_idStringFresh store ID, spec_<uuid>.
specPolicySpecDeterministic synthesized spec.
generated_countu32Number of PolicySlot::Generated entries.
composed_countu32Number of PolicySlot::Existing entries.

simulate_policy

Replay the recording and run the deny suite. Returns the SimReport.

Input

FieldTypeRequiredDescription
spec_idStringyesSpec ID from synthesize_policy.
recording_idStringyesRecording ID for replay.
extra_deny_vectorsVec<DenyVector>noExtra deny vectors appended to the auto-generated suite.

Output

The raw SimReport:

{
  "spec_id": "spec_...",
  "permit": { "passed": true, "error": null },
  "deny_results": [
    { "name": "...", "passed": true, "expected_error_code": 1010, "actual_error_code": 1010 }
  ],
  "total_vectors": 5,
  "passed": 5,
  "timestamp_ledger": 2572326
}

export_policy

Materialize artifacts (Rust source, WASM, install envelope XDR) for a spec.

Input

FieldTypeRequiredDescription
spec_idStringyesSpec ID.
smart_accountString (C-addr)yesTarget smart account.
source_accountString (G-addr)yesFunding source account.
rpc_urlStringyesSoroban RPC URL.
network_passphraseStringyesNetwork passphrase the RPC serves.
account_revision"post_pr_655" | "pre_pr_655" | "unknown"yesSmart-account release vintage. pre_pr_655 and unknown are hard refusals in v1.
format"rust_source" | "wasm" | "install_envelope" | "all"yesArtifact selector.

Output

FieldTypeDescription
artifact_idStringFresh store ID, art_<uuid>.
rust_sourceOption<String>Rendered Track-B source for first Generated slot.
wasm_base64Option<String>Compiled WASM bytes, base64-encoded.
install_envelope_xdr_base64Option<String>Install envelope XDR, base64-encoded.
wasm_hash_hexOption<String>Lowercase hex SHA-256 of the compiled WASM.
resource_urisVec<String>Resource URIs for the produced artifacts.

verify_install

On-chain readback. Calls simulateTransaction(SmartAccount::get_context_rule(id)), decodes the result, diffs against the spec.

Input

FieldTypeRequiredDescription
smart_accountString (C-addr)yesSmart account whose on-chain context rule is inspected.
context_rule_idu32yesContext rule ID assigned at install time.
network"testnet" | "mainnet"yesNetwork discriminant.
rpc_urlStringnoOverride the default RPC URL.
source_accountString (G-addr)noFunded source account for the simulation. Defaults to smart_account.
expected_spec_idStringnoSpec ID to compare against (looked up in store).
expected_specPolicySpecnoInline expected PolicySpec. Takes precedence over expected_spec_id.

Output

FieldTypeDescription
matchesbooltrue iff every field matches.
driftVec<DriftItem>Per-field drift report. Empty when matches is true. Each item: { field: String, expected: Value, actual: Value }.

get_policy_artifacts

Return rendered Rust source and WASM hashes for a stored spec. Powers the playground Source tab.

Input

FieldTypeRequired
spec_idStringyes

Output

FieldTypeDescription
spec_idStringEcho of input.
generated_sourcesVec<GeneratedSource>Each { slot_index, cargo_toml, lib_rs }.
composed_countu32Count of PolicySlot::Existing.
generated_countu32Count of PolicySlot::Generated.
wasm_sha256Option<String>Pre-optimize WASM hash, hex.
optimized_wasm_sha256Option<String>Post-optimize WASM hash, hex.

simulate_custom_source

Compile and simulate a user-edited lib.rs. The playground's inspect-and-modify backend.

Input

FieldTypeRequired
recording_idStringyes
spec_idStringyes
modified_lib_rsStringyes
extra_deny_vectorsVec<DenyVector>no

Output

SimReport, same shape as simulate_policy.

Tool-local error codes

JSON-RPC codeSymbol
-32112E_PREFLIGHT_FORBIDDEN_PATTERN
-32113E_CARGO_BUILD_FAILED

The preflight regex set is the single source of truth for forbidden patterns: unsafe blocks/fns/impls/traits, extern "C", proc-macro attributes, #[link], include_bytes! and include_str!, and the literal string "build.rs". The frontend mirrors this exact regex set client-side, so most rejections never round-trip.

create_snapshot

Persist a session for the share-URL feature.

Input

FieldTypeRequired
recording_idStringyes
spec_idStringyes
modified_lib_rsStringno (set on a custom-source snapshot)
reportSimReportyes

Output

FieldTypeDescription
snapshot_idString8-character Crockford base32 (40 bits of entropy).
expires_atDateTime<Utc>Creation time plus 30 days.

get_snapshot

Retrieve a persisted snapshot.

Input

FieldTypeRequired
snapshot_idStringyes

Output

The full SnapshotRecord:

{
  "snapshot_id": "...",
  "created_at": "...",
  "expires_at": "...",
  "recording_id": "...",
  "spec_id": "...",
  "recording": { /* Recording */ },
  "spec": { /* PolicySpec */ },
  "modified_lib_rs": null,
  "report": { /* SimReport */ }
}

On this page