Repository navigation
fix(mcp): keep briefs and Improve actions to admins and managers - #1770
Merged
Merged
Conversation
…smissing The MCP tools write with the service role, so the row rules that keep analysts from adding prompts never reached them: an analyst's key could accept a prompt suggestion and add a tracked prompt. The key's role now comes with the auth context and the data layer checks it, for the tool and its REST route alike: - accept_prompt_suggestion, accept_topic_suggestion and dismiss_topic_suggestion: admins and managers only. - dismiss_prompt_suggestion: not agency partners, as the table's rule. - update_opportunity_status: any member records progress; dismissing, or moving a dismissed one back, needs an admin or a manager. Drafts, briefs, Site Audits, tasks and Improve actions stay open to every member. A refused tool answers with the reason; the REST routes answer 403 role_required. The MCP guide names the role each write needs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Shopping page is locked on Starter, but only in the browser: over an API key, list_shopping_cards, get_product_visibility and their REST routes (/api/v1/shopping-cards included) read the cards on any plan. They now check shopping_analytics on the organization's plan after the brand check and answer plan_limit without reading a card: a tool error with the reason, and 403 on the REST routes, as the API's requireFeature answers. A plan that has ended keeps reading what it had, as the read-only dashboard does; self-hosted has no gate. The MCP guide and the metrics reference say the endpoints need Growth or above. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…carry one Co-Authored-By: Claude Opus 5.5 <[email protected]>
Generating with AI is for admins and managers (2026-10-29), as in the dashboard. generate_content_brief and create_improve_action now check the key's role before anything is read or generated, and so do their REST mirrors (POST /api/mcp/content-opportunities/:id/brief and /api/mcp/prompts/:id/improve-action, 403 role_required). The MCP guide marks both as admin and manager writes and lists AI work among what the roles keep. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
5 of 6 tasks
gkhngyk
approved these changes
Oct 29, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good with d23ef1dd: rebased onto main (docs conflict only)
Reviewed this PR's own change (#1764's head 7a4a30e → 1273892), read on main 3b7611c.
What I changed (branch take-1770, built on main 3b7611c: this PR's commit cherry-picked onto it)
- The base. As it stands, the branch doesn't merge with main. Its old copies of #1762 and #1764 conflict with main in
docs/guides/mcp-server.mdx,web/src/lib/mcp/data.tsandrole-gate.test.ts. - The docs conflict. The PR's own commit conflicts only in
docs/guides/mcp-server.mdx, against #1713's task review tools. I kept both:- The
create_improve_actionrow is now marked "(admin, manager)", below the three task review rows. - The Roles paragraph lists reviewing tasks, dismissing, and work that costs AI (briefs and Improve actions) as admin/manager work.
- The
- No code changes.
What I checked
- Order of checks.
generateBriefForandcreateImproveActionForcallrequireManagerbefore the ownership read, the subscription check and the internal call.- The role is the key's own, so checking it first reveals nothing about another organization's ids.
- A refused call never reaches the LLM.
- The REST twins.
POST /api/mcp/content-opportunities/:id/briefand/api/mcp/prompts/:id/improve-actionalready pass errors throughfailedCallResponse, which answersRoleRequiredErrorwith 403role_required. - The internal routes. The internal brief route on the API has no user, so this check is the brief's only role gate over a key. The internal Improve route also checks the role on the API once #1769 is in.
- Tool descriptions and docs say "Needs an admin or a manager" and match the behaviour.
- Each gate is tested. Removing either
requireManagermakes the role-gate tests fail, for analysts and for agency partners. The new brief route test checks the 403 mapping, which was already on main. - Embeds: none added. The two existing
!innerreads are unchanged. - Read-only workspace. No new write route.
subscription-guard-coverage.test.tspasses. - Tests (on main with this PR and #1769). Web
tscis clean.lib/mcp,api/mcp,lib/agentand the touched component tests pass: 61 files, 408 tests. The full web suite gives 598 of 600 files; the two timing tests that failed under load (shopping categories, Library paging) pass when re-run.
Follow-up (not blocking)
web/src/lib/mcp/role-gate.ts's header comment still lists briefs as day-to-day work open to every member. Worth one line in a later change.
Before merging
- Merge
take-1770, not this branch: this branch conflicts with main. - It is independent of #1769: the two merge together cleanly, in either order.
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.
Summary
The MCP tools that generate at a cost now check the key owner's role first, as the web app does after #1763's follow-up.
generate_content_briefandcreate_improve_actioncallrequireManagerbefore reading anything.POST /api/mcp/content-opportunities/:id/briefand/api/mcp/prompts/:id/improve-action, answer 403role_required.docs/guides/mcp-server.mdx: both are marked "(admin, manager)", and the Roles section is updated.Related issue
None.
Stacked on #1764 (MCP shopping plan gate, itself on #1762, the MCP role gate). The diff against it holds only this change.
Type of change
fix— Bug fixHow to test
cd web && yarn vitest run src/lib/mcp/role-gate.test.ts 'src/app/api/mcp/content-opportunities/[id]/brief/route.test.ts'Checklist
_before-publish.test.tsxfailed on the focus race that test(content): wait for the dialog's first focus before opening the JSON-LD code #1753 fixes; this branch doesn't touch it.🤖 Generated with Claude Code