Skip to content

fix(mcp): filter private comments for portal details#48

Open
BunsDev wants to merge 1 commit into
mainfrom
codex/fix-mcp-post-details-vulnerability
Open

fix(mcp): filter private comments for portal details#48
BunsDev wants to merge 1 commit into
mainfrom
codex/fix-mcp-post-details-vulnerability

Conversation

@BunsDev

@BunsDev BunsDev commented Jun 15, 2026

Copy link
Copy Markdown
Member

Motivation

  • Repair a regression that exposed private/team-only comments to portal users because getCommentsWithReplies was called without the includePrivate option.
  • Ensure portal users (non-team) only receive public comments while team members keep access to private comments.

Description

  • Pass the caller's team membership into getCommentsWithReplies by computing includeTeamOnlyFields = isTeamMember(auth.role) and calling getCommentsWithReplies(postId, undefined, { includePrivate: includeTeamOnlyFields }) in apps/web/src/lib/server/mcp/tools.ts.
  • Add two unit assertions in apps/web/src/lib/server/mcp/__tests__/handler.test.ts that verify getCommentsWithReplies is invoked with includePrivate: false for an OAuth portal user and includePrivate: true for a team member.
  • Preserve existing summary gating and other post-detail fields; no broad surface-area changes were made.

Testing

  • Ran git diff --check which reported no whitespace errors and the diff is as expected.
  • Attempted bun test apps/web/src/lib/server/mcp/__tests__/handler.test.ts but the run failed with TypeError: vi.mock is not a function because the environment invoked Bun's test runner while the suite uses Vitest APIs.
  • Attempted bun install --frozen-lockfile to install deps for full test runs but this was blocked by npm registry 403 errors, so the added tests could not be fully executed in this environment.

Codex Task

Copilot AI review requested due to automatic review settings June 15, 2026 13:51

Copilot AI 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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes a regression in the MCP get_details tool where portal (non-team) users could receive private/team-only comments by ensuring the includePrivate option is correctly passed to getCommentsWithReplies.

Changes:

  • Compute includeTeamOnlyFields from the caller’s role and pass it as includePrivate into getCommentsWithReplies for post details.
  • Add unit assertions to verify includePrivate is false for OAuth portal users and true for team members.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
apps/web/src/lib/server/mcp/tools.ts Ensures comment fetching honors team membership by wiring includePrivate into the query call.
apps/web/src/lib/server/mcp/tests/handler.test.ts Adds tests asserting the correct includePrivate flag is passed for portal vs team contexts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +910 to +918
vi.mocked(getDeveloperConfig)
.mockResolvedValueOnce({
mcpEnabled: true,
mcpPortalAccessEnabled: true,
})
.mockResolvedValueOnce({
mcpEnabled: true,
mcpPortalAccessEnabled: true,
})
Comment on lines +942 to +945
expect(response.status).toBe(200)
expect(vi.mocked(getCommentsWithReplies)).toHaveBeenCalledWith('post_test', undefined, {
includePrivate: false,
})
Comment on lines +961 to +964
expect(response.status).toBe(200)
expect(vi.mocked(getCommentsWithReplies)).toHaveBeenCalledWith('post_test', undefined, {
includePrivate: true,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants