Repository navigation
Description
Context
A hosted Claude turn sees two copies of every Apify tool. The copy with the plainer name never works.
- Interactive hosted turns load the project's
.mcp.json, and with it the in-workerbrain mcpserver.strictMcpConfigis set only for an autonomous envelope (packages/ui-backend-claude/src/sdk-options.ts:399). - That server always registers
brain_apify_*(registerApifyTools,packages/core/src/mcp-server.ts:703, called at:786), backed bycreateStandaloneApify, which needsBRAIN_APIFY_LEDGER. - The host never passes
BRAIN_APIFY_LEDGERorAPIFY_TOKENto a subprocess (HOST_ONLY_SECRET_ENV,packages/ui-sdk/src/server/subprocess-env.ts:34). Everymcp__brain__brain_apify_*call therefore refuses withaccounting_unavailable/ledger_unset(packages/core/src/lib/apify/standalone.ts:83). - The working copies are the host's
mcp__brain-ui__brain_apify_*. Both sets have the same names and descriptions, so the model cannot tell them apart.
Observed on a hosted 0.44.0 install (2026-11-06). Asked what LinkedIn data could be collected, the model called mcp__brain__brain_apify_approvals. It got ledger_unset and told the user Apify was not enabled. The user objected that it was configured. Only then did the model retry mcp__brain-ui__brain_apify_approvals, which worked. The governance record shows the failed call as a roadblock (tool_error, family mcp:brain:brain_apify_approvals).
Compute had the same problem, fixed in #3107/#3108. IN_WORKER_COMPUTE_TOOLS (packages/ui-backend-claude/src/sdk-options.ts:47-53) is disallowed in every session (sdk-options.ts:427), and packages/ui-backend-claude/tests/stable-roster.test.ts:39-41 pins that. Apify was never added next to it.
Scope
- Add
IN_WORKER_APIFY_TOOLS, built fromAPIFY_TOOL_NAMESwith themcp__brain__prefix, next toIN_WORKER_COMPUTE_TOOLS. Disallow it in every Claude session, whatever the configuration, as compute is. The tool list must not depend on configuration (provider history). - Extend
stable-roster.test.tsto assert, in every mode, that every in-worker Apify tool is indisallowedTools. - Check the Pi backend for the same exposure. Pi enables the fixed host Apify capability in its session environment (
currentCaps,packages/ui-backend-pi/src/session-pool.ts:70-77); inspect the concrete worker registration before claiming the in-worker.mcp.jsoncopies are exposed there. If the in-worker server's copies reach a Pi turn, close that the same way. If not, say so in the PR.
Out of scope
- Standalone
brain mcp/brain apifyoutside a hosted turn. WithBRAIN_APIFY_LEDGERset, the operator's own process must keep working. - Giving workers the ledger or the token.
- Apify policy, approvals or pricing.
Acceptance criteria
- No hosted session's tool list exposes
mcp__brain__brain_apify_*. Themcp__brain-ui__brain_apify_*tools are unaffected. - The exclusion holds whatever the host configures: Apify enabled or disabled; interactive, autonomous or voice.
- A roster test derived from
APIFY_TOOL_NAMESfails if a new Apify operation is added without being excluded. Mutation receipt: drop one name from the list and the test fails.
Verification
bun run test packages/ui-backend-claude/tests/stable-roster.test.ts- A hosted interactive turn with Apify enabled lists only the
mcp__brain-ui__Apify tools.
Contract impact
None. This removes an unusable duplicate from the hosted tool list. Host tool names and the standalone MCP surface are unchanged.
Bounded reproduction — 2026-11-09
Inspected source: 9c7eb25825fdad5f4485db0df472188805edb450; Bun 1.4.4 (38afee6c8), frozen lockfile, isolated temporary checkout, repository test wrapper and offline preload. Command: bun run test ./tmp/triage/apify-roster.test.ts. A temporary keyless fixture assembled the real createClaudeSdkTurn for a hosted governed session, derived the ten mcp__brain__brain_apify_* names from APIFY_TOOL_NAMES, and checked disallowedTools. All ten were absent; IN_WORKER_APIFY_EXCLUDED failed expecting an empty missing-name list. This establishes the missing exclusion in assembled options; it does not claim a paid Apify call or a live Claude tool-list observation. The fixture failed at the named behavioral assertion, after module loading succeeded. Temporary diagnostic fixtures are outside authored source; this triage changes no product code.
Triage 2026-11-09 at main 9c7eb25825fdad5f4485db0df472188805edb450: Recorded the bounded intended-assertion failure and clarified current source/verification. The existing p1 and 0.45.0 commitment are preserved. It remains standalone: the GitHub-tools epic does not own this backend correction, and no existing open epic owns its full deliverable.
Activity
schlessera commentedon Nov 15, 2026
Claimed for implementation. Claim token:
claim-116b0db1. Branch:fix/3788-exclude-in-worker-apify.collisions: closure-only overlaps with open drafts, no path collision
schlessera commentedon Nov 15, 2026
Merged in #4021 as
ed4eb5a0ccc319e481882d8d8368bd1968d1c262(candidate run 43750083047 passed; the main run on the squash is in progress).IN_WORKER_APIFY_TOOLS, built fromAPIFY_TOOL_NAMES, is disallowed in every Claude session next toIN_WORKER_COMPUTE_TOOLS. The host'smcp__brain-ui__brain_apify_*tools and standalonebrain mcpare unchanged.stable-roster.test.tsasserts the exclusion in every interactive mode, plus a 16-case matrix (interactive or autonomous × hosted or unhosted × Apify enabled or disabled × typed or voice). Failing first: 17 failures onIN_WORKER_APIFY_DISALLOWED*. Mutation (droppingbrain_apify_revoke): the same 17 fail and name the dropped tool..mcp.jsondoes, the copies disappear from the deferred listing and ToolSearch after the change. They are listed and loadable on the base.brain_apify_*tools are host bridge tools.disallowedToolsdoes not filter.