Skip to content

The plugin's status check names the token's source and warns when the saved config names another server - #191

Merged
zlareb1 merged 13 commits into
mainfrom
plugin-status-token-source
Nov 3, 2026
Merged

zlareb1 merged 13 commits into
mainfrom
plugin-status-token-source

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

The Claude Code and Codex plugins' status check now says which lookup supplied the token and warns when ~/.loom/config.json holds a token saved for another server. The session primer says the same when the install token was skipped for such a config, and the loom-status skill maps Claude Code's "needs authentication" and "SDK auth failed: ZodError" to their cause.

Why

A person installs the plugin with --config token=… against server B and the loom MCP server shows "needs authentication" with a ZodError from the MCP SDK. The install token reaches the hooks as an environment variable, but the MCP header helper is not a hook and reads LOOM_API_KEY, then ~/.loom/config.json, then ~/.loom/token. The first hook copies the install token into the config only when none of those already holds a token, so a config left behind by another Loom (server A) wins: the helper sends A's token to B, B answers 401, and Claude Code falls back to browser OAuth, which fails with the ZodError on a server that has OAuth off. Nothing in the plugin said any of this. The client check reported the token as valid (it is, for A) and the primer said nothing.

The change surfaces facts the plugin already has:

  • tokenLookup() returns the token with the kind of lookup that answered (resolveToken reads it); the status script prints a source line and warns when the config file is the source and its url differs from the server the check uses.
  • The shell the agent runs the status script from carries no CLAUDE_PLUGIN_OPTION_* (checked from a Bash tool call in a session with the plugin installed), so without help the script would resolve the server from the same config and compare it with itself. The SessionStart hook, which does see the option, saves the install URL to a tmp state file keyed by the plugin's install root (so a Codex install on the same machine, whose hook passes no option, never reads the Claude Code install's URL) and removes it when the option is gone; under Claude Code the script checks the server the MCP entry calls, in its order: the saved install URL, then LOOM_BASE_URL, then localhost. Under Codex, whose entry may be replaced whole in Codex's own config, it checks the hooks' server from resolveServerUrl and compares the config with nothing.
  • applyPluginOptions returns the saved config url and whether the config holds a token, and installTokenNotice turns the mismatch the header helper will meet (no LOOM_API_KEY, a config token the hook did not just write, a config url other than the MCP entry's, which is the option, then Codex's fixed entry, then LOOM_BASE_URL, then localhost) into a primer line, so the agent reads the cause at session start, with or without a token option. The remedy depends on the cause: when nothing named the entry's server, the entry is on its localhost default and the line says to name the config's server with --config server_url= or LOOM_BASE_URL; otherwise it says to put the entry's server's token in the file or LOOM_API_KEY. The plugin README and the integration page, which told a remote-server user that one config file was enough, now say the MCP entry never reads it. The notice is about Claude Code's MCP entry, so the hook emits it only under Claude Code (Codex's entry is fixed in its plugin) and never in agent mode, where the tools send the agent's exchanged token. A normalizeUrl helper in lib/loom-client.mjs serves the URL handling this change adds, and sameServer compares origins with the loopback spellings folded, so 127.0.0.1 and localhost read as one server. Under Codex, whose MCP entry may be replaced whole in Codex's own config, the status script checks the hooks' server and makes no source comparison, and the notice is not emitted.
  • The loom-status reference maps the two client symptoms to the cause and the fix.

Scope and risk

Plugin files only: lib/loom-client.mjs, lib/plugin-options.mjs, bin/loom-client-status.mjs, hooks/loom-session-start.mjs, the loom-status skill, the README, the Codex copies through agent_plugin_sync, and both manifests to 1.2.5. The hooks' behaviour changes in two small ways besides the primer notice: the first-session write saves the server named for the MCP entry (the option, then LOOM_BASE_URL) beside the token, over a url another install left in the file, since that is the server the saved token is sent to and the notice and the status check read the pair; when nothing names a server, the url the file holds stays and no default is written over it; and the server_url option is written to one tmp state file per plugin install. resolveToken keeps its order (the lookup moved into a shared function); an agent whose exchange supplied no token reports no source. The status script's gate on the auth call now checks the token line by name rather than the last check, since source sits between them. No token text is printed: the source line names a lookup or a path, never the value. The saved install URL is one small tmp state file per user, rewritten each session and swept with the other state files after a day idle.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none. Users get it with claude plugin update loom@loom.
  • Rollback: revert. The tmp state file is swept within a day. A url the first-session write placed in ~/.loom/config.json beside an install token stays, as the token itself always did; it is the server the token is for.

Tests

