feat(mcp): add readOnlyHint annotations to all MCP tools#1013
Conversation
Mark all MCP tools as read-only using the MCP specification's readOnlyHint annotation. This enables compatibility with Cursor's Ask mode and other MCP clients that restrict tool usage based on whether tools modify their environment. All 7 tools (search_code, list_commits, list_repos, read_file, list_tree, list_language_models, ask_codebase) are now annotated with readOnlyHint: true in both the built-in web server and the standalone npm package. Fixes #SOU-707 Co-authored-by: Michael Sukkarieh <msukkari@users.noreply.github.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR adds read-only hint annotations to MCP tools across two implementation files and updates the changelog. Seven tools (search_code, list_commits, list_repos, read_file, list_tree, list_language_models, ask_codebase) are marked as read-only to support MCP clients that restrict tool usage based on behavior hints. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment Tip You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.Change the |
Co-authored-by: Michael Sukkarieh <msukkari@users.noreply.github.com>
Summary
This PR adds
readOnlyHint: trueannotations to all MCP (Model Context Protocol) tools in Sourcebot. This enables compatibility with Cursor's Ask mode and other MCP clients that restrict tool usage based on whether tools modify their environment.Problem
MCP tools in Sourcebot were not working in Cursor Ask mode because Cursor couldn't detect that our tools are read-only. According to the MCP specification, tools should include annotations to indicate their behavior characteristics.
Solution
Added
readOnlyHint: trueannotation to all 7 MCP tools in both implementations:Built-in server (
packages/web/src/features/mcp/server.ts):search_codelist_commitslist_reposread_filelist_treelist_language_modelsask_codebaseStandalone npm package (
packages/mcp/src/index.ts):The
readOnlyHintannotation is part of the MCP specification'sToolAnnotationsinterface and indicates that a tool does not modify its environment. All Sourcebot MCP tools are inherently read-only since they only query/read data.Testing
Fixes #SOU-707
Linear Issue: SOU-707
Summary by CodeRabbit
New Features
Documentation