Live MCP token usage audit (Archolith Skree) for OpenCode sessions. Tracks per-server token spend and waste patterns in real time.
The cleanest integration of the four agents — runs in-process as a TypeScript plugin,
no subprocess spawn or stdin/stdout overhead. Uses the real OpenCode sessionId for
perfect file scoping.
curl -fsSL https://raw.githubusercontent.com/Archolith/archolith-mcp-audit/main/scripts/install.sh | bash -s -- opencodeThe installer clones https://github.com/Archolith/archolith-audit-plugin-opencode to
~/.archolith/plugins/archolith-audit-plugin-opencode, verifies dist/index.js, verifies the
managed Python runtime, and writes the OpenCode plugin plus MCP config.
Clone the repo:
git clone https://github.com/Archolith/archolith-audit-plugin-opencode \
~/.archolith/plugins/archolith-audit-plugin-opencodeAdd to OpenCode config (~/.config/opencode/opencode.json):
{
"plugin": [
"/home/you/.archolith/plugins/archolith-audit-plugin-opencode/dist/index.js"
],
"mcp": {
"archolith-audit": {
"type": "local",
"enabled": true,
"command": ["python", "-m", "archolith_mcp_audit.bootstrap", "mcp", "--agent", "opencode"],
"environment": {
"MCP_AUDIT_ENABLED": "1",
"PYTHONPATH": "/home/you/.archolith/plugins/archolith-audit-plugin-opencode"
}
}
}
}On first MCP startup,
the plugin creates an isolated runtime under ~/.archolith/venvs/opencode-pyXY
and installs requirements.txt there. It does not mutate your global Python
environment.
cd archolith-audit-plugin-opencode
npm install
npm run buildAdd to OpenCode config:
{
"plugin": ["/absolute/path/to/archolith-audit-plugin-opencode/dist/index.js"],
"mcp": {
"archolith-audit": {
"type": "local",
"enabled": true,
"command": ["python", "-m", "archolith_mcp_audit.bootstrap", "mcp", "--agent", "opencode"],
"environment": {
"MCP_AUDIT_ENABLED": "1",
"PYTHONPATH": "/absolute/path/to/archolith-audit-plugin-opencode"
}
}
}
}Start an OpenCode session. After a few tool calls, call mcp_audit_summary via the
audit MCP tools. Should show per-server data. Check ~/.archolith/sessions/ for the
JSONL file — it should be growing as tools are called.
To verify the Python runtime without starting a full OpenCode session:
PYTHONPATH="/absolute/path/to/archolith-audit-plugin-opencode" \
python -m archolith_mcp_audit.bootstrap check --agent opencodepackage.json ← npm package manifest (opencode-plugin keyword)
tsconfig.json ← TypeScript compiler config
src/index.ts ← plugin entry point (in-process, no subprocess)
requirements.txt ← Python runtime dependencies
archolith_mcp_audit/ ← bundled core Python package
- Runs in-process: no subprocess spawn, no stdin/stdout overhead
context.sessionIdis the real OpenCode session ID — perfect file scoping- TypeScript: type-safe, IDE support
tool.execute.aftergivesevent.resultdirectly — no payload parsing needed
- npm package publication is pending. Use the GitHub clone path until the npm package is published.
- Python 3.10+ on PATH with
venvandpip - Network access on first MCP startup unless the managed venv is already populated
- Node.js 18+ recommended for OpenCode; the plugin bundle avoids newer syntax for compatibility
- OpenCode