Qwen Code
Wire KYA into Qwen Code so tool calls the agent routes through Shield’s MCP gate pass Shield’s evaluate first and are recorded. Qwen Code’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 qwen
That writes a shield-kya entry into ~/.qwen/settings.json under mcpServers. For a per-project setup instead:
kya connect qwen --project # writes ./.qwen/settings.json
No restart needed: Qwen Code watches settings.json and starts new MCP servers live.
Prefer editing by hand? Copy qwen/settings.example.json (stdio) into place and merge the mcpServers section yourself.
Hosted variant. Instead of a local stdio server, Qwen can call the hosted MCP endpoint directly: merge qwen/settings.hosted.example.json (httpUrl: "https://shield-agent.com/mcp" + Authorization: Bearer ${KYA_API_KEY}). Pick one: don’t enable the stdio and hosted entries at the same time, or every call gets evaluated twice under two server names.
What KYA reports
Each tool call Qwen 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.
Files written
| Scope | Path |
|---|---|
| Global | ~/.qwen/settings.json |
| Project | ./.qwen/settings.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
- Ask the running session to list its MCP tools.
shield-kyaappears without a restart. - Confirm
kya.policy_evaluate,kya.session_ingest,kya.request_approvalare listed. -
Offline smoke, no cloud needed:
kya wrap --offline --tool-id Write --irreversible --args '{"path":"x.ts","content":"hi"}'Expect a
REQUIRE_APPROVErow in the record (trail) (--irreversiblewithout a policy never auto-allows).
Uninstall
Edit ~/.qwen/settings.json and delete the shield-kya entry under mcpServers. Nothing else is installed: no daemon, no background process. (kya connect qwen --force rewires the entry if you only want to refresh it.)
Troubleshooting
- Server not listed in Qwen. Live reload landed mid-2026. On older builds, restart the CLI. Confirm the entry is under
mcpServersin~/.qwen/settings.json. command not founderrors. Connect wiresnode …/cli.js serve-mcp --stdiofrom the install you ran it from. If you connected via a tempnpxcache and later cleared it, rerunkya connect qwen --forcefrom a real install (npm i -g @shield-agent/kya).- Double decisions on one action. You enabled both the stdio and hosted entries. Remove one.
- Decisions need a key. The wired env sets
KYA_OFFLINE=1, so the server starts keyless and sample-evaluates. Against an authenticated control plane, setKYA_API_KEYin the entry’senvblock (stdio) or use the hosted variant’s Bearer header.
Honesty note
Qwen decides which tools go through MCP. KYA gates the ones that do. A tool Qwen 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 -- qwen "explain this diff"
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.