Build with the local Soterias SDK. Get started with Python and TypeScript.
SoteriasDocsBuild
Core components

Execute a protected SQLite operation

Send a request to Rust's fixed SQLite route. Policy, warrant, permit and broker checks run before the effect. Inspect the returned status and receipt evidence instead of treating every return as success.

When to use this

Use this when an application needs native policy and broker enforcement around a configured SQLite operation or protected read.

Install the matching API preview

These examples use the API 2 preview, not names promised by the public RC5 release. Existing RC5 entry points remain available. The Python wheel below is verified on Windows x64; it is not a cross-platform release.

shell
python -m pip install https://docs.soterias.io/downloads/api-preview/soterias_local-0.1.0rc5%2Bapi2-cp311-abi3-win_amd64.whl
shell
npm install https://docs.soterias.io/downloads/api-preview/soterias-core-0.1.0-rc.5-api.2.tgz
npm install --save-dev typescript@5.8.3 @types/node@24

Python imports soterias. TypeScript imports @soterias/core. Use Python 3.11+ for this wheel and Node 22.23.4+ for these examples. For a .mts file, compile with npx tsc example.mts --target ES2022 --module NodeNext --moduleResolution NodeNext --skipLibCheck, then run the emitted .mjs file.

Before you run

Set SOTERIAS_ROOT to your operator-provisioned host directory, SOTERIAS_CHECKPOINT to its independently retained checkpoint file, and SOTERIAS_UNLOCK to its custody unlock. For protected execution/review also set SOTERIAS_CUSTODY. These are explicit trusted inputs, not placeholder authority to generate inside an agent. Set SOTERIAS_OUTPUT to an existing, empty, operator-provisioned private output directory, independent of the host and signing custody. On Windows it must have the same owner/SYSTEM-only private ACL as other native artifacts; a generic temporary directory is insufficient. The SDK's Rust checks are retained.

The SDK never invents missing identities, policy, trust or custody. For protected features, obtaining those operator artifacts is a prerequisite, just as connecting to a database requires its configured credentials. The native test provisioning helper is contributor tooling, not the application API.

Application walkthrough

Choose Python or TypeScript. Create example.py or example.mts and append that language's chunks in order. Each language forms one complete program; indentation and open blocks carry across chunks.

Import the packages

Import the SDK and standard-library helpers. These are the real package exports used by the executable program.

import json
import os
from pathlib import Path
import tempfile
import time
from soterias import security


