Fix workspace-scoped MCP resources/list and resources/read (#6770) - #6773
Conversation
) The MCP `resources/list` and `resources/read` handlers were calling `/api/skills` and `/api/design-systems` without workspace headers, while the project/run tools (after nexu-io#6569) all resolve the signed-in workspace and forward `x-od-workspace-id` / `x-od-workspace-member-id`. This meant an MCP client listing resources only saw the NO-SCOPE catalog: any Personal design system that the workspace actually owned was filtered out, and reading `od://design-systems/<personal-id>/DESIGN.md` returned `404 design system not found` from the daemon even though the binding exists. The same blind spot affected `/api/skills` listing. Fix: route both handlers through the same `resolveMcpWorkspaceContext` that the project/run tools use, and forward the headers on the listing and read calls. The two handlers are extracted to exported `_listMcpResources` / `_readMcpResource` helpers so the logic is reachable from a vitest harness without spinning up a real stdio MCP server; the original `server.setRequestHandler` bodies now delegate to those helpers (no behavioral change to the stdio path). Tests: `apps/daemon/tests/mcp-resources-workspace-scope.test.ts` covers the header forwarding on both `resources/list` and `resources/read`, the NO-SCOPE fallback when no workspace resolves, the brief-app resource fast path that bypasses the daemon, and the unsupported-URI rejection.
|
🧪 Queued for QA validation — this PR changes live MCP resource behavior, so we'll want a manual QA pass before merge. Nothing needed from you right now; we'll pick that up once the review/CI gates are clear. Thanks for the contribution! 🙏 |
|
Hey @xxiaoxiong — the workspace-header gap and the regression coverage are both clear from the current write-up. Before pool review picks this up, could you add the user-facing outcome ( Related: #6770 (linked bug report with the end-user repro). |
The new mcp-resources-workspace-scope test imports this constant to assert the brief-app resource fast path bypasses the daemon. It is referenced inside mcp.ts but never exported — typecheck broke with TS2459.
|
One more PR-body item after this push: because this is labeled |
PerishCode
left a comment
There was a problem hiding this comment.
@xxiaoxiong I reviewed the workspace-scoped MCP resource changes across both modified files. The list and read handlers now consistently reuse the existing workspace resolver, preserve the headerless fallback and brief-app fast path, and retain the stdio handler behavior through the extracted helpers. I also verified the focused regression suite (5 tests), daemon source/test typecheck, and repository guard all pass. Nice work closing this resource-catalog gap with focused coverage.
🔁 Powered by Looper · runner=reviewer · agent=codex · An autonomous AI dev team for your GitHub repos.|
Thanks for the contribution. I completed QA validation for this PR. QA Acceptance Record Scope:
Verified:
Not verified:
Risks / notes:
Conclusion:
|
Problem
MCP
resources/listandresources/readcall the daemon's/api/skillsand/api/design-systemswithout forwarding the workspace headers (x-od-workspace-id,x-od-workspace-member-id). This means:od://design-systems/<personal-id>/DESIGN.mdreturns404 design system not found, even though the binding exists under the workspace.This differs from the project/run tools (introduced in #6569) which already resolve the signed-in workspace and forward headers on every daemon call.
Fix
_listMcpResources— extract theListResourcesRequestSchemahandler body into an exported helper. Inside thedaemonTarget.callcallback, resolve the workspace context once and pass the headers to bothgetJsoncalls for/api/skillsand/api/design-systems._readMcpResource— same pattern forReadResourceRequestSchema. The skill/design-systems branch now resolves the workspace and forwards headers so reads of Personal design systems land on the binding instead of returning 404.server.setRequestHandlerbodies now delegate to the helpers (no behavioral change to the stdio path).Tests
Added
apps/daemon/tests/mcp-resources-workspace-scope.test.tscovering:resources/listcallsresources/readfor design-system URIsRelated
Closes #6770