node --test integrations/claude-code-plugin/tests/*.test.mjs: 407 pass with the two files that fail on main in this sandbox (loom-status-node, repo-identity, where apt and git are unavailable) left out; CI runs them all. New or extended: plugin-options.test.mjs (installTokenNotice for the mismatch, same server, no url, other skip reasons and a write; applyPluginOptions returning configUrl; tokenLookup kinds across the three lookups; mcpServerUrl order; the saved install URL round trip with removal and statusServerUrl's order) and agent-mode-fallback.test.mjs (a failed exchange yields a FAIL token line and no source line, and never prints the saved personal token); install-token-notice.test.mjs spawns the hook against a local server: with a config saved for another URL it asserts the primer line in Claude Code and its absence under Codex and for an agent whose exchange succeeded, and with a config that names another server but holds no token it asserts the option write puts the option's url beside the token and the next session says nothing; and loom-client-status.test.mjs (the source line's position between token and auth, PASS naming the lookup, WARN on a different server naming the config path, PASS on the same server, absent with no token; a WARN never fails the check). Also ran scripts.codegen.agent_plugin_sync (clean), biome and prettier on the changed files, node --check over every shipped script, claude plugin validate for the plugin and the marketplace, and tests/unit/test_public_copy.py and test_doc_links.py. The plugin evals were not run: they grade the loom-memory write guidance, which this change does not touch.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Checked: the header helper's lookup order against resolveToken, the skip reasons in planMaterialize, and that the status output carries no token value.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed. (no server change)
  • Generated files are regenerated in this PR, not by hand: the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. (none)
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version, and no other open PR uses that version. (1.2.5; open PRs are at 1.2.1 to 1.2.4)
  • The frontend builds and its tests pass, if frontend/ changed. (unchanged)
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

zlareb1 and others added 13 commits November 3, 2026 09:56
… saved config names another server

The MCP header helper never sees the install option: it reads LOOM_API_KEY,
then ~/.loom/config.json, then ~/.loom/token, and the first hook copies the
install token into the config only when none of those holds one. A config
token saved for another server is then sent to this one and refused, and
Claude Code shows the OAuth fallback's error instead of the cause. The client
check now prints a source line, the session primer says so when the saved
config names another server, and the loom-status reference maps the client
symptoms to the cause. Both plugin manifests move to 1.2.5.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
…tart hook saves

The agent's shell carries no install option, so the script resolved the
server from the same config it was meant to question. The hook saves the
option's URL to tmp state; the script takes it after LOOM_BASE_URL. The
primer notice names the URL the MCP entry calls and is skipped in agent
mode; one lookup returns the token with its kind.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
…e option is gone

The Codex copy of the scripts keeps its own file and never writes it. The
first-session write saves the MCP entry's URL beside the token, an exchange
that supplied no token is no source, the hook still copies the install token
in agent mode, and the hook doc and skill name the server order.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
…ault

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
…thout a token option

A config token saved for another server misleads the helper whether or not
the install passed a token. The status server has no env parameter, the
source name has no fallback for a kind the lookup never yields, and the
install-URL test always restores the prior state.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
…llow the notice rule

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
…normalizer

Codex's MCP entry is fixed in its plugin, so the notice about Claude Code's
entry is emitted under Claude Code only. A hook-level test spawns the
SessionStart hook with a config saved for another server and reads the
primer. The notice names the config path in use.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
…MCP entry's server

A url another install left in the config made the notice and the status
check misread a token the hook had written itself. The state helpers take
their directory, so the tests run in their own; the hook-level test cleans
up and asserts a successful exchange.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
…ient checks

The status server takes no env parameter it could only half apply, the
hook-level test asserts the saved install URL and its removal, and the
reference's server row describes the URL the check uses in each client.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
… URL to its default

The status server's last fallback is the MCP entry's default, never the
config's url, and the install token is always written beside the URL its
MCP entry sends it to. The header helper's comment names what it reads.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
…'s url is never overwritten with it

When nothing names the entry's server it falls back to localhost, and the
remedy is to name the config's server, not to swap the token. The install
token's url is written only when the option or LOOM_BASE_URL names one.
The MCP entry's order puts Codex's fixed entry ahead of LOOM_BASE_URL, the
agent-mode line names the server the exchange went to, and the README and
the integration page say the entry never reads the config file.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
…ing; servers compare by origin

Codex's MCP entry may be replaced whole in Codex's own config, which the
plugin cannot read, so there the check keeps the hooks' server and the
source line only names the lookup. Loopback spellings read as one server.
The agent-mode line is tested with a different exchange server.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
…n test uses a live token

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Lareb Zafar <[email protected]>
@zlareb1
zlareb1 merged commit 95e6b44 into main Nov 3, 2026
16 of 18 checks passed
@zlareb1
zlareb1 deleted the plugin-status-token-source branch November 3, 2026 12:04
@pufit pufit mentioned this pull request Nov 4, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant