Skip to content

feat(FIX-1905): a project's coding runs get its MCP servers, with each person's own key - #3261

Merged
jhoffner merged 5 commits into
mainfrom
claude/project-thread-i3njgj
Oct 13, 2026
Merged

jhoffner merged 5 commits into
mainfrom
claude/project-thread-i3njgj

Conversation

@jhoffner

@jhoffner jhoffner commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • A project row names the MCP servers that its coding runs get (mcpServers). A member changes the list with setMcpServers. The host defines what each name connects to. The row holds names only.
  • Each person sets their own key on the new Settings page in Shift Manager. The page writes through a Lab route. The route finds the person from the verified bearer, not from the body. The page never shows a key back.
  • When a run starts, FSD reads the requester's key and connects to the server. FSD gives the server's tools to Claude Code in-process (the new mcpTools option on claudeCodeAgent). The key does not go into the run's command line, environment, items or records.
  • A run on a project that names no servers gets no MCP servers. A missing key does not stop the run. The session says which key is not set and where to set it.

What changes

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.

  1. 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.
  2. packages/claude-code/src/sdk/mcp-tools.ts and packages/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.
  3. packages/tools/src/mcp/manager.ts, withoutHeaderValues. This is beyond the spec. A failed connection put the Authorization header value in the catalog error and in a console.warn line. 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*) skip client.* 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: expose is 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 (the ask.ts header 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

How to review this. This implements an approved spec — the approach and the numbered
decisions in its DECISIONS.md are already signed off by a human, so please review the
code against that direction, not the direction itself. The canonical set is retained
at specs/issues/<ISSUE-ID>/ on main; Linear links to it and the original merged spec
PR, which keeps review history. Follow-up amendment PRs explain later direction changes.
Current architecture docs remain the authority for shipped behavior (BP-037).

Most valuable here: correctness on the second path (the legacy shape, the null
boundary, the concurrent case, the cancel path), anything deriving an auth or routing
decision from caller-controllable input, and a behaviour the tests assert around
rather than on.

Already settled upstream: the approach and every decision in the spec's DECISIONS.md
(human-approved — if one is wrong, say so as a spec finding and it gets folded back; don't
re-argue it inline), and the conventions in docs/contributing/best-practices.md.

Engineering calls — decided along the way, no product sign-off needed
  • The resolver has 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.
  • The run code moved from project-workspace.ts to run-project.ts. project-workspace.ts lost 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.
  • The chief of staff's createProject omits mcpServers. 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.
  • The tools manager scrubs header values (see item 3 above). Beyond the spec.
Deviations from the spec
  • Docs prose. The task gave no agent tool to this session, so the docs-writer and docs-editor agents did not run. I transcribed the approved DOCS.md drafts. Additions beyond the drafts: one sentence on callTool in tools/mcp.md, and the sidebar entry for shift-manager/settings. Please read apps/docs with that in mind.
  • The goal check does not serve the profile. It opens the fsd Lab in-process through openLab, with a scratch checkout mapped as the profile maps this repository, and a scripted chief of staff. It skips startHarness, because the probe reports no Claude account in this environment while the Agent SDK still runs. goal.md → Anti-game gives the reasons.
  • The review skill ran as a self-review only. No sub-agent lenses were available.
Verification

Typecheck, each exit 0: pnpm --filter @flow-state-dev/{tools,claude-code,workforce,shift-manager,harness-manager} typecheck, and tsc --noEmit in goals/.

Tests:

Package Result
tools 487 passed
claude-code 317 passed
workforce 1277 passed
harness-manager 271 passed
shift-manager 455 passed, 1 failed, 6 skipped

The one shift-manager failure is test/command.test.ts → getAssetPath(). It fails the same way on main with 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:

  • checkedMcpServers neutered: 4 fail.
  • The other-project guard broken: 2 fail.
  • A planted log of the key value: the sentinel test fails.
  • The abort signal dropped: 1 fails.
  • The seed given to every user, with no stored keys: 8 fail.
  • The connection close removed and the connectors flag dropped: 5 fail.
  • expose removed from the key collection: BR-9 fails.

Docs: apps/docs pnpm build exit 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.

Run Verdict
PASS run PASS on FIX-1951. The answer carried the title after one mcp__linear__get_issue call. 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-linear FAIL, as expected, on FIX-1924: no title, and no mcp__linear__ call. The run said no Linear tool was connected.
GOAL_CONTROL=no-key FAIL, as expected, on FIX-1897: no title, and no mcp__linear__ call. The session said the key for linear is 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) and setMcpServers; Workforce adds user-scoped mcp-credentials/*, projectMcpTools (connects with the run owner’s key and relays tools), and createMcpManager.callTool plus catalog jsonSchema and redactSecrets on connection errors. claudeCodeAgent({ mcpTools }) exposes host-defined in-process MCP servers with strictMcpConfig and connectors disabled when set, including lifecycle and abort handling.

Shift Manager adds Settings (/settings) and a Lab /api/flows/mcp-credentials route (write-only, bearer-scoped); the fsd profile wires Linear and both default projects to linear. Docs, changesets, and a goal check verify the key never reaches the run.

Reviewed by Cursor Bugbot for commit a37149f. Configure here.

…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
@jhoffner jhoffner self-assigned this Oct 13, 2026
@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 13, 2026 10:58pm UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 13, 2026 10:58pm UTC
flow-state-dev-ui Ignored Ignored Preview Oct 13, 2026 10:58pm UTC

Request Review

@linear-code

linear-code Bot commented Oct 13, 2026

Copy link
Copy Markdown

FIX-1905

@cursor

cursor Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot 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)

@jhoffner

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T21:44:36.560901Z e8380b0 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Collaborator Author

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 callTool seam reuses the one MCP client instead of adding a second. The findings below are about leaner shapes and a few second paths. Ordered by value.

1. Secret scrubbing is implemented twice, and the two copies disagree (worth consolidating in this PR)

  • packages/tools/src/mcp/manager.ts withoutHeaderValues strips the header values and each ≥8-char word of them. The manager now owns this for the catalog error and the console.warn.
  • packages/workforce/src/projects/project-mcp-tools.ts scrub(server.error, [url, ...secrets]) then scrubs the same message again with a different rule (whole key only, plus the URL).
  • Because the manager already scrubs the message, the secrets array in the workforce copy is dead weight. The only thing it adds is the URL. Two redactors with different rules is how a future header format (not Bearer <key>) gets scrubbed in one place and leaks in the other.
  • Suggestion: let the manager own it, and add the URL to what it scrubs (it has config.transport.url). Then delete scrub and the secrets collection from projectMcpTools. That also answers the PR's open question 3: scrubbing in the manager is enough as long as it is the single place that does it, and that place has a test with a header format other than Bearer.
  • The ≥ 8 chars heuristic is also worth a look. A short key (e.g. 6 chars) leaves the header value whole-matched only. That is fine today because the whole value is removed first, but a client that echoes only the token half of Bearer abc123 would leak it. Either drop the heuristic and rely on whole-value plus bearer-token extraction, or say in the doc comment that short tokens are only caught as part of the whole header value.

2. mcpCredentialsAdapter resolves the storage cell with a fabricated flow (coupling to engine internals)

mcp-credentials.mts calls resolveUserStorageKey(userId, orgId, { id: "", isolateUserState: false }). That passes a made-up flow-shaped object so that the route computes the same cell the run's mcp-credentials/* collection (flowIsolation: false) will read. If the engine ever changes how the key is derived (e.g. isolation default, or an extra field), the route writes to a cell the run never reads, and the failure mode is silent: Settings shows "set", runs say "key isn't set".

  • The test for it uses a real local HTTP MCP server, which is good, but check there is one test that writes through the route and reads through the resource collection in the same engine. If that exists, the coupling is at least pinned. If it only checks the route's own GET, add the round trip.
  • Longer term the cleaner seam is an engine helper that answers "the user cell for a flowIsolation: false collection" for a transport adapter, so adapters don't hand-build a flow descriptor. Not for this PR; worth a follow-up issue.

3. Hand-written MCP server loop in claude-code/src/sdk/mcp-tools.ts (~180 lines)

inProcessMcpServer implements initialize, ping, tools/list, tools/call and cancellation by hand. The reason (no schema library between, pass JSON Schema through unchanged) is sound, since the SDK's tool() helper wants zod. Two things to weigh:

  • @modelcontextprotocol/sdk's low-level Server takes raw setRequestHandler(ListToolsRequestSchema | CallToolRequestSchema, …) with plain JSON Schema, which would delete the protocol handling and the RpcError class. It is not a dependency of claude-code today (I checked package.json), so adding it is a cost. Recommendation: keep the hand-rolled version, since the protocol surface is tiny and tested (9 tests), but add a one-line comment saying why the SDK's Server was not used so the next reader doesn't redo this evaluation.
  • Cancel path: calls.get(request.params?.requestId as string). JSON-RPC ids may be numbers; the Map is keyed by whatever request.id was. If the SDK sends numeric ids and the cancel notification carries the same number, it works; if either side stringifies, cancels silently miss and the call runs to completion after the run aborted. Please add a test with a numeric id for the cancelled-call case.

4. Second-path checks (BP-035)

  • Close on every path. handedTools is resolved after resolveClaudeAgent(ctx) and before the run's try. Nothing between the two awaits looks like it throws today, but if the code between them ever gains a throw, the connections projectMcpTools just opened are never closed (the finally is the only closer). Cheaper to guard: wrap from resolution onward in the existing try/finally, or note the invariant in a comment at the resolution site.
  • Shared close per server. projectMcpTools hands every server the same manager.close, so Promise.allSettled over N servers calls it N times. It is idempotent so this is correct, but the type (close per server) suggests independent lifetimes. A reader will wonder. One sentence in the RelayedMcpServer doc.
  • Auto-allowed tools. allowedTools gets every relayed tool, including write tools (Linear save_issue, comments) using the requester's own key. That is consistent with "the person's own key", and disallowedTools is the documented escape hatch, but nothing in the project row can mark a server read-only. Not a defect against the spec. Worth stating in docs/workforce/projects.md so a project member knows naming linear lets a run write with their key.
  • Stored keys are plaintext in the host store, and debug routes read them without expose. The PR flags this itself. I agree it is out of scope, but it deserves a tracked follow-up issue rather than a note in a PR body, because it is the one place the "never shown back" promise has a hole. The Settings copy should not say a key is "never visible" until that is closed; say "never shown in the app".
  • seedEnv for the operator. The seeded key applies when found.owner === options.operator. owner comes from the run's trusted session identity, not the body, so BP-031 holds. The behaviour that a missing stored key silently falls back to an env key is intentional for goal checks, but the status message for the operator who has neither does not mention the env path. Fine; flagging only so it is a conscious choice.

5. Architecture notes on the refactor in this diff

  • The project-workspace.ts → run-project.ts move (~170 lines) is the right call: the relay and the workspace now share one project read, which is what makes named(ctx) and the "exactly the project's servers" guarantee possible. Reviewers should diff it with --color-moved; consider saying so in the PR body.
  • defineWriteProject(offered) / defineSetMcpServers(offered) turn two module-level handlers into factories solely to close over the offered list, and ProjectBlocks['createProject'] becomes ReturnType<typeof defineWriteProject>. That is the minimal way to get host-supplied config in without a global, and it matches how other factories here work. No change requested. The one oddity: setRepository and setBrief stay module-level while the other two are factories, so defineProjectBlocks() is now mixed. Acceptable for this PR; it is a point toward making all project writes factories if a third host config arrives.
  • createProjectInputSchema.mcpServers: z.array(z.unknown()) deliberately defers validation to checkedMcpServers so a bad value is never echoed. Good, but it means the generated action schema advertises unknown[] to the chief of staff. If the chief-of-staff tool listing is derived from that schema, a model sees no hint that values are bare names. The description on the action covers setMcpServers; check createProject does too, or confirm the PR's "chief of staff omits mcpServers" decision means it is intentionally hidden.

6. Smaller things

  • packages/shift-manager/src/lib/mcp-credentials.ts and the route both handle the "unknown server" refusal; make sure the browser never builds the URL path from unvalidated text (encodeURIComponent on the server name).
  • Docs were transcribed without docs-writer/docs-editor (stated in the PR). Please run docs-editor over apps/docs/docs/{workforce/projects,shift-manager/settings,tools/claude-code-sdk}.md before merge; user-facing pages must follow the outsider rule in docs/contributing/user-docs.md.
  • Changeset levels (workforce minor, claude-code minor, tools patch) look right for pre-1.0.

Summary

# 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
@cursor

cursor Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot 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)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/claude-code/src/sdk/agent.ts Resolved
Comment thread packages/tools/src/mcp/manager.ts Resolved
Comment thread packages/claude-code/src/sdk/agent.ts Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  • withoutHeaderValues strips that server's header values before the catalog and the warn line. scrub then 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.
  • RelayedMcpTool matches ClaudeCodeMcpTool on purpose. Workforce does not take a dependency on claude-code.
  • inProcessMcpServer is the five methods the SDK asks for. RpcError, objectSchema, errorResult, and toCallToolResult are one use each. Pulling in the MCP SDK's Server adds a dependency to delete a tested protocol. The file header is why no schema library sits in between.
  • named and the resolver both call runProjectOf. A helper is a function for two lines. Calling named from the resolver reads the project twice.
  • defineMcpCredentialsCollection returns one collection so two blocks meet. statusOf is already the route and the start line. mcpCredentialProblem is 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 /proc walk 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.

Open in Web View Automation 

Sent by Cursor Automation: Code Snob

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Run-level close, not per-server close — projectMcpTools hangs the same manager.close on every RelayedMcpServer, and claudeCodeAgent then Promise.allSettleds every server.close() in finally. That works today because close is idempotent, but it papers over ownership (tests already dedupe closes). A smaller API would return { servers, close } once, or document that only the harness calls close once.

  2. One runProjectOf per coding attempt — MCP resolution and projectWorkspace / feeds.cwd each call runProjectOf, 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).

  3. Relay-only manager mode in tools/mcp — projectMcpTools only needs catalog + callTool, but connect still builds full GeneratorTool handlers via mcpToolToHandler on every run. For large catalogs (e.g. Linear), that is wasted connect-time work. A createMcpManager({ mode: "relay" }) (or a slim createMcpRelayClient) would drop handler allocation until something actually needs generator tools.

  4. Unify secret scrubbing — scrub in project-mcp-tools.ts and withoutHeaderValues in manager.ts solve the same problem twice. A shared redactSecrets(text, secrets[]) in tools/mcp (or core utils) would be one place to audit.

  5. HTTP path constant for MCP credentials — workforce adapter defines the route; shift-manager/src/lib/mcp-credentials.ts hardcodes /api/flows/mcp-credentials. Export one constant from workforce (or a tiny shared contract module) so client and host cannot drift.

  6. Type bridge instead of as unknown as LooseBlockContext — HarnessCallbackContext → LooseBlockContext at the MCP resolver boundary is the same smell as heldTask; a narrow input type on runProjectOf would remove repeated casts.

What I would not chase in this PR

  • Merging RelayedMcpTool and ClaudeCodeMcpTool via a cross-package import (dependency arrow is wrong; a neutral harness-tool shape in core is a follow-up if a second harness copies the struct).
  • Moving mcpCredentialsAdapter into 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

  • fromWorkstream uses ctx.session.identity.userId while fromProject uses runOwnerOf — same intent, slightly different null paths.
  • inProcessMcpServer swallows transport send failures on JSON-RPC errors (.catch(() => {})); fine if intentional, worth a one-line comment.
  • host.mts repeats Object.keys(options.mcpServers ?? {}) in several places; one local offeredMcpNames would 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.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

Comment thread packages/tools/src/mcp/manager.ts Resolved
Comment thread packages/claude-code/src/sdk/agent.ts Resolved
…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
@cursor

cursor Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot 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)

@jhoffner

Copy link
Copy Markdown
Collaborator Author

@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

Copy link
Copy Markdown
Collaborator Author

Conflicts resolved in 0612bbf by merging main into this branch. The only conflict was the API table in packages/workforce/README.md. I kept this PR's project MCP rows and main's new defineWorkstreamBlocks row (leadFit, openWorkstreamTool).

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 checkout.test.ts (the "no credential" cases) and one in project-workstreams.test.tsx. The same five fail on main in this container, so they come from the environment, not the merge. CI is the real check.


Generated by Claude Code

@cursor

cursor Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot 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)

Copy link
Copy Markdown
Collaborator Author

Test (1/3) is red, and it is not this PR's failure. The failing test is shift-manager test/project-workstreams.test.tsx, "refuses research under the EM… and opens it under the general lead". It times out waiting for the ask in the general lead's session.

main fails the same way. The CI run on main after #3263 (FIX-1920) merged on top of #3232 (FIX-1872) is red in the same job, run 38479167321. I also ran this test on a clean origin/main worktree and it times out identically there. Main has no fix yet, so there is nothing to port into this PR. I've asked for a fix on main. Once it lands, I'll merge main in here again.


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

Copy link
Copy Markdown
Collaborator Author

I ported #3272's fix for the red test into this branch as a37149f, the same one-line change to project-workstreams.test.tsx (handOff → dispatchTask). The test file now passes locally, 13/13. Once #3272 merges, this change makes no difference.


Generated by Claude Code

@cursor

cursor Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot 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)

@jhoffner
jhoffner merged commit 70b0894 into main Oct 13, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants