OpenCode

Wire KYA into OpenCode so tool calls the agent routes through Shield’s MCP gate pass Shield’s evaluate first and are recorded. OpenCode’s built-in tools do not go through the gate and are not evaluated or recorded. Allow runs, Deny stops, Hold waits for a person.

Setup

kya connect opencode

That writes a shield-kya entry into ~/.config/opencode/opencode.json under the mcp key. For a per-project setup instead:

kya connect opencode --project   # writes ./opencode.json

Restart OpenCode after connecting. MCP servers load at startup.

Prefer editing by hand? Copy opencode/opencode.example.json into place and merge the mcp section yourself.

What KYA reports

Each tool call OpenCode routes through Shield’s MCP gate lands on the receipt: tool id, decision (Allow / Deny / Hold), timestamp, and a clipped, redacted preview of what would change. Open it with kya receipt --open, or watch live in the host’s MCP panel.

Files written

Scope Path
Global ~/.config/opencode/opencode.json
Project ./opencode.json

Connect merges. Your other MCP servers and settings stay as they were. If the existing file doesn’t parse as JSON, connect stops and tells you. It never overwrites a config it cannot read.

Verify

  1. Restart OpenCode.
  2. Ask the agent to read a file. On the receipt you should see a record (trail) row for the call.
  3. Offline smoke, no cloud needed:

    kya wrap --offline --tool-id Write --irreversible --args '{"path":"x.ts","content":"hi"}'
    

    Expect a REQUIRE_APPROVE row in the record (--irreversible without a policy never auto-allows).

Uninstall

Edit ~/.config/opencode/opencode.json and delete the shield-kya entry under mcp. Nothing else is installed: no daemon, no background process. (kya connect opencode --force rewires the entry if you only want to refresh it.)

Troubleshooting

Honesty note

OpenCode decides which tools go through MCP. KYA gates the ones that do. A tool OpenCode executes outside MCP is outside the gate. Do not treat this setup as full coverage of the agent.

Wrap fallback

Works with or without MCP:

kya wrap --offline -- opencode run "refactor src/"

Wrap evaluates the command itself before it runs and records a row in the record. Use it for hosts, shells, or scripts that never speak MCP.