Repository navigation
feat(FIX-1905): a project's coding runs get its MCP servers, with each person's own key - #3261
Conversation
…ch person's own key (FIX-1905) A project row names the MCP servers its coding runs get (`mcpServers`, `setMcpServers`). The host defines what each name connects to. Each person sets their own key through the Lab's write-only route; Shift Manager's Settings page writes through it. A Claude Code run reaches the servers through an in-process relay (`mcpTools`), so no key goes on the run's command line, environment, items or records. - tools: MCPManager.callTool and the catalog's plain jsonSchema; header values are scrubbed from connection-error messages. - claude-code: the `mcpTools` option on claudeCodeAgent. - workforce: mcpServers on the project row, setMcpServers, the mcpCredentials collection (setAt only), projectMcpTools. - shift-manager: the mcp-credentials route, the Settings page, linear for the fsd projects. - goal: a projects coding run reads its Linear issue (PASS, both controls FAIL). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AbWGaPRHHDktemkzFXph5b
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 86555967-cf4c-4a54-8957-39bf14008d35) |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Second-look + architecture review (automated, read-only)Reviewed against the approved FIX-1905 direction, so none of this re-argues the spec. The overall shape holds up: the relay is small, the key never enters the run's argv or env, and the 1. Secret scrubbing is implemented twice, and the two copies disagree (worth consolidating in this PR)
2.
|
| # | Finding | Severity | Action |
|---|---|---|---|
| 1 | Two secret scrubbers with different rules | Medium | Consolidate in the manager; add URL; drop scrub |
| 2 | Route builds the user cell from a fabricated flow object | Medium | Confirm a route→collection round-trip test; follow-up issue for an engine helper |
| 3 | Cancel-by-id may miss for numeric ids | Medium | Add numeric-id cancel test |
| 4a | handedTools resolved outside the try/finally |
Low | Move inside or comment the invariant |
| 4b | Plaintext key + debug route read | Follow-up | Track as an issue; soften Settings copy |
| 4c | Write tools auto-allowed with requester's key | Low | Document in projects page |
| 5 | Mixed factory/module-level project writes | Note | None |
| 6 | Docs not run through docs-editor | Process | Run before merge |
No blocking correctness defect found in what I read; I did not run the suites or the goal check.
Generated by Claude Code
The retired-terms guard counts 'person' and 'member' where they mean the signed-in user. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AbWGaPRHHDktemkzFXph5b
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 70f39fd4-ce48-4146-8220-5ac8480acaf1) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8380b039f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Code Snob — already tight. No POC.
Head d07a9521c (d07a9521 only says user where the previous commit said person). I read packages/claude-code/src/sdk/mcp-tools.ts, the mcpTools path in agent.ts, packages/tools/src/mcp/manager.ts (withoutHeaderValues, callTool, plainJsonSchema), packages/workforce/src/projects/project-mcp-tools.ts, mcp-credentials.ts, mcp-server-name.ts, run-project.ts, project-workspace.ts, the defineWriteProject / defineSetMcpServers factories in project-writes.ts, packages/shift-manager/teams/devteam/mcp-credentials.mts, src/lib/mcp-credentials.ts, surfaces/Settings.tsx, the harness, stub, and openLab wiring, plus call-tool.test.ts, mcp-tools.spec.ts, project-mcp-tools.test.ts, mcp-servers.test.ts, and the goal's run.mts.
A rewrite does not shrink the contract:
withoutHeaderValuesstrips that server's header values before the catalog and the warn line.scrubthen strips the URL and every key from this run, which is what the status line asserts (GITHUB_URL,mcp.github.example,SENTINEL). The warn line still names the address. One function would hide the address from the operator log, or still need both input sets.RelayedMcpToolmatchesClaudeCodeMcpToolon purpose. Workforce does not take a dependency on claude-code.inProcessMcpServeris the five methods the SDK asks for.RpcError,objectSchema,errorResult, andtoCallToolResultare one use each. Pulling in the MCP SDK'sServeradds a dependency to delete a tested protocol. The file header is why no schema library sits in between.namedand the resolver both callrunProjectOf. A helper is a function for two lines. Callingnamedfrom the resolver reads the project twice.defineMcpCredentialsCollectionreturns one collection so two blocks meet.statusOfis already the route and the start line.mcpCredentialProblemis already the route and the page's refusal. Settings is the one form.- The Lab test's HTTP server is the real client path. The workforce suite's scripted client is the no-network path. The goal's
/procwalk and held-out issue are that check. - The option JSDoc is the canonical explanation. The README and the docs page are the two reader surfaces. The changeset is the one consumer sentence. The Settings paragraph in the shift-manager README matches the overview the way the paragraphs around it already do.
Left as recorded: named(ctx), the move into run-project.ts, the chief of staff omitting mcpServers, header scrubbing in the manager, and no ask tool through mcpTools.
Sent by Cursor Automation: Code Snob
There was a problem hiding this comment.
Simplify review (FIX-1905)
Verdict: The overall shape looks like the right one for the security model (host URLs, project names, per-user keys, relay in the host process). Pulling runProjectOf out of project-workspace so workspace and MCP share one reader is a real simplification win, and leaning on createMcpManager / callTool instead of a second HTTP client in workforce is the correct reuse.
I would not swap the in-process bridge for @modelcontextprotocol/sdk here: the Claude Agent SDK wants { type: "sdk", instance } with a thin connect(transport) surface, and remote MCP inside the child would fight the “key never leaves the host” rule. @flow-state-dev/mcp is the wrong direction (FSD as server, not client relay).
Where the PR feels heavier than it needs to be is mostly lifecycle and duplication, not the three-party config model:
Cleaner alternatives worth considering
-
Run-level
close, not per-serverclose—projectMcpToolshangs the samemanager.closeon everyRelayedMcpServer, andclaudeCodeAgentthenPromise.allSettleds everyserver.close()infinally. That works today becausecloseis idempotent, but it papers over ownership (tests already dedupe closes). A smaller API would return{ servers, close }once, or document that only the harness callscloseonce. -
One
runProjectOfper coding attempt — MCP resolution andprojectWorkspace/feeds.cwdeach callrunProjectOf, so a typical run does duplicate store reads (heldTask, workstream/project rows). If latency matters for short runs, cache the result on the harness callback context for the attempt (or thread a shared “run project” through workspace + MCP wiring in shift-manager). -
Relay-only manager mode in
tools/mcp—projectMcpToolsonly needs catalog +callTool, butconnectstill builds fullGeneratorToolhandlers viamcpToolToHandleron every run. For large catalogs (e.g. Linear), that is wasted connect-time work. AcreateMcpManager({ mode: "relay" })(or a slimcreateMcpRelayClient) would drop handler allocation until something actually needs generator tools. -
Unify secret scrubbing —
scrubinproject-mcp-tools.tsandwithoutHeaderValuesinmanager.tssolve the same problem twice. A sharedredactSecrets(text, secrets[])intools/mcp(or core utils) would be one place to audit. -
HTTP path constant for MCP credentials — workforce adapter defines the route;
shift-manager/src/lib/mcp-credentials.tshardcodes/api/flows/mcp-credentials. Export one constant from workforce (or a tiny shared contract module) so client and host cannot drift. -
Type bridge instead of
as unknown as LooseBlockContext—HarnessCallbackContext→LooseBlockContextat the MCP resolver boundary is the same smell asheldTask; a narrow input type onrunProjectOfwould remove repeated casts.
What I would not chase in this PR
- Merging
RelayedMcpToolandClaudeCodeMcpToolvia a cross-package import (dependency arrow is wrong; a neutral harness-tool shape incoreis a follow-up if a second harness copies the struct). - Moving
mcpCredentialsAdapterinto workforce without an explicit engine boundary decision. - Replacing the goal under
goals/a-projects-coding-run-reads-its-linear— it is large but appropriate for proving the full path.
Nits / optional
fromWorkstreamusesctx.session.identity.userIdwhilefromProjectusesrunOwnerOf— same intent, slightly different null paths.inProcessMcpServerswallows transport send failures on JSON-RPC errors (.catch(() => {})); fine if intentional, worth a one-line comment.host.mtsrepeatsObject.keys(options.mcpServers ?? {})in several places; one localofferedMcpNameswould trim noise.
Merge posture: I am not blocking on the above; they are simplification and perf hygiene rather than correctness bugs. The security split and test coverage look thoughtful. If you address only one follow-up before merge, I'd pick run-level close or document that harness must call close once — that is the piece most likely to bite when manager.close behavior changes.
No code changes from this automation run; review only.
Sent by Cursor Automation: Review For Best Approach
…hared close once, scrub call errors and short keys (FIX-1905) - claude-code: the mcpTools resolver runs inside the run's try/finally and is raced against the run's signal; an abort stops the wait, and what the resolver answers later is closed. A close several servers share is called once. - workforce: a relayed tool call's failure has the server's address and the owner's key taken out before it reaches the run. - tools: connection errors redact every credential word of a header value, however short (a leading scheme word is kept); redactSecrets is the one redaction helper, used by the workforce relay too. - shift-manager: the credentials route and its client share one path constant. - claude-code: say why the in-process server's failed error send is ignored. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AbWGaPRHHDktemkzFXph5b
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 579dd511-0bd8-4310-8637-53dcfcc56089) |
|
@claude resolve conflicts |
Resolve the workforce README API table: keep this branch's project MCP rows and main's defineWorkstreamBlocks row (leadFit, openWorkstreamTool). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AbWGaPRHHDktemkzFXph5b
|
Conflicts resolved in 0612bbf by merging Typecheck passes for tools, claude-code, workforce, shift-manager and harness-manager. Tests pass for tools, claude-code, workforce and harness-manager. Five shift-manager tests fail locally: four in Generated by Claude Code |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: ed383208-5be8-4d4d-b6d7-3f409150c557) |
|
Test (1/3) is red, and it is not this PR's failure. The failing test is
Generated by Claude Code |
…orkstream test The coordinator's post is now a dispatchTask row (FIX-1872), so the scripted script must post with dispatchTask, not handOff. Same one-line change as #3272; it no-ops once main carries it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AbWGaPRHHDktemkzFXph5b
|
I ported #3272's fix for the red test into this branch as a37149f, the same one-line change to Generated by Claude Code |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 2d5d9ee8-a977-4ce2-a3cf-9b906d7bb04c) |


Requested by Jake · project thread
The problem
A coding run on the FSD project cannot read Linear. The agent gets an issue id and no way to read the issue. The person must paste the issue in, or the agent guesses. A run on a project gets the MCP servers that the server machine's own Claude Code settings hold. The project does not control them.
What this does
mcpServers). A member changes the list withsetMcpServers. The host defines what each name connects to. The row holds names only.mcpToolsoption onclaudeCodeAgent). The key does not go into the run's command line, environment, items or records.The goal check passes with real Claude Code and real Linear. Both controls fail as they must.
What's asked of you
Nothing new. This implements the approved direction in the spec.
Parts worth reviewing closely
The rest of this is for whoever reviews the code.
packages/shift-manager/teams/devteam/mcp-credentials.mts, the key route. Is the caller always the verified principal, and can no answer, refusal or log line carry the value? If this is wrong, one person can write another person's key, or a key leaks into a log.packages/claude-code/src/sdk/mcp-tools.tsandpackages/workforce/src/projects/project-mcp-tools.ts, the relay. Does each run get exactly the project's servers (strictMcpConfig, claude.ai connectors off), and does every path close the connection, including abort? If this is wrong, a run reaches servers the project did not name, or connections stay open.packages/tools/src/mcp/manager.ts,withoutHeaderValues. This is beyond the spec. A failed connection put theAuthorizationheader value in the catalog error and in aconsole.warnline. The fix removes header values from those messages. Is this scrub enough, or must the manager stop logging the message completely?Known gap, filed as FIX-1955 (High): the engine's debug routes (
/debug/resources*) skipclient.*shaping by design (packages/engine/src/routes/debug-snapshot.ts), so when debug endpoints are on, they return a stored key. No declaration on the Workforce record can close this:exposeis already set, and debug reads ignore it. The fix needs a generic engine marker that debug reads honor, so it is out of scope here. Debug endpoints are off by default.Deliberately not here: MCP for workers that do not code, OAuth sign-in to Linear, a general secrets store, and an ask tool for the harness manager through
mcpTools(theask.tsheader now says that it is possible).Spec:
specs/issues/FIX-1905/· Linear: FIX-1905 · Epic: FIX-1903 · Depends on FIX-1904 and FIX-1926 (merged) · This PR merges.How to review this — altitude, what's in scope, what's deliberately unsettled
Engineering calls — decided along the way, no product sign-off needed
named(ctx). It gives the project's server names with no key read and no connection. The scripted harness uses it to say that its run goes without those servers (BR-24). If this is wrong: one more method on a public interface.project-workspace.tstorun-project.ts.project-workspace.tslost about 170 lines and the behavior did not change; the workspace suites pass with no edit to them. If this is wrong: a review of a move that looks like a rewrite.createProjectomitsmcpServers. A chief of staff cannot name servers for a project; a member sets them. If this is wrong: one more step for a person who wants Linear on a new project.Deviations from the spec
docs-writeranddocs-editoragents did not run. I transcribed the approvedDOCS.mddrafts. Additions beyond the drafts: one sentence oncallToolintools/mcp.md, and the sidebar entry forshift-manager/settings. Please readapps/docswith that in mind.fsdLab in-process throughopenLab, with a scratch checkout mapped as the profile maps this repository, and a scripted chief of staff. It skipsstartHarness, because the probe reports no Claude account in this environment while the Agent SDK still runs.goal.md→ Anti-game gives the reasons.Verification
Typecheck, each exit 0:
pnpm --filter @flow-state-dev/{tools,claude-code,workforce,shift-manager,harness-manager} typecheck, andtsc --noEmitingoals/.Tests:
The one shift-manager failure is
test/command.test.ts→getAssetPath(). It fails the same way onmainwith this change stashed.New suites:
tools/test/mcp/call-tool.test.ts(6),claude-code/test/sdk/mcp-tools.spec.ts(9),workforce/test/project-mcp-servers.test.ts(9),workforce/test/project-mcp-tools.test.ts(11),shift-manager/test/mcp-servers.test.ts(12, with a real local HTTP MCP server).Red states, each seen to fail and then restored:
checkedMcpServersneutered: 4 fail.exposeremoved from the key collection: BR-9 fails.Docs:
apps/docspnpm buildexit 0, no broken links.Goal check:
pnpm tsx goals/shift-manager/a-projects-coding-run-reads-its-linear/run.mts, with real Claude Code (Agent SDK 0.3.234) and real Linear.mcp__linear__get_issuecall. One process was read in the run's places. The key was in none of its command line or environment, the items, the requests, the sessions or the task.GOAL_CONTROL=no-linearmcp__linear__call. The run said no Linear tool was connected.GOAL_CONTROL=no-keymcp__linear__call. The session said the key forlinearis not set.The verdict log is in
goals/shift-manager/a-projects-coding-run-reads-its-linear/goal.md.Changesets: workforce minor, claude-code minor, tools patch.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AbWGaPRHHDktemkzFXph5b
Generated by Claude Code
Note
High Risk
Touches authentication-adjacent credential storage, HTTP routes, and relay of third-party API keys into coding runs; incorrect isolation or logging could leak secrets (debug routes noted as a known gap).
Overview
Project coding runs can use MCP tools (e.g. Linear) with per-user keys held by FSD, not by the agent process.
Projects gain
mcpServers(names only) andsetMcpServers; Workforce adds user-scopedmcp-credentials/*,projectMcpTools(connects with the run owner’s key and relays tools), andcreateMcpManager.callToolplus catalogjsonSchemaandredactSecretson connection errors.claudeCodeAgent({ mcpTools })exposes host-defined in-process MCP servers withstrictMcpConfigand connectors disabled when set, including lifecycle and abort handling.Shift Manager adds Settings (
/settings) and a Lab/api/flows/mcp-credentialsroute (write-only, bearer-scoped); the fsd profile wires Linear and both default projects tolinear. Docs, changesets, and a goal check verify the key never reaches the run.Reviewed by Cursor Bugbot for commit a37149f. Configure here.