Govern: Protect a Tool from the CLI
Protect an MCP server tool with consent, watch an agent get refused, approve it and see the call go through, all from the kya-os CLI
Goal
Protect one tool on an MCP server you made with kya-os mcp create, and prove the protection works end to end without opening the dashboard.
By the end you'll have:
- a tool that refuses an agent until its user approves
- a refused call and an approved call, both recorded by KYA
kya-os mcp statusshowing all 11 steps done
Best for: developers who built a server with kya-os mcp create and want to govern its tools from the terminal.
Prerequisites
- The
kya-osCLI, signed in (kya-os login) - A server from
kya-os mcp create, with a key in its.dev.vars - A Cloudflare account, and
npx wrangler logindone once - To connect the server to consent, you must be the project's creator
Time Estimate
10 minutes, once the server is deployed
How protection works
Protection belongs to the project and goes by tool name.
Protecting search protects every tool called search on every server in the project, and the CLI says so when another server has one.
Use a project of its own for a server whose tools you protect differently.
A protected tool refuses an agent that has no consent, and the refusal names where the agent's user can approve. Where that is depends on how the project is set up: KYA's consent page, the project's verified authorization host domain, or the MCP server itself. The CLI follows the address the refusal names, so the steps below are the same in each case.
Step 1: Deploy the server and check it
In the server's folder:
npx wrangler secret bulk .dev.vars
npm run deploy
kya-os mcp statusmcp status lights each step only from evidence.
Before you protect anything, these must be done: key valid, deployed, tools known and listed on Servers.
If one isn't, the status line says why and what to run.
Step 2: Call a tool while it's open
kya-os mcp probe search --args '{"query":"test"}'The probe calls the tool as a throwaway agent, with a new did:key each run.
It prints the result, then waits up to 30 seconds and prints Checkpoint recorded the call.
Step 3: Protect it
kya-os mcp protect searchThe first time, the CLI connects the server to the project's authorization host:
- KYA checks that the server controls its host, from the DID document it serves at
https://<host>/.well-known/did.json. - KYA issues the server's authorization values, once.
- The CLI writes them to
.dev.varsand uploads them withnpx wrangler secret bulk, the values on stdin. - It calls the server so it registers with its new key, and waits for KYA to confirm.
- It revokes the key
mcp createminted, which the new values replace.
Then it sets the protection and makes sure the server sees it before it finishes.
After the first time, protect only sets the protection.
Step 4: See the refusal
kya-os mcp probe search --args '{"query":"test"}'The call is refused, and the probe prints where an agent would send its user:
Refused, as it should be: search needs consent. An agent would send its user to <host>.
Checkpoint recorded the refusal.If the call goes through instead, the probe exits 1 with Not protected: the call went through without consent.
Step 5: Approve, and call with consent
kya-os mcp probe search --args '{"query":"test"}' --delegatedThe probe opens the consent page the refusal names.
Approve the request there.
The probe picks up the credential, makes the call again with it, and prints Checkpoint recorded the delegated call.
On a machine without a browser, add --no-open and open the printed address yourself.
The probe waits 600 seconds for the approval; --timeout changes that.
Step 6: Check every step
kya-os mcp statusWhen the refusal and the delegated call are recorded, the last line reads:
All 11 steps done: <name> is listed, protected, refuses calls without consent and serves calls with it.The server's page under Servers in the dashboard shows the same steps.
Undo
kya-os mcp unprotect searchThe tool is open again. The server stays connected to consent, so protecting a tool later is one command.
When something goes wrong
See the CLI reference for every flag.