Docs / SDKs and APIs

SDKs and APIs

Agents reach TraceMem over MCP, over HTTP, or through one of our SDKs, and model clients reach it by pointing their base URL at the gateway. Every route arrives at the same governed path, so an agent can use whichever suits it and every control still applies.
SDKs
TypeScript, Python
Agent surfaces
MCP and HTTP
Gateway
Anthropic- and OpenAI-compatible
Integrations
Claude Code, Vercel AI SDK, OpenCode, OpenClaw

The surfaces

Which surface an agent uses is a question of convenience, not of what gets governed. Grants, purposes, policy, PII processing and the trace are the same on all of them.

For agents

The agent MCP server, the HTTP runtime API, and our SDKs over them. An agent authenticates as itself and can carry a token naming the person it acts for.
  • Port 9001 (MCP)
  • Port 8080 (HTTP)

For model clients

Anthropic- and OpenAI-compatible endpoints. An existing SDK or coding agent changes its base URL and nothing else.
  • Port 8080

Install an SDK

Each SDK installs from its language's public registry and connects with the agent's key and your deployment's URL. From there, a decision is two calls.

@tracemem/ts-sdk on npm · Node.js 18 or later

  1. Install the package
    npm install @tracemem/ts-sdk
  2. Connect it to your deployment
    export TRACEMEM_API_KEY="<the agent's key>"
    export TRACEMEM_API_URL="<your TraceMem URL>"

    Both are on the agent's connection panel in the dashboard.

  3. Record a decision
    import { TraceMemClient } from "@tracemem/ts-sdk";
    
    const client = TraceMemClient.fromEnv();
    
    const decision = await client.open("support_reply");
    // Read products, process PII and call models through TraceMem here.
    await decision.close({ outcome: "commit" });

What the SDKs cover

The SDKs cover the agent runtime at parity: a typed method for each operation, helpers for the decision lifecycle, and a call that waits for an exception to be resolved and reports the outcome either way.

What they cover

The operations an agent performs at runtime. Configuration is done in the dashboard or through the admin MCP server.

  • decisions
  • products
  • PII processing
  • governed model calls
  • document redaction
  • exceptions
  • retrieval

Any other language

Anything that speaks JSON-RPC or HTTP calls the MCP server or the HTTP API directly. Worked examples are in the full documentation.

  • Go
  • Java
  • Rust
  • C++
  • Zig

Agent MCP server

JSON-RPC 2.0 over HTTP, authenticated with Authorization: Agent <key>. The agent sees the published products it has been granted and nothing behind them.
AreaTools
Decisionsdecision_create, decision_record, decision_read, decision_write, decision_evaluate, decision_request_approval, decision_add_context, decision_get, decision_close, decision_supersede, decision_search, capabilities_get
Evidencedecision_trace, decision_receipt
Productsproducts_list, product_get
PIIpii_process, pii_response_process
Exceptionsexception_get, exception_list
Retrievalretrieval_evaluate_query, retrieval_evaluate_source, retrieval_filter_results, retrieval_record_injection, retrieval_record_opaque

HTTP runtime API

Everything the agent MCP server does, over plain HTTP under /v1/runtime/decisions. The person an agent acts for travels as X-Tracemem-End-User-Token and is verified against your identity provider, not taken on trust.

Same grants and purposes

An agent reaches exactly the products it was granted, for the purposes they allow, whichever surface it uses.

Same policy and PII

Evaluation, exceptions and PII processing run on the same path as they do for MCP calls.

Same trace

Every call writes the same events to DecisionDB, so the record does not depend on the transport.

Model gateway endpoints

Two client-compatible surfaces in front of every configured model provider. Either one reaches any provider, with requests, responses and streams translated as needed.
Anthropic-compatible
POST /v1/proxy/anthropic/v1/messages
GET  /v1/proxy/anthropic/v1/models
OpenAI-compatible
POST /v1/router/v1/chat/completions

Claude Code and other Anthropic clients set ANTHROPIC_BASE_URL to the proxy. OpenAI SDKs set their base URL to the router. Identity, PII and policy apply to both, and both are written to the trace. The providers behind the gateway are listed in Integrations.

Admin MCP server

For administrative automation: an MCP server authenticated as a user rather than as an agent, on its own port so it can be exposed to a narrower network than the agent surface. Credentials stay out of reach through it.

Configuration

  • agents
  • connectors
  • products
  • policies
  • approval routes
  • webhook integrations

Operation

  • users
  • traces
  • trace export
  • system status

Agent frameworks and coding agents

Packages that put an existing agent or coding assistant on the governed path without rewriting it.

Claude Code

A plugin with commands, agents, hooks and a skill, so the decisions in a coding session are recorded and governed where the work happens.

In Claude Code
/plugin marketplace add tracemem/tracemem-claude-code-plugin
/plugin install tracemem@tracemem-plugins
Then set, in the environment
export TRACEMEM_API_KEY="<the agent's key>"
export TRACEMEM_MCP_URL="<your agent MCP URL>"

Vercel AI SDK

TraceMem tools for applications built on the AI SDK, ready to hand to any model call.

Install
npm install @tracemem/vercel-ai @tracemem/ts-sdk zod

OpenCode

A plugin that brings decision recording and governance into OpenCode sessions.

opencode.json
{
  "plugin": ["@tracemem/opencode-plugin"]
}
Then set, in the environment
export TRACEMEM_API_KEY="<the agent's key>"
export TRACEMEM_MCP_URL="<your agent MCP URL>"

OpenClaw

A plugin and a skill that put OpenClaw agents on the governed path.

Setup guide in the customer portal.

OpenAI Codex, and any IDE or agent that speaks MCP, connect through the agent MCP server and the gateway.