Kimi Code CLI

Wire KYA into Kimi Code so every tool call the agent makes passes Shield’s evaluate first. Allow runs, Deny stops, Hold waits for a person.

Setup

kya connect kimi

That writes a shield-kya entry into ~/.kimi-code/mcp.json under mcpServers. For a per-project setup instead:

kya connect kimi --project   # writes ./.kimi-code/mcp.json

No app restart: open a new session to load shield-kya. Kimi Code registers MCP servers at session start.

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

What KYA reports

Every tool call Kimi routes through MCP 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.

Files written

Scope Path
Global ~/.kimi-code/mcp.json
Project ./.kimi-code/mcp.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. Open a new Kimi Code session.
  2. Ask the agent to list its MCP tools. kya.policy_evaluate, kya.session_ingest, kya.request_approval should appear.
  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 (trail) (--irreversible without a policy never auto-allows).

Uninstall

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

Troubleshooting

Honesty note

Kimi decides which tools go through MCP. KYA gates the ones that do. A tool Kimi 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 -- kimi "summarize this repo"

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.