Repository navigation
fix(mcp): gate the shopping reads on the plan's shopping analytics - #1764
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]>
5 tasks done
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
4 tasks done
6 of 7 tasks
gkhngyk
approved these changes
Oct 29, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good, with follow-ups
Reviewed 7a4a30e. It is stacked on #1762 (9e11860), from ce9a3dc, and I reviewed its own diff (9e11860..7a4a30e). Web and docs, no migration.
What I checked
- The gate.
listShoppingCardsandgetProductVisibilitycheck the brand first, then the plan:planIncludesreadsORG_PLAN_COLUMNSand checkshasFeature(usagePlanFromOrgRow(…).plan, 'shopping_analytics').- A Growth plan that has ended keeps reading, as the API's
requireFeature(…, { readOnly: true })and the dashboard do. - Self-hosted skips the read.
- Another organization's brand still answers "not found" before any plan read.
- Every surface. The gate is in the data functions, so it covers:
- the tools
list_shopping_cardsandget_product_visibility; /api/mcp/shopping-cards, plus/api/v1/shopping-cards, which re-exports it;/api/mcp/product-visibility, which has no/v1path.
- the tools
- Refusal body.
{ error: 'plan_limit', message }with 403 is what the API'srequireFeatureanswers. The plan name comes fromgetMinimumPlanForFeature, so it followsplans.ts. The tools return the same JSON as an error result. - Embeds. None added.
planIncludesreadsorganizationsdirectly. - The tests catch it. I put #1762's
data.ts,server.tsand both routes back under the PR'sshopping-plan.test.ts. Both Starter cases fail: the tool answers, and REST says 200. With the PR, the 6 tests pass. Thelib/mcp,api/mcp,api/v1andlib/agenttests andsubscription-guard-coverage.test.tspass at this head: 31 files, 194 tests. Webtscis clean, and so is Prettier on the touched files. - Docs.
mcp-server.mdxandapi-reference/metrics.mdxsay Growth and up and give the 403 body. - It merges cleanly on ce9a3dc and alongside #1763 and #1733.
Follow-ups
This was referenced Oct 29, 2026
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 Product Visibility page is for plans with
shopping_analytics(Growth and up). It checks that only in the browser. The MCP toolslist_shopping_cardsandget_product_visibility, and/api/v1/shopping-cards, didn't check it at all.Both data functions now read the organization's plan (
ORG_PLAN_COLUMNS+hasFeature) after the brand check and answerNOT_IN_PLANwithout it:plan_limit, and REST answers 403.Docs:
mcp-server.mdxandapi-reference/metrics.mdxsay "Growth and up".Related issue
None.
Stacked on #1762 (MCP keys carry the caller's role). This branch's test gives its key a role. The diff against it holds only this change.
Type of change
fix— Bug fixHow to test
cd web && yarn vitest run src/lib/mcp/shopping-plan.test.ts(6 tests): Starter is refused, Growth passes, an ended Growth plan reads, self-hosted has no gate, and REST answers 403.Checklist
🤖 Generated with Claude Code