Skip to content

feat(mcp): Add optional visibility parameter to control chat visibility#903

Merged
brendan-kellam merged 5 commits intomainfrom
cursor/SOU-510-mcp-chat-visibility-d270
Feb 18, 2026
Merged

feat(mcp): Add optional visibility parameter to control chat visibility#903
brendan-kellam merged 5 commits intomainfrom
cursor/SOU-510-mcp-chat-visibility-d270

Conversation

@brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Feb 18, 2026

Add an optional visibility parameter to the ask_codebase tool to allow agents to control chat session visibility.

This enables agents to set chat sessions to public in shared environments like Slack, preventing 404 errors for users who did not create the API key used by the MCP server.


Linear Issue: SOU-510

Open in Cursor Open in Web

Summary by CodeRabbit

  • New Features
    • Added an optional visibility setting (PRIVATE or PUBLIC) to control chat session privacy.
    • Smart defaults: PRIVATE for authenticated users, PUBLIC for anonymous users; anonymous users cannot create PRIVATE chats.
    • Help text updated to explain visibility behavior and how to configure visibility in shared environments.

- Add visibility parameter to askCodebaseRequestSchema in MCP
- Update blocking chat API to accept and use visibility parameter
- Allow agents to override default visibility (PRIVATE/PUBLIC)
- Useful for shared environments like Slack where links should be public

Co-authored-by: Brendan Kellam <brendan@sourcebot.dev>
@cursor
Copy link

cursor bot commented Feb 18, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

Adds an optional visibility parameter to the /api/chat/blocking endpoint and the MCP ask_codebase tool. Values: PRIVATE or PUBLIC. Defaults: PRIVATE for authenticated users, PUBLIC for anonymous users (anonymous requests cannot create PRIVATE chats).

Changes

Cohort / File(s) Summary
Changelog Documentation
CHANGELOG.md, packages/mcp/CHANGELOG.md
Added Unreleased entries documenting the new optional visibility parameter for controlling chat session visibility.
Tool Descriptions
packages/mcp/src/index.ts
Updated help text for search_code and ask_codebase to mention the visibility parameter and its behavior in shared/anonymous contexts.
Request Schema
packages/mcp/src/schemas.ts
Added optional visibility enum (PRIVATE
Blocking Chat Route
packages/web/src/app/api/(server)/chat/blocking/route.ts
Parsed incoming visibility, computed chatVisibility (use requested value when provided; otherwise default PRIVATE for authenticated users and PUBLIC for anonymous users), and used it when creating the chat.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant MCP_Tool as MCP Tool
  participant Server
  participant DB

  Client->>MCP_Tool: send ask_codebase request (optional visibility)
  MCP_Tool->>Server: POST /api/chat/blocking (visibility param forwarded)
  Server->>Server: determine chatVisibility (requested or default based on auth)
  Server->>DB: create chat record with chatVisibility
  DB-->>Server: chat created
  Server-->>MCP_Tool: return chat link/metadata
  MCP_Tool-->>Client: present chat link (visibility noted)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding an optional visibility parameter to control chat visibility in the MCP ask_codebase tool, which aligns with the file changes across CHANGELOG, schemas, and API route implementations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/SOU-510-mcp-chat-visibility-d270

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@brendan-kellam
Copy link
Contributor Author

@cursoragent add changelog entries to the main changelog and the packages/mcp changelog. The PR link is #903

@brendan-kellam brendan-kellam marked this pull request as ready for review February 18, 2026 20:36
@cursor
Copy link

cursor bot commented Feb 18, 2026

Done! I've added changelog entries to both CHANGELOG.md files and pushed the changes.

Changes Made

Main CHANGELOG.md (/workspace/CHANGELOG.md)

  • Added entry under [Unreleased] > ### Added:
    • "Added optional visibility parameter to MCP ask_codebase tool to allow controlling chat session visibility in shared environments. #903"

MCP CHANGELOG.md (/workspace/packages/mcp/CHANGELOG.md)

  • Added entry under [Unreleased] > ### Added:
    • "Added optional visibility parameter to ask_codebase tool to allow controlling chat session visibility in shared environments. #903"

Both entries follow the repository's changelog conventions with the PR link included. The changes have been committed and pushed to the cursor/SOU-510-mcp-chat-visibility-d270 branch.

Open in Cursor Open in Web

@github-actions

This comment has been minimized.

- Add entry to main CHANGELOG.md
- Add entry to packages/mcp/CHANGELOG.md

Co-authored-by: Brendan Kellam <brendan@sourcebot.dev>
@brendan-kellam brendan-kellam changed the title Mcp chat visibility feat(mcp): Add optional visibility parameter to control chat visibility Feb 18, 2026
- Clarify that the change affects both the API endpoint and MCP tool

Co-authored-by: Brendan Kellam <brendan@sourcebot.dev>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/web/src/app/api/`(server)/chat/blocking/route.ts:
- Around line 102-103: The code computes chatVisibility using
requestedVisibility ?? (user ? ChatVisibility.PRIVATE : ChatVisibility.PUBLIC),
which allows an anonymous caller to explicitly set PRIVATE; change the guard so
PRIVATE is only allowed for authenticated users — e.g., if (!user &&
requestedVisibility === ChatVisibility.PRIVATE) set chatVisibility =
ChatVisibility.PUBLIC, otherwise use requestedVisibility ?? (user ?
ChatVisibility.PRIVATE : ChatVisibility.PUBLIC); update the logic around the
chatVisibility variable (and any downstream use) to enforce that
ChatVisibility.PRIVATE is only accepted when user is present.

- Update visibility logic to ignore PRIVATE requests from unauthenticated users
- Add guard to ensure anonymous users can only create PUBLIC chats
- Update tool description and schema to document this behavior
- Prevents creation of inaccessible ownerless private chats

Co-authored-by: Brendan Kellam <brendan@sourcebot.dev>
- Remove note from MCP tool descriptions (schemas.ts and index.ts)
- Add note to blocking chat API route's visibility parameter description
- Clarifies that the restriction is enforced at the API level

Co-authored-by: Brendan Kellam <brendan@sourcebot.dev>
@brendan-kellam brendan-kellam merged commit 1d57be3 into main Feb 18, 2026
9 of 10 checks passed
@brendan-kellam brendan-kellam deleted the cursor/SOU-510-mcp-chat-visibility-d270 branch February 18, 2026 21:32
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

Comments