Reference · Tools for AI clients

revoke_mcp_token

signature
revoke_mcp_token(str, map | null=) -> bool

What it does

Ends an MCP token by its id, as mcp_tokens gives it: from then on a call that carries it is a 401. It looks among the session's tokens, as mcp_tokens() finds them, or with { user } among all of that user's, which also reaches a token a session made for someone else. It gives whether there was one: true when a token ended, false for an id it did not find (ended already, another user's, made up).

Examples

in a program
route POST /settings/ai/revoke { form: { id: str } } {    revoke_mcp_token(id)    redirect("/settings/ai")}

A token's id is not the token: a page can show ids, and a button to end each, without showing anything an AI client could use.

Outside a request there is no session, so nothing is found:

print(revoke_mcp_token("a111085996bb88a1"))print(revoke_mcp_token("a111085996bb88a1", { user: "ana" }))
output
falsefalse

Edge cases

Errors

An id that is not text stops the program, and quillo check refuses it first: argument 1 of `revoke_mcp_token` must be str, got int.

this one fails
print(revoke_mcp_token(42))
output
line 1: `revoke_mcp_token` takes a token's id, as `mcp_tokens()` gives it, got int

Chaining

Ending all of a user's tokens, say after a password change:

in a program
fn end_all_tokens(user: str) = mcp_tokens({ user }) | map((t) => revoke_mcp_token(t.id, { user }))

See also

mcp_token, mcp_tokens, end_session, Tools for AI clients

Thread
1Useful? Like it, or add to its thread below.

Thread 0 posts

On revoke_mcp_token(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo