Repository navigation
The plugin's status check names the token's source and warns when the saved config names another server - #191
Merged
Merged
Conversation
… 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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
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.jsonholds a token saved for another server. The session primer says the same when the install token was skipped for such a config, and theloom-statusskill 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 readsLOOM_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 (resolveTokenreads it); the status script prints asourceline and warns when the config file is the source and itsurldiffers from the server the check uses.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, thenLOOM_BASE_URL, then localhost. Under Codex, whose entry may be replaced whole in Codex's own config, it checks the hooks' server fromresolveServerUrland compares the config with nothing.applyPluginOptionsreturns the saved configurland whether the config holds a token, andinstallTokenNoticeturns the mismatch the header helper will meet (noLOOM_API_KEY, a config token the hook did not just write, a configurlother than the MCP entry's, which is the option, then Codex's fixed entry, thenLOOM_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=orLOOM_BASE_URL; otherwise it says to put the entry's server's token in the file orLOOM_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. AnormalizeUrlhelper inlib/loom-client.mjsserves the URL handling this change adds, andsameServercompares origins with the loopback spellings folded, so127.0.0.1andlocalhostread 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.loom-statusreference 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, theloom-statusskill, the README, the Codex copies throughagent_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, thenLOOM_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 theserver_urloption is written to one tmp state file per plugin install.resolveTokenkeeps 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 thetokenline by name rather than the last check, sincesourcesits 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
claude plugin update loom@loom.urlthe first-session write placed in~/.loom/config.jsonbeside 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 onmainin 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(installTokenNoticefor the mismatch, same server, no url, other skip reasons and a write;applyPluginOptionsreturningconfigUrl;tokenLookupkinds across the three lookups;mcpServerUrlorder; the saved install URL round trip with removal andstatusServerUrl's order) andagent-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.mjsspawns 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; andloom-client-status.test.mjs(thesourceline's position betweentokenandauth, 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 ranscripts.codegen.agent_plugin_sync(clean), biome and prettier on the changed files,node --checkover every shipped script,claude plugin validatefor the plugin and the marketplace, andtests/unit/test_public_copy.pyandtest_doc_links.py. The plugin evals were not run: they grade theloom-memorywrite 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 inplanMaterialize, 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 typecheckandmake test-unitpass; the integration suite passes if server behaviour changed. (no server change)python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited. (none)frontend/changed. (unchanged)docs/describe the system as it now is, and this description names any operator steps and wire changes.git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code