Repository navigation
feat(mcp): Add scoped read tools for conversations, review items, and automations - #2573
Merged
Merged
Conversation
… automations Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…tools # Conflicts: # packages/junior/src/api/mcp/AGENTS.md
Contributor
|
5 screenshot changes — 5 changed · 0 added · 0 removed Review screenshots in Frameshift |
listConversations, listReviewItems, and listAutomations all take a text query and filters, so name them searchConversations, searchReviewItems, and searchAutomations. listConversationMessages keeps its name because it pages one transcript and has no query. Co-Authored-By: David Cramer <[email protected]>
dcramer
approved these changes
Nov 2, 2026
dcramer
left a comment
Member
There was a problem hiding this comment.
ideally each tool would have its own side-by-side file with tests covering it
Member
|
i need the tests added / refactored |
Each tool in src/api/mcp/tools now has a test file at the same path under tests/integration/api/mcp/tools. Each file covers the tool's main result and its access or failure rule. route.test.ts keeps only the OAuth, transport, and scope scenarios. The shared OAuth helpers move to the mcp-http fixture. Conversation, Review item, and Automation seeding moves to a new mcp-tools fixture. stopConversation now checks participation first. A non-participant got "Only conversation participants can stop this turn.", which showed that the Conversation exists. Like the other conversation tools, it now reports "Conversation not found."
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends the remote MCP server at
/api/mcpfrom one tool to nine. The tools are split across four OAuth scopes. No tool starts agent work: nothing sends a message, answers or dismisses a Review item, or runs an Automation.Scopes
conversations:readsearchConversations,getConversation,listConversationMessagesconversations:managearchiveConversation,stopConversationreview_items:readsearchReviewItems,getReviewItemautomations:readsearchAutomations,getAutomationoauth/scopes.tsowns the scope list and the consent copy.TOOLS_BY_SCOPEinserver.tsmaps each scope to its tools. Each request registers only the tools of the token's granted scopes, so a client never sees a tool it can't call.scope. A request without one asks for every scope. An unknown scope returnsinvalid_scope.scopeas one space-separated string. Grants issued before this change (conversations:read) still parse and keep working. To get the new tools, users connect again.scopethat differs from the grant's, instead of silently narrowing it.WWW-Authenticateand both metadata documents now advertise every scope.Tools
getConversationreturns metadata, the Brief (without its activity counts and keywords), and the last assistant reply. It does not return the transcript.listConversationMessagespages user and assistant messages backward from newest. It uses the existing signed conversation cursor. Each page scans at most 200 report events. Tool calls are excluded.searchConversationsfirst runsisConversationParticipant. That keeps the same membership rule thatsearchConversationsalready relies on.archiveConversationandstopConversationwrap the existing REST functions. A 4xxHTTPExceptionbecomes a tool error.stopConversationneeds the work queue, so the MCP handler now receives it fromapp.ts.deliverReviewItemChangesends a submit or dismiss as a message to every linked Conversation through the work queue, which would trigger agent runs. Results includecanActand a dashboard link, so the person answers there.mine/attention/ state filters) and get, plus the 10 newest runs. Cost and chart fields are left out.instructionssaying the tools are read-mostly and cannot start work.Not in this PR
junior://conversations/{id}) and attachment downloads.searchConversations. The feed query has no cursor today, and the dashboard has the same 50-item limit.pauseAutomationand any tool that triggers runs. Those would go behind separate opt-in scopes later.Tests and docs
tests/integration/api/mcp/route.test.tsadds three scenarios that run through real Junior wiring:The
operate/mcp-serverpage andapi/mcp/AGENTS.mdare updated with the scope and no-run invariants.Checks run locally:
pnpm typecheck, rootpnpm lint,pnpm docs:check, the MCP integration and unit tests, and the conversation stop and archive integration tests. I did not run an end-to-end test with a real Claude Code client.via @dcramer.
--
View Session [Sentry]