Use a host-selected MCP tool catalog backed by the same Rust executor. Authenticated clients submit proposals; signed review stays outside the agent tools.
When to use this
Use this when an agent client needs a protected tool while the host retains backend credentials, policy and approval handling.
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.
python -m pip install https://docs.soterias.io/downloads/api-preview/soterias_local-0.1.0rc5%2Bapi2-cp311-abi3-win_amd64.whlnpm 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@24Python 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_MCP_URL, SOTERIAS_MCP_TOKEN and SOTERIAS_REQUEST (the path to your original request JSON) from the trusted accounting host below. Python also needs python -m pip install mcp==1.30.0 httpx. The host must already hold any required exact operation approval.
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 asyncio
import json
import os
from pathlib import Path
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_clientimport 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.
# %% Connect to an operator-configured protected MCP host
# The token is scoped to execution. Reviewer keys never enter this client.
url = os.environ["SOTERIAS_MCP_URL"]
token = os.environ["SOTERIAS_MCP_TOKEN"]
request = Path(os.environ["SOTERIAS_REQUEST"]).read_text(encoding="utf-8")
async def main():
async with streamablehttp_client(url, headers={"Authorization": f"Bearer {token}"}) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()// %% 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.
# %% Execute through the native host's real accounting tool
# The host selects routes and approval evidence; the tool receives a request.
result = await session.call_tool("execute_accounting", {"requestJson": request})
if result.isError:
raise RuntimeError("Protected tool refused the request")
text = next(block.text for block in result.content if block.type == "text")
outcome = json.loads(text) // %% 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.
# %% Inspect the outcome instead of treating transport success as business success
# Verify original receipts separately with your own retained trust.
print(json.dumps({"status": outcome["status"],
"target_observed": outcome["targetObserved"]}))
asyncio.run(main()) // %% 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(); }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.
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.
// %% 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.
// %% 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.
// %% 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.
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.
// %% 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.
// %% 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.
// %% 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.