Claude (Code, Desktop, claude.ai)

Wire KYA into Claude Code or Claude Desktop so tool calls that go through MCP pass Shield’s evaluate first. Allow runs, Deny stops, Hold waits for a person.

Setup - Claude Code

kya connect claude     # user level: merges shield-kya into ~/.claude.json (mcpServers only)

or, for project scope (with --hooks, the hook goes to the project’s .claude/settings.json as well):

cd your-project
kya start              # shows a plan and asks once; wires ./.mcp.json (plus user-level configs for every installed host)
kya start --dry-run    # print the plan, write nothing
kya uninstall          # undo it (see ../uninstall.md)
# or: kya connect claude --project

kya start prints a plan of every file it will create or merge, then asks Apply? [Y/n] (--yes or KYA_YES=1 skips the question; off a terminal it applies only with --yes). It also inits .kya/ (and adds .kya/* and !.kya/policy.json to .gitignore in a git repo) and opens the live activity report. It runs in the background, so your terminal returns immediately (kya stop stops it). It exits by itself when the project folder is removed. It also exits after 30 minutes with no request and no open report page. To change the 30 minutes, set KYA_RECEIPT_IDLE_MINUTES (0 keeps it running). It also exits when its memory (RSS) is above 512 MB (2048 MB when plain-language search is installed); set KYA_RECEIPT_MAX_RSS_MB to change this (0 turns it off). The next kya start starts a new one. Claude Code loads MCP servers at process start; if a session is open, relaunch with claude --resume; it keeps the conversation. kya start --no-open wires without the report; --force rewrites the existing shield-kya entry.

Setup - Claude Desktop

Copy claude/claude_desktop_config.example.json into Claude Desktop’s MCP settings and restart the app. To ship it as a Desktop extension instead, pack with npx @anthropic-ai/mcpb pack (see manifest.json). That pack runs the bundled dist/cli.js, not npx -y.

Setup - claude.ai / Cowork (hosted)

Add a custom connector at https://shield-agent.com/mcp with request header Authorization: Bearer <KYA_API_KEY> (or X-API-Key). Not Directory-listed yet: API-key auth, no OAuth DCR.

What KYA reports

Three MCP tools: kya.policy_evaluate (Allow / Deny / Hold), kya.session_ingest (observe / raise-only risk), kya.request_approval (opens a human Hold; it does not execute the side effect). Every call lands on the receipt with a clipped, redacted change preview: kya receipt --open.

Files written

Setup Path
Claude Code (user) ~/.claude.json (mcpServers merged, all other keys untouched)
Claude Code (project) .mcp.json, .kya/ in your repo
Claude Desktop the app’s own MCP settings file (you paste it)

Connect and kya start merge. Existing servers and keys stay. A symlinked ~/.claude.json (dotfiles setups) is written through to the real file it resolves to.

Project files are different: kya connect --project, kya start, kya init, kya certify, kya orr run, kya receipt and the sandbox state under .kya/ never write outside the project. If .mcp.json, mcp.json, .cursor/, .kya/, a report directory inside the project (such as .kya/certify or ./orr-report) or any other project path is a symlink that resolves outside the project, is a dangling symlink, or is a file with other hard links (the other name may be anywhere, including inside the repo), kya refuses, writes nothing and exits 1 with PROJECT_PATH_REFUSED. An output directory you name outside the project (--out, --out-dir) is used as given, but a link planted at a report file name there is replaced, not followed. A cloned repo cannot use a planted link to make kya edit a file elsewhere on your machine. A symlink that stays inside the project is followed. To fix a refusal, replace the link with a regular file (remove the link, or copy the real content in its place) and run the command again.

Verify

  1. Restart the host after wiring.
  2. In Claude Code, run /mcp. shield-kya should list as connected with the three tools.
  3. Offline smoke:

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

    Expect a REQUIRE_APPROVE row in the record (trail).

Uninstall

Delete the shield-kya block from .mcp.json (or the Desktop settings file) and restart. Remove .kya/ if you don’t want the local record.

Troubleshooting

Honesty note

Claude Code’s built-in tools don’t all route through MCP. KYA gates the MCP path completely; what the host executes natively never reaches evaluate. For shell-level coverage of any command, use the wrap fallback below.

Wrap fallback

kya wrap --offline -- claude "refactor src/"

Wrap evaluates the command itself before it runs and records a row in the record. Exit 0 Allow, 4 Hold, 1 Deny, so kya wrap … && next-step can’t skip the gate.