Skip to content

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.

15.7 KB
Raw Blame

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 -A or git add .), re-check git status and git diff --staged before 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.js line 23: export const SETTINGS_URL = 'https://three.ws/settings/mcp-tools';, quoted by createPolicy() in every tool_disabled refusal (line 145) across every hosted MCP server. packages/mcp-policy/README.md line 217 confirms: "quoted in every refusal." api/_mcp-studio/dispatch.js line 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 in mcp_tool_settings ..., written by /settings/mcp-tools through /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.js already exports loadToolSettings(userId, apiKeyId) (reads the account row and, if present, the per-key override row) and invalidateToolSettings(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 call invalidateToolSettings(user.id) after every successful write.
  • packages/mcp-policy/src/groups.js lines 59-86 already export GROUPS, 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's settingsToTokens() (lines 112-122) is the function that actually consumes a saved row: it reads settings.groups and settings.tools only (confirmed: no tiers key 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 (per enablementFromTokens()'s documented precedence, "tool over group over tier"), so switching on a group such as trading or wallet is 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 a tiers key to what gets written.
  • docs/prompts/03-mcp-tool-policy-skill.md line 9 already lists this exact gap as open, written before this order: "the /settings/mcp-tools page and the /api/mcp-tools writer for mcp_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

  1. Read api/_mcp/policy.js in full (currently ~200-300 lines; read all of it), focusing on loadToolSettings, invalidateToolSettings, and the SETTINGS_TTL_MS memo, to confirm nothing else needs to change there.
  2. Read packages/mcp-policy/src/groups.js in full (GROUPS, GROUP_IDS, TIERS, DEFAULT_TIERS) and packages/mcp-policy/src/enablement.js's settingsToTokens and resolveEnablement to confirm the exact settings shape consumed.
  3. Read api/notifications/preferences.js in 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).
  4. Write a new endpoint api/mcp-tools.js (or api/mcp-tools/index.js, match whichever file-per-route convention api/notifications/preferences.js's sibling routes use for a single-segment path; confirm by checking vercel.json for how api/notifications/preferences.js is 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 via loadToolSettings(user.id) from api/_mcp/policy.js (import it; do not reimplement the SQL).
    • PUT (or PATCH, match the verb api/notifications/preferences.js uses 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 an INSERT ... ON CONFLICT (user_id) WHERE api_key_id IS NULL DO UPDATE against mcp_tool_settings, merging into the existing settings.groups jsonb rather than replacing the whole settings object (so a future tools-level override, if ever added, is not clobbered). Call invalidateToolSettings(user.id) after the write. Gate with requireCsrf the same way api/notifications/preferences.js does.
  5. 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.js modeled on an existing tests/api/*.test.js settings-writer test (check tests/api/ for one testing notifications/preferences.js or a similarly-shaped settings endpoint and copy its DB-mocking approach). Assert: (a) GET with no saved row returns account: {} and the full GROUPS list; (b) PUT {groups:{trading:false}} then GET reflects trading: false while other groups remain absent/default; (c) an unknown group id in the PUT body is rejected with a 4xx, not silently stored; (d) invalidateToolSettings is 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.
  6. Build the page. Decide the route by following the existing /settings convention from order 455's investigation: public/settings/index.html is the identity/security SPA with hash tabs; /settings/mcp-tools is a distinct, deeper path already hardcoded by SETTINGS_URL as 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. Create public/settings/mcp-tools/index.html (a new, small standalone page, following the structural pattern of public/settings/index.html's <head>/brand/i18n script includes, but its own self-contained script, not reusing the identity SPA's navigate() router) that:
    • On load, calls GET /api/mcp-tools, renders one row per entry in the returned groups array (label + summary from GROUPS, matching the exact copy already written in packages/mcp-policy/src/groups.js, do not rewrite the summaries), with a toggle reflecting account[group.id] ?? true (groups are enabled by default when unset, matching defaultEnablement()'s "nothing in groups means use the tier default" semantics; do not default an unset group to false, 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 the PUT/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.js lines 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 (check grep -rn "mcp-policy" docs/ data/pages.json first rather than guessing a URL).
  7. 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.html rule 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-tools is still reachable, i.e. placed before that catch-all in the routes array, since vercel-style route arrays match top to bottom).
  8. Add the new page to data/pages.json (so it is sitemap-indexed, matching the project convention tests/pages-routes.test.js checks for) if that test's logic applies to this kind of page; read that test first to confirm whether a page needs a pages/<name>.html source to qualify, and only add the pages.json entry if your new file's location satisfies that check, otherwise state in your report why it was intentionally left out.
  9. 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 the api/mcp-tools.js path to whatever you actually named the file in step 4) and fix anything it flags.
  10. Add a data/changelog.json entry (tag feature, link /settings/mcp-tools) describing that agents and connectors can now turn on disabled tool groups themselves instead of hitting a dead link, then run npm run build:pages and confirm only the expected generated files change.
  11. Read the full diff and confirm every changed/added line is one of the changes above.

Done when

  • GET /api/mcp-tools and a PUT/PATCH writer both exist, are covered by tests/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.js passes 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-tools via a new vercel.json rule, rendering the live GROUPS list from @three-ws/mcp-policy (no hardcoded duplicate copy of group labels/summaries) and the account's actual saved state from GET /api/mcp-tools (no mock data).
  • An unknown group id sent to the writer is rejected, not silently persisted.
  • npm run check:rules on the touched paths reports no violations.
  • A changelog entry exists and npm run build:pages ran 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.