opencode

A setup guide for connecting CCE, a context-search service, to OpenCode, a terminal-based coding assistant. It configures the connection in OpenCode's project file so the assistant can discover the service.

In plain words
What is it for?
Use it to run CCE setup, add or create opencode.json, verify context_search calls, and check whether query usage is being tracked.
Why use it?
It avoids guessing the correct configuration format and helps confirm that OpenCode can call the context-search tool.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/elara-labs/code-context-engine/opencode
Clone the repo
git clone --depth 1 https://github.com/elara-labs/code-context-engine
Per session 10 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 399 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00010 $0.00399
Opus 5 $0.00005 $0.00199
Sonnet 5 $0.00002 $0.00080
Haiku 4.5 $0.00001 $0.00040

Measured yesterday against content hash 4159c68371d4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

opencode scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs-src/src/content/docs/agents/opencode.md · 54 lines

What it actually says

OpenCode uses a single opencode.json file in the project root for all configuration, including MCP servers.

Quick setup

cce init              # Auto-detects OpenCode if opencode.json exists
cce init --agent all  # Explicitly includes OpenCode

Files created

opencode.json

CCE adds its MCP server entry to the existing opencode.json (or creates one if it does not exist).

{
  "mcp": {
    "context-engine": {
      "type": "local",
      "command": ["cce", "serve", "--project-dir", "/path/to/your/project"]
    }
  }
}

Note: OpenCode uses "mcp" as the servers key, with "type": "local" and "command" as an array (not a string with separate "args").

No instruction file

OpenCode does not use a separate instruction file. The MCP server registration is sufficient for OpenCode to discover and use CCE's tools.

Verify it's working

  1. Start an OpenCode session after running cce init
  2. The context_search tool should be available
  3. Ask a code question and check the tool output for context_search calls
  4. Run cce savings to check if queries are being tracked

Troubleshooting

OpenCode doesn't detect the MCP server

Check that opencode.json exists in your project root and contains the context-engine entry. If you have an existing opencode.jsonc (with comments), CCE merges into that file.

"cce: command not found"

Ensure cce is on your PATH. If installed with uv tool install, add ~/.local/bin to your shell profile.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 54 lines · 10 tokens per session scan A 4159c68371d4

Subscribe to this mod's changes

opencode is an agent published in the GitHub repository elara-labs/code-context-engine (407 stars, last pushed 8d ago), licensed MIT. It adds 10 tokens to every session and 399 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.