Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
456. Every disabled-tool refusal points agents at /settings/mcp-tools, a page that was never built
How to run: paste this file's repo path into a fresh Claude Code chat in this repository and say "run this work order". Runnable now, no gate, no owner action required.
Operating clause (binding)
- Read CLAUDE.md first. CLAUDE.md overrides everything, including this file.
- Finish 100% in this session. Never end the turn with a question, an option list, or an unexecuted plan.
- The only permitted stops are the CLAUDE.md stop-and-ask gates (spend/on-chain writes, push/deploy, posting externally, committing content referencing a crypto project other than
$THREE, destroying unrecoverable data). This order touches none of them: it writes settings that gate tool visibility, it does not move funds itself. - Concurrent agents share this worktree: stage explicit paths only (never
git add -Aorgit add .), re-checkgit statusandgit diff --stagedbefore committing. - The em-dash and en-dash characters are banned in everything you write.
Why this matters (measured 2026-10-25)
Every three.ws MCP server refuses a disabled tool call with a message that names a fix URL:
curl -s -o /dev/null -w "%{http_code}\n" https://three.ws/settings/mcp-tools
returns 404 today. find api -iname "*mcp-tools*" finds only api/_lib/viewer-mcp-tools.js (an unrelated module: static tool definitions for the 3D-viewer MCP tools, not the tool-policy settings this order is about). curl -s -o /dev/null -w "%{http_code}\n" https://three.ws/api/mcp-tools also returns 404. grep -rln "mcp_tool_settings" api/ src/ returns exactly two files: api/_mcp/policy.js (reads the table) and api/_lib/migrations/20260922170000_mcp_tool_settings.sql (creates it). There is no writer anywhere in the tree.
The backend this page needs already exists and is already wired to read from the table this order will start writing to:
packages/mcp-policy/src/runtime.jsline 23:export const SETTINGS_URL = 'https://three.ws/settings/mcp-tools';, quoted bycreatePolicy()in everytool_disabledrefusal (line 145) across every hosted MCP server.packages/mcp-policy/README.mdline 217 confirms: "quoted in every refusal."api/_mcp-studio/dispatch.jsline 393 builds the same URL independently for the studio surface.api/_mcp/policy.js's own header comment (lines 1-16, read today) already states the intended wiring in the present tense: "saved settings inmcp_tool_settings..., written by/settings/mcp-toolsthrough/api/mcp-tools" and the migration's own header comment (20260922170000_mcp_tool_settings.sql) says the same thing and documents the exact settings shape:{ "groups": { "<group id>": true|false }, "tools": { "<tool name>": true|false } }.api/_mcp/policy.jsalready exportsloadToolSettings(userId, apiKeyId)(reads the account row and, if present, the per-key override row) andinvalidateToolSettings(userId)(clears the 15-second in-memory memo on every instance after a write, so a save takes effect immediately rather than waiting out the memo). Both exist today and need no changes; the writer endpoint this order adds should callinvalidateToolSettings(user.id)after every successful write.packages/mcp-policy/src/groups.jslines 59-86 already exportGROUPS, a frozen array of{ id, label, summary }for all 26 tool groups ("in the order the settings page and the skill document list them", per its own doc comment, written before this page existed), e.g.{ id: 'trading', label: 'Trading', summary: 'Quote and execute swaps from an agent wallet, copy trading, and signal subscriptions.' }and{ id: 'wallet', label: 'Wallet', summary: 'Agent wallets: balances, portfolio, provisioning, and transfers out.' }. This is the exact data the settings page needs to render; do not invent a second copy of group labels.packages/mcp-policy/src/enablement.js'ssettingsToTokens()(lines 112-122) is the function that actually consumes a saved row: it readssettings.groupsandsettings.toolsonly (confirmed: notierskey is read from saved settings, even though the live spec grammar elsewhere supports tier tokens). This means the correct v1 settings UI is a per-group on/off list, not a per-tier toggle: turning a group on takes precedence over its tools' tiers (perenablementFromTokens()'s documented precedence, "tool over group over tier"), so switching on a group such astradingorwalletis what actually unlocks the financial-tier tools inside it. A UI that only exposed a "financial tier" master switch would not match what the saved-settings format is capable of expressing, and would require inventing a new settings shape the reader does not support. Build the per-group list; do not add atierskey to what gets written.docs/prompts/03-mcp-tool-policy-skill.mdline 9 already lists this exact gap as open, written before this order: "the/settings/mcp-toolspage and the/api/mcp-toolswriter formcp_tool_settings(nothing writes the table yet...)."
Net effect today: every agent, connector, or MCP client that is refused a financial-tier tool (swaps, transfers, launches, domain registration, deletes; the tools gated by tool_disabled) is told to visit a page that cannot load and has no way to turn the tool on at all, short of an operator hand-editing the database or every caller individually discovering and using the X-Three-Tools header / npx three-ws tools CLI escape hatches (which exist but are not self-discoverable from the in-product refusal message itself). This is a live production gap affecting every disabled-tool refusal, documented as open in two places in this repository already, with its entire read path already shipped and only the write path and the page missing.
This is a new finding, not a duplicate: grep -rln "mcp-tools\|mcp_tool_settings" prompts/finish/ before this order returns nothing in the 401-455 range. It is distinct from order 455 (/settings/connections, chat-gateway pairing, a different table and a different API) despite both being settings-page gaps discovered in the same sweep; do not merge them, they have no shared code path.
Task
- Read
api/_mcp/policy.jsin full (currently ~200-300 lines; read all of it), focusing onloadToolSettings,invalidateToolSettings, and theSETTINGS_TTL_MSmemo, to confirm nothing else needs to change there. - Read
packages/mcp-policy/src/groups.jsin full (GROUPS,GROUP_IDS,TIERS,DEFAULT_TIERS) andpackages/mcp-policy/src/enablement.js'ssettingsToTokensandresolveEnablementto confirm the exact settings shape consumed. - Read
api/notifications/preferences.jsin full as the closest existing pattern for a per-user settings writer endpoint in this codebase (zod body schema,getRequestUser, CSRF, a GET that returns the resolved view plus metadata the UI renders from, a PUT/PATCH that merges a sparse override). - Write a new endpoint
api/mcp-tools.js(orapi/mcp-tools/index.js, match whichever file-per-route conventionapi/notifications/preferences.js's sibling routes use for a single-segment path; confirm by checkingvercel.jsonfor howapi/notifications/preferences.jsis routed and mirror it for/api/mcp-tools):GET: require a signed-in user (getRequestUser), return{ groups: GROUPS, account: <account settings.groups or {}>, key: null }(no per-key UI in this order; see Never Blocked). Read the account row vialoadToolSettings(user.id)fromapi/_mcp/policy.js(import it; do not reimplement the SQL).PUT(orPATCH, match the verbapi/notifications/preferences.jsuses for its sparse-merge semantics): body{ groups: Record<string, boolean> }, validated with zod (z.record(z.enum(GROUP_IDS), z.boolean())or equivalent, reject unknown group ids rather than silently storing them), merged onto the existing account-wide row (api_key_id IS NULL) with anINSERT ... ON CONFLICT (user_id) WHERE api_key_id IS NULL DO UPDATEagainstmcp_tool_settings, merging into the existingsettings.groupsjsonb rather than replacing the wholesettingsobject (so a futuretools-level override, if ever added, is not clobbered). CallinvalidateToolSettings(user.id)after the write. Gate withrequireCsrfthe same wayapi/notifications/preferences.jsdoes.
- Write the test first (this endpoint is new code, not a bug fix, but CLAUDE.md's "no mocks, no fake data" and "errors handled at boundaries" rules still apply: write a real integration-style test before claiming it works). Add
tests/api/mcp-tools.test.jsmodeled on an existingtests/api/*.test.jssettings-writer test (checktests/api/for one testingnotifications/preferences.jsor a similarly-shaped settings endpoint and copy its DB-mocking approach). Assert: (a)GETwith no saved row returnsaccount: {}and the fullGROUPSlist; (b)PUT {groups:{trading:false}}thenGETreflectstrading: falsewhile other groups remain absent/default; (c) an unknown group id in thePUTbody is rejected with a 4xx, not silently stored; (d)invalidateToolSettingsis called exactly once per successful write (spy on the import). Run it, confirm the assertions fail against a stub/no-op handler (or against no handler at all, i.e. a 404) before the implementation exists, then implement step 4 and confirm it passes. - Build the page. Decide the route by following the existing
/settingsconvention from order 455's investigation:public/settings/index.htmlis the identity/security SPA with hash tabs;/settings/mcp-toolsis a distinct, deeper path already hardcoded bySETTINGS_URLas a full path (not a hash), so give it its own static entry rather than cramming a 26-row group list into the existing SPA's tab bar. Createpublic/settings/mcp-tools/index.html(a new, small standalone page, following the structural pattern ofpublic/settings/index.html's<head>/brand/i18n script includes, but its own self-contained script, not reusing the identity SPA'snavigate()router) that:- On load, calls
GET /api/mcp-tools, renders one row per entry in the returnedgroupsarray (label + summary fromGROUPS, matching the exact copy already written inpackages/mcp-policy/src/groups.js, do not rewrite the summaries), with a toggle reflectingaccount[group.id] ?? true(groups are enabled by default when unset, matchingdefaultEnablement()'s "nothing ingroupsmeans use the tier default" semantics; do not default an unset group tofalse, that would misrepresent the current effective state). - A single "Save" action that collects every row whose toggle differs from its loaded state into
{ groups: {...} }and sends thePUT/PATCH, then toasts success or the real server error message (no fake "Saved!" if the request failed). - A short explanatory line at the top distinguishing read/write (on by default) from financial-tier tools (off unless the containing group is explicitly turned on), so a user understands what flipping a group does; this can summarize the three-tier model already documented in
packages/mcp-policy/src/groups.jslines 7-20, do not invent new terminology for it. - A link to
packages/mcp-policy/README.md's public-facing explanation if one is published under/docs, or omit the link if none is (checkgrep -rn "mcp-policy" docs/ data/pages.jsonfirst rather than guessing a URL).
- On load, calls
- Add the route to
vercel.json: a rule routing/settings/mcp-tools(and, if the page needs any sub-assets beyond the single HTML file,/settings/mcp-tools/) to the new static file, following whichever single-file-route pattern is simplest among the examples already in the file (e.g. the/settings->/settings/index.htmlrule from order 455's investigation). Add this rule before any catch-all that could otherwise shadow it (check whether order 455 already landed its/settings/(.*)fallback fix by the time you run this; if so, make sure your new specific rule for/settings/mcp-toolsis still reachable, i.e. placed before that catch-all in theroutesarray, since vercel-style route arrays match top to bottom). - Add the new page to
data/pages.json(so it is sitemap-indexed, matching the project conventiontests/pages-routes.test.jschecks for) if that test's logic applies to this kind of page; read that test first to confirm whether a page needs apages/<name>.htmlsource to qualify, and only add thepages.jsonentry if your new file's location satisfies that check, otherwise state in your report why it was intentionally left out. - Run
npm run check:rules -- --paths api/mcp-tools.js tests/api/mcp-tools.test.js public/settings/mcp-tools/index.html vercel.json(adjust theapi/mcp-tools.jspath to whatever you actually named the file in step 4) and fix anything it flags. - Add a
data/changelog.jsonentry (tagfeature, link/settings/mcp-tools) describing that agents and connectors can now turn on disabled tool groups themselves instead of hitting a dead link, then runnpm run build:pagesand confirm only the expected generated files change. - Read the full diff and confirm every changed/added line is one of the changes above.
Done when
GET /api/mcp-toolsand aPUT/PATCHwriter both exist, are covered bytests/api/mcp-tools.test.js, and the test file's assertions are confirmed to have failed before the implementation existed.tests/api/mcp-tools.test.jspasses in full.- The writer calls
invalidateToolSettings(user.id)after every successful write (asserted by the test). - A real page exists at a static path reachable as
/settings/mcp-toolsvia a newvercel.jsonrule, rendering the liveGROUPSlist from@three-ws/mcp-policy(no hardcoded duplicate copy of group labels/summaries) and the account's actual saved state fromGET /api/mcp-tools(no mock data). - An unknown group id sent to the writer is rejected, not silently persisted.
npm run check:ruleson the touched paths reports no violations.- A changelog entry exists and
npm run build:pagesran cleanly.
Never blocked
| Apparent blocker | Resolution |
|---|---|
| "Should per-API-key overrides get a UI too?" | No, out of scope for this order. loadToolSettings already supports a key row and the GET response shape in step 4 reserves a key: null slot for it, but building per-key UI means picking which API key is being edited (a second navigation dimension) and is a bigger, separable unit of work. Ship the account-wide toggle now; a later order can add key-scoped overrides on top of this endpoint without breaking it. |
"Should this expose per-tool overrides (settings.tools), not just per-group?" |
No. 26 groups is already a reasonably sized list; the full tool census is hundreds of entries. The saved-settings reader supports tools for exactly this kind of future refinement, but the account-wide group toggle closes the actual production gap (a 404'd fix-it link in every refusal message) without that complexity. |
"Where exactly should the new page live, public/settings/mcp-tools/index.html or somewhere else?" |
Confirmed by reading SETTINGS_URL in packages/mcp-policy/src/runtime.js: it is https://three.ws/settings/mcp-tools, a path, not a hash. Serve a real static file at that path; do not silently change SETTINGS_URL to point somewhere else; that constant is quoted verbatim in every refusal message already shipped to every connector. |
"What if order 455 (the /settings/connections 404 fix) hasn't shipped yet when I run this?" |
Irrelevant; they touch disjoint files (different APIs, different tables, different pages) and do not depend on each other. Run this order independently. |
Report format
State: the new endpoint's file path and verb(s), the test file and its fail-then-pass sequence, the new static page's path and the vercel.json rule added for it, whether a data/pages.json entry was added (and why, per step 8), the changelog entry, and the commit hash.