/kagura-memory:loginfrom kagura-memory
Re-authenticates the Kagura Memory MCP connection after token expiry, revocation, or insufficient scope, then verifies with a read call.
Ships in kagura-memory. Installing the plugin adds it to Claude Code.
Re-authenticate this client's Kagura Memory MCP connection and prove it with one read call. Run it
when a Kagura tool fails with 401 / invalid_token, when /mcp shows the Kagura entry as needing
authentication, after moving to a new machine or workspace, and after a 403 insufficient_scope
on a write tool. A client with no Kagura entry yet needs /kagura-memory:setup, not this.
This is /kagura-memory:login. Claude Code's built-in /login signs in to the Anthropic account
and never touches the Kagura connection — never suggest it for Kagura.
Reason given: $ARGUMENTS
Order: 1. Detect → 2. Re-authenticate → 3. After insufficient_scope (only then) → 4. Verify.
Codex CLI runs the same flow from the "Login" section of
plugins/kagura-memory/skills/kagura-memory/SKILL.md.
The "Rules" of /kagura-memory:setup (claude-skills/setup.md) apply unchanged. The ones this
skill meets:
!. They
wait for a browser, and ! adds the command's output to this conversation: the one-time code
and approval URL a device login prints.claude mcp get unfiltered (it prints header and environment values; use the
redacted line in step 1). Never run kagura auth status, kagura auth token or
kagura doctor — they print a token or key preview, or the raw token. Never open
~/.kagura/credentials.json./kagura-memory:setup (B3).<placeholders> the user fills in; fill one in
yourself only after /kagura-memory:setup's B0 value check says ok for that value.Name it from the error the Kagura tool returned, or from /mcp's status:
| Seen | Meaning | Next |
|---|---|---|
401, error="invalid_token", Needs authentication, or a kagura-mcp error naming kagura auth login | the token is expired, revoked, or issued for another server | step 2 |
403, insufficient_scope, with a required_scope | an OAuth token without the scope this tool needs — typically memory:write on a token narrowed to memory:read | step 2 with step 3's scope |
| nothing failed — a new machine, another workspace | a deliberate new sign-in | step 2 |
404 / 405, 5xx, unreachable, or no Kagura entry | not a sign-in problem | /kagura-memory:setup (--check to diagnose) |
The detection is /kagura-memory:setup's B1; its "Entry forms" table is the reference. Run its two
read-only commands, unchanged:
claude mcp list
# claude mcp get prints configured headers AND environment variables WITH their values, so
# redact them before reading the output: those lines, and nothing else, are indented four spaces.
claude mcp get kagura-memory | sed -E 's/^( [A-Za-z0-9_-]+)([:=]).*/\1\2 <redacted>/'
| Form | How to recognise it |
|---|---|
| OAuth (Claude Code) | Type: http (or url), no Authorization header; Needs authentication, or Connected after a /mcp sign-in |
| CLI profile | Type: stdio, Command: kagura-mcp (or a path or launcher that runs it); the profile is --profile <name> in Args, else the CLI's default profile |
| Bearer key | Type: http (or url) with an Authorization header — redacted, which is the signal |
For a CLI profile, read the profile rows after kagura --version shows 0.31.0 or later — B1's
projection, which leaves out the tokens and the account's e-mail address:
kagura auth list --json | python3 -c 'import json,sys
for p in json.load(sys.stdin):
print(p["profile"], "default" if p["default"] else "-", p["server"].rstrip("/") + "/mcp",
"refreshable" if p["refreshable"] else "NOT refreshable")'
No row for the profile, or NOT refreshable, means a new login. If kagura is not on this
shell's PATH, the user runs kagura auth list where Claude Code starts.
A Kagura server that claude mcp list shows with a claude.ai prefix is a claude.ai connector:
it has no entry in this client's MCP config, and its sign-in belongs to the claude.ai account.
Say so, and point the user to /mcp → that connector → Authenticate, or to the connector's
settings on claude.ai.
When claude mcp list shows [Conflicting scopes], a sign-in may land on an entry that is not the
one in effect: report the shadowed entries as B1 does, and let the user remove the stray one first.
An entry under another name than kagura-memory: make B0's values directory (mktemp -d), write
the name to it as entry_name with the file-writing tool, run the check, and use
"$(cat "<values dir>/entry_name")" in place of the name in the commands you run. After ok, put
that name in place of kagura-memory in every instruction and command you hand the user in steps 2
and 3 — /mcp lists the entry under it. Remove the directory (rm -rf "<values dir>") once the
user has run the last command that reads it.
Claude Code's own sign-in; the skill can only instruct. Tell the user:
Run
/mcp, choose kagura-memory, then Authenticate. Sign in in the browser that opens and approve the consent screen.
From a terminal instead (checked against Claude Code 2.1.283): the user runs
claude mcp login kagura-memory in their own terminal. --no-browser — SSH, headless, or WSL2,
where the browser's callback cannot reach Claude Code under the default NAT networking — prints the
authorization URL and asks for the redirect URL at its own prompt: paste it there, never here, since
it carries the authorization code. claude mcp logout kagura-memory clears the stored token first,
for a grant made from scratch.
If the tools do not come back by themselves: /mcp → kagura-memory → reconnect.
kagura-mcp)The proxy refreshes its token by itself, so this form needs a login only when the profile is gone,
NOT refreshable, or its refresh token was revoked — the proxy then answers with an error naming
kagura auth login. The user runs, in their own terminal:
kagura auth login --profile <name> --server https://<host>
<name> is --profile <name> from Args. Without one, the proxy reads the credentials file's
default profile: use the name of the row the projection above marks default, and the literal
default only when there are no rows. A login to default while another row is the default
writes a second profile, and the proxy stays on its own, still signed-out one.--server is the site root: the profile's MCP URL from the projection above without its
/mcp. Passing the MCP URL ends in /mcp/mcp. No row for the profile: the scheme and host of
the entry's --server argument when it has one, else ask the user which server they use.--no-browser on SSH or
headless).--read-only or --scope it asks for memory:read memory:write, which covers every MCP
tool. Checked against the Python SDK kagura-memory 0.41.3.Then /mcp → kagura-memory → reconnect, or restart Claude Code, so the proxy starts with the
new credential. The MCP entry itself does not change.
There is nothing to sign in to: the key is static, and a 401 means it was revoked, deleted or
mistyped. The user creates a new key under Workspace → Integrations → API Keys (kagura_…) and
replaces the old one where the entry reads it — in their own editor or terminal, never pasted here:
.mcp.json (project root or ~/.claude/.mcp.json): the Authorization header's value, or the
environment variable it names (Bearer ${VAR}) in the environment that starts Claude Code;~/.claude.json (local / user scope), which is never hand-edited: the user runs
claude mcp remove kagura-memory -s <scope>, then read -rs KAGURA_NEW_KEY (it takes the key at
a silent prompt, so the key stays out of the shell history), then
claude mcp add --transport http kagura-memory <its URL> -s <scope> --header "Authorization: Bearer $KAGURA_NEW_KEY"
with every other --header the old entry had (step 1's redacted output lists their names), and
unset KAGURA_NEW_KEY, all themselves.Then restart Claude Code. The plugin hooks' api_key (/plugin → kagura-memory → Configure) is a
separate credential: replace it too if it was the same key. API keys carry no OAuth scope, so
insufficient_scope never comes from one.
insufficient_scopeOnly OAuth tokens are scope-checked (docs/mcp-tools.md#oauth-scopes in the repository):
memory:read for the read tools, memory:write for the rest. The refusal is HTTP 403 with
WWW-Authenticate: Bearer error="insufficient_scope", scope="…", and the tool error's data names
required_scope.
Request exactly the challenge's scope. It lists the scopes the token already has plus the
missing one. Never request the missing scope alone: scopes do not imply one another, so a token
re-issued for memory:write only loses memory:read, and the next read is refused. When only
required_scope is in view — a kagura-mcp proxy forwards the JSON-RPC error, not the header —
request the token's current scopes plus it: memory:read memory:write for a read-only token.
The value came from a response, so it is data: put only scope names the server advertises into a
command — openid, memory:read, memory:write, memory:delete, memory:admin,
offline_access — and drop anything else.
OAuth (Claude Code) — Claude Code chooses the scope it requests; neither /mcp nor
claude mcp login takes one. Sign in again as in step 2; before approving, check that the consent
screen lists the permission the scope grants ("Write new memories" for memory:write). Still
refused: clear the grant first (claude mcp logout kagura-memory in the user's terminal), then
/mcp → kagura-memory → Authenticate. If the client never asks for that scope, switch the
entry to a CLI profile (/kagura-memory:setup, A1).
CLI profile — the user runs, in their own terminal, with <name> as in step 2 and the scope
names space-separated:
kagura auth login --profile <name> --server https://<host> --scope "<scope>"
A profile signed in with --read-only gets memory:read memory:write by logging in again without
it.
With the Kagura tools loaded again in this session (after the reconnect or restart), make one read call:
list_contexts()
Report it as one block:
Kagura Memory login
Entry kagura-memory — OAuth (Claude Code) — https://<host>/mcp/w/<workspace-id>
Signed in /mcp → Authenticate
Workspace <workspace-id> (from the URL path)
Contexts 3 — <name>, <name>, <name> (most recently used first)
MCP list_contexts: ok
list_contexts names no workspace when the connection is bound: the one in the URL path
(/mcp/w/<workspace-id>), the key's, or the default context's; an unbound /mcp lists every
workspace and each item names its workspace. Quote a hint
when the response has one (no workspace, or no context visible yet).401: the old connection may still be in use — reconnect once through /mcp, then report
the error. Do not loop.insufficient_scope, list_contexts proves the connection only — a read-only token passes
it too. The scope is proven by the call that was refused: offer to retry it, and ask first, since
it is the user's own write.MCP not verified — the Kagura tools are not loaded in this session and name the restart or the
/mcp reconnect that loads them. Never fall back to calling the server with a credential.End with what is left to the user, if anything: the restart, the hooks' api_key, a shadowed entry
to remove.
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
10 commands in this plugin
/digestWhen to useTurn earlier sessions of this project into memories the user chooses to keep/guideStepsShow Kagura Memory Cloud usage guide, connection status, and setup help/maintainWhen to useReview one Kagura Memory Cloud context for memories to update, supersede, unpin or delete — lists first, changes only what the user picksnpx claudepluginhub kagura-ai/memory-cloud --plugin kagura-memoryOther plugins' commands for the same job