OpenCode plugin for TraceMem decision tracking and traceability. This plugin provides tools to create, manage, and track decisions through the TraceMem MCP API.
Add the plugin to your opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@tracemem/opencode-plugin"]
}OpenCode will automatically install the plugin and its dependencies on startup.
Set your TraceMem API key:
export TRACEMEM_API_KEY=your_api_key_hereOr add it to your .env file in your project root.
Override the default MCP server URL (default: https://mcp.tracemem.com):
export TRACEMEM_MCP_URL=https://mcp.tracemem.comAfter installation, verify your setup by asking OpenCode to run:
tracemem_doctor
This will check your API key configuration and test connectivity to the TraceMem MCP server.
The recommended workflow for using TraceMem with OpenCode:
-
Open a decision before starting work:
tracemem_open(action="refactor") -
Add context as you work:
tracemem_note(kind="info", message="Starting refactoring of user service") -
Read decision data when needed:
tracemem_decision_read(product="pg_customers_v1", purpose="order_validation", query={"customer_id": "1001"}) -
Evaluate a policy:
tracemem_decision_evaluate(policy_id="discount_cap_v1", inputs={"proposed_discount": 0.15, "customer_tier": "premium"}) -
Request approval if needed:
tracemem_decision_request_approval(title="Discount Approval", message="Customer requesting 25% discount") -
Write mutations to the decision:
tracemem_decision_write(product="pg_orders_v1", purpose="order_creation", mutation={"operation": "insert", "records": [...]}) -
Close the decision when done:
tracemem_decision_close(action="commit", reason="Order successfully processed")
The tracemem_open tool automatically maps common actions to standardized intents:
| Action | Intent |
|---|---|
edit_files |
code.change.apply |
refactor |
code.refactor.execute |
run_command |
ops.command.execute |
deploy |
deploy.release.execute |
secrets |
secrets.change.propose |
db_change |
data.change.apply |
review |
code.review.assist |
Example:
tracemem_open(action="refactor")
// Automatically maps to intent: code.refactor.executetracemem_capabilities_get- Get MCP server capabilitiestracemem_doctor- Verify plugin setup and connection
tracemem_products_list- List all productstracemem_product_get- Get product details
tracemem_open- Open a new decision with auto-intent mappingtracemem_decision_create- Create a new decisiontracemem_decision_get- Get decision detailstracemem_decision_add_context- Add context to a decisiontracemem_decision_read- Read data through a governed data producttracemem_decision_evaluate- Evaluate a policy within a decision contexttracemem_decision_request_approval- Request approvaltracemem_decision_write- Write mutation to decisiontracemem_decision_trace- Get trace informationtracemem_decision_receipt- Get decision receipttracemem_decision_close- Close a decision
tracemem_note- Add a safe note (automatically sanitized)
The plugin maintains the current decision ID in memory. If you omit the decision_id parameter from decision tools, they will use the most recently created decision (from tracemem_open or tracemem_decision_create).
The plugin automatically sanitizes data to prevent secrets from being stored:
- Redacted keys: Any key matching patterns like
token,secret,password,api_key,auth,credential, etc. will have their values replaced with[redacted] - Size limits: Long strings (>1000 chars) are truncated, arrays are limited to 100 items, and recursion depth is limited to 10 levels
- Applied to:
decision_create.metadatadecision_add_context.datadecision_read.querydecision_write.mutation
- Never include secrets in metadata or notes - Even though redaction helps, it's better to avoid including secrets entirely
- Use
tracemem_notefor safe notes - This tool provides additional safety guarantees - Review before closing - Always review decision data before closing with
commit - Use appropriate actions - Use
abortwhen work shouldn't proceed,commitwhen successful
See the examples/ directory for:
opencode.json- Example OpenCode configurationenv.example- Example environment variable configuration
Apache-2.0