def save_artifact(name, data):
    # The operator supplies an existing private parent; create files without replacement.
    descriptor = os.open(output / name, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
    with os.fdopen(descriptor, "wb") as stream:
        stream.write(data)
        stream.flush()
        os.fsync(stream.fileno())

Load operator-selected inputs

These paths and the unlock come from the trusted application, never an agent.

# %% Load operator-selected inputs
# These paths and the unlock come from the trusted application, never an agent.
root = Path(os.environ["SOTERIAS_ROOT"])
custody = Path(os.environ["SOTERIAS_CUSTODY"])
checkpoint = Path(os.environ["SOTERIAS_CHECKPOINT"]).read_bytes()
unlock = os.environ["SOTERIAS_UNLOCK"].encode()
configuration = (root / "document-profile.json").read_bytes()
request = (root / "allow-request.json").read_bytes()


def config(pin):
    return security.Config(root, custody=custody, configuration=configuration,
                           checkpoint=pin, passphrase=unlock)

Prepare an exact operation without executing it

Preparing produces the native binding and retained pin used by the reviewer.

# %% Prepare an exact operation without executing it
# Preparing produces the native binding and retained pin used by the reviewer.
with security.Executor(config(checkpoint)) as executor:
    operation = executor.prepare(request)

Ask the separate reviewer to inspect the original selection

This is trusted reviewer UI code. Never expose this owner as an agent tool.

# %% Ask the separate reviewer to inspect the original selection
# This is trusted reviewer UI code. Never expose this owner as an agent tool.
with security.Reviewer(config(operation.checkpoint),
        signing_key=json.loads((root / "operation-key.json").read_bytes())) as reviewer:
    review = reviewer.prepare(request, operation,
                              expires_at_ms=int(time.time() * 1000) + 300_000)
    print(review.selection.decode())
    answer = input("Inspect this selection, then type APPROVE: ")
    print()
    if answer != "APPROVE":
        raise RuntimeError("Review declined")
    approval = reviewer.approve(review, confirmation=review.confirmation_digest)

Execute through Rust and retain the next checkpoint

A signed approval still passes through native policy, warrant and broker checks.

# %% Execute through Rust and retain the next checkpoint
# A signed approval still passes through native policy, warrant and broker checks.
output = Path(os.environ["SOTERIAS_OUTPUT"])
with security.Executor(config(operation.checkpoint)) as executor:
    report = executor.invoke(request, approval=approval)
    save_artifact("checkpoint.json", executor.checkpoint())
    for index, receipt in enumerate(report.receipts):
        save_artifact(f"receipt-{index}.json", receipt)
    print(json.dumps({"status": report.status, "receipt_count": len(report.receipts),
                      "target_observed": report.target_observed,
                      "native_timing": json.loads(report.native_timing),
                      "receipt_errors": report.receipt_errors,
                      "evidence_directory": str(output)}))

MCP composition

Administration and signing stay on the trusted operator surface shown above. After that setup, an agent uses the real execute_accounting tool below. This client submits an operation through the configured authority; it cannot issue warrants, activate reviews or sign approvals. Native timings and administration diagnostics are read through their SDK owners, rather than invented MCP endpoints.

Configure the host

The following complete host requires the operator's basic SQLite configuration.json, transport-policy.json, exact operation-approval.json and retained checkpoint. For a document or delegated host, use its matching native profile and artifacts; do not substitute the basic host configuration into another profile. Set SOTERIAS_CONNECTION to a new private file for the endpoint/credential, and SOTERIAS_NEXT_CHECKPOINT to a new independently retained file for the shutdown pin. Share only the scoped execution credential with the agent.

host.mjs

Create host.mjs and append these chunks in order. Together they form one complete program; indentation carries across chunks.

Step 1

Import the SDK and standard-library helpers. These are the real package exports used by the executable program.

JavaScript
import fs from 'node:fs';
import path from 'node:path';
import { security } from '@soterias/core';
import { listenAccountingHttp } from '@soterias/mcp-server/accounting-http';

Open the operator-selected native owner

Enrollment, tool review, warrants and exact operation approval happen beforehand.

JavaScript
// %% Open the operator-selected native owner
// Enrollment, tool review, warrants and exact operation approval happen beforehand.
const root = process.env.SOTERIAS_ROOT;
const read = name => fs.readFileSync(path.join(root, name));
const owner = security.Host.open({ root, custody: process.env.SOTERIAS_CUSTODY,
  configuration: read('configuration.json'),
  checkpoint: fs.readFileSync(process.env.SOTERIAS_CHECKPOINT),
  passphrase: Buffer.from(process.env.SOTERIAS_UNLOCK) });

Start a loopback host with authenticated native admission

The agent cannot replace the policy, custody or signed approval through a tool call.

JavaScript
// %% Start a loopback host with authenticated native admission
// The agent cannot replace the policy, custody or signed approval through a tool call.
let listener;
try {
  listener = await listenAccountingHttp(owner, {
    transportPolicy: read('transport-policy.json'),
    operationApproval: read('operation-approval.json'),
  });
  const token = owner.issueTransportCredential().toString('base64url');
  fs.writeFileSync(process.env.SOTERIAS_CONNECTION,
    JSON.stringify({url: listener.url, token}), {flag: 'wx', mode: 0o600});
} catch (error) { owner.close(); throw error; }

Retain the acknowledged checkpoint when shutting down

Keep this output independently of the writable host and signing custody.

JavaScript
// %% Retain the acknowledged checkpoint when shutting down
// Keep this output independently of the writable host and signing custody.
let stopping;
function stop() {
  stopping ??= (async () => {
    await listener.close();
    fs.writeFileSync(process.env.SOTERIAS_NEXT_CHECKPOINT, listener.checkpoint(),
      {flag: 'wx', mode: 0o600});
  })();
  return stopping;
}
for (const signal of ['SIGINT', 'SIGTERM']) process.once(signal, () => {
  void stop().catch(() => { process.stderr.write('host_shutdown_failed\n'); process.exitCode = 1; });
});
// A parent process can close this control stream for orderly local shutdown.
process.stdin.resume();
process.stdin.once('end', () => { void stop(); });

Call the protected tool

Save this complete HTTP client as mcp.mjs. It uses the operator-provided endpoint, scoped token and original request from the environment. Run it with node mcp.mjs; inspect its outcome and verify its signed receipts separately.

Install the matching adapter with npm install https://docs.soterias.io/downloads/api-preview/soterias-mcp-server-0.1.0-rc.5-api.2.tgz. Its SDK peer dependency shares the same native class identities as your installed preview.

mcp.mjs

Create mcp.mjs and append these chunks in order. Together they form one complete program; indentation carries across chunks.

Step 1

Import the SDK and standard-library helpers. These are the real package exports used by the executable program.

JavaScript
import fs from 'node:fs';
import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';

Connect to an operator-configured protected MCP host

The token is scoped to execution. Reviewer keys never enter this client.

JavaScript
// %% Connect to an operator-configured protected MCP host
// The token is scoped to execution. Reviewer keys never enter this client.
const client = new Client({ name: 'invoice-assistant', version: '1.0.0' });
const transport = new StreamableHTTPClientTransport(new URL(process.env.SOTERIAS_MCP_URL),
  { requestInit: { headers: { Authorization: 'Bearer ' + process.env.SOTERIAS_MCP_TOKEN },
    redirect: 'error', credentials: 'omit' } });
try {
  await client.connect(transport);

Execute through the native host's real accounting tool

The host selects routes and approval evidence; the tool receives a request.

JavaScript
  // %% Execute through the native host's real accounting tool
  // The host selects routes and approval evidence; the tool receives a request.
  const requestJson = fs.readFileSync(process.env.SOTERIAS_REQUEST, 'utf8');
  const result = await client.callTool({ name: 'execute_accounting', arguments: { requestJson } });
  if (result.isError) throw new Error('Protected tool refused the request');
  const content = result.content.find(block => block.type === 'text');
  if (!content || content.type !== 'text') throw new Error('Expected an accounting outcome');
  const outcome = JSON.parse(content.text);

Inspect the outcome instead of treating transport success as business success

Verify original receipts separately with your own retained trust.

JavaScript
  // %% Inspect the outcome instead of treating transport success as business success
  // Verify original receipts separately with your own retained trust.
  console.log(JSON.stringify({ status: outcome.status, target_observed: outcome.targetObserved }));
} finally { await client.close(); }

Check the result

The application program prints a JSON result and preserves native refusals. For protected operations inspect status and target_observed: transport success does not imply a completed effect. The pure examples contain assertions for their exact expected values. Successful startup is not proof of production enrollment, a physical human review or current authority.

Put it into a workflow

Use the AML walkthrough for protected document reads, reviewed writes and signed outcome checks. Use multi-agent workflows for personal and enterprise orchestration. Keep each agent's proposals separate from operator authority.

Search guides, examples and API reference.