Repository navigation
fix(shopping): don't ask for Merchant Center where the server doesn't offer it - #1747
Merged
Merged
Conversation
For an AI assistant working on a shop's catalog (MCP plan B6a): - get_catalog_sources (REST GET /api/mcp/catalog/sources): where the catalog is read from (feeds, uploads, connected stores) and how each last sync went, with its products in the catalog now. - list_catalog_products (REST GET /api/mcp/catalog/products): the live products, by title, as Product Visibility reads them, each with its readiness for AI shopping, its Google Merchant Center issues by severity and the AI visits and orders its page brought over 30 days; `search`, and paged with `limit` and `offset`. Product Visibility's catalog reads (readCatalogProducts and its paged readers) and Settings' source read (readCatalogSources) move to lib/shopping/catalog-read.ts and take the client: the member's session on the pages, the service role for the MCP once the brand is the key's. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # docs/guides/mcp-server.mdx # web/src/lib/mcp/server.ts # web/src/lib/mcp/subscription-gate.test.ts
…wer past its end - Read the page's variants and their issues 100 ids and 1,000 rows a request, so a page past PostgREST's row cap keeps every issue. - Count each issue (code and attribute) once per product, however many variants and destinations it is on, and only for a Merchant Center account whose last sync went through (hasMerchantCenter, now shared with the editor's shopping check from lib/shopping/catalog-read). - Answer an empty page for an offset past the matches, which PostgREST refuses (PGRST103) once it counts them. - Search titles as written: a case-insensitive regex with its special characters escaped, since PostgREST turns every `*` of a like pattern into `%`. - One CARD_MAX_ROWS for the card and catalog reads. - Tests for the REST mirrors, the paged reads and the brand scoping; readiness.unknown, revenue_30d and the REST `search` in the tool description and docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Three read tools and their REST mirrors (MCP plan B6b), on top of the catalog tools (B6a): - get_shopping_shelf: each shopping question's latest shelf per AI channel, the brand's place on it and its last 7 days, and "Why not you?" on the shelves it isn't on (its catalog product the question asks for most, with its readiness). Paged; period, platform, market and absent_only filters. - get_shopping_readiness: the Readiness checklist and score, each check's text as the tab writes it (en.json) and where its fix starts, and each AI channel's state. - get_product_ai_says: a catalog product's "What AI says": answers, quotes and the pages they cited. They run the page's own loaders with the service role (dbClient / withDbClient) once the brand is the key's, so the tools and the page read the same. Like the page's tabs they need a plan with shopping_analytics (403 over REST). copyValues moves to lib/shopping/readiness.ts for both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Plan: read the plan the organization is on (usagePlanFromOrgRow), as the page does, so a workspace whose trial ended still reads; the locked message names the first plan with Product Visibility. - Shelf: read the products for "Why not you?" beside the shelves; pages of 10 shelves (50 at most), each with its first 10 products and products_total. - Readiness: read which channels hold the brand's products one row a channel (getShoppingOwnChannels) instead of every card on the shelves. - Guard test: the page's loaders through the MCP client with the member's client failing, every read and RPC naming the brand; plan lock and not found answered as errors. - Comments on the shared loaders say the MCP runs them with the service role; docs table no longer split by a blank line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Google Merchant Center can't be connected where the API has no Composio auth config for it (COMPOSIO_GMC_AUTH_CONFIG_ID), as on Cloud today, yet Product Visibility asked for it: Readiness's "Google Merchant Center feed connected" warned in the US and failed in Europe, pulling the score down, and its Connect led to Settings' Coming soon. - readinessChecklist takes merchantCenterOffered: where Merchant Center isn't offered and the brand has no Merchant Center source, the check is neither listed nor scored. A source connected before still passes. - The page reads it from /api/integrations/config (getMerchantCenterOffered, false when unread); the data strip's Merchant Center chip says Soon there, as the marketplaces with no connector. - The MCP readiness reads the same through a new CRON_SECRET internal endpoint, GET /api/internal/integrations-config (the MCP has no member session); unread counts as not offered. integrationsConfig() is the one definition for both routes. - Europe's market note no longer says only a Merchant Center feed decides ChatGPT: Google Shopping does, from a feed or the pages' product schema. Co-Authored-By: Claude Opus 5.5 <[email protected]>
6 tasks done
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 this PR's own change (d868083e..4b8cc65d, one commit on top of #1733). No migration.
What I checked
- Readiness.
readinessChecklistleaves the Merchant Center item out only when the server doesn't offer it and the brand has no Merchant Center source. A brand that already has one keeps the item, and it passes. The score is computed over the items listed, so a store with only a feed now scores 100 instead of being pulled down by a check it can't act on. When the sources can't be read and Merchant Center isn't offered, the item is left out as well rather than shown as unknown. That matches the PR's "say less, never more". - Where "offered" comes from. The page asks the existing
/api/integrations/configwith the member's token through the newgetMerchantCenterOffered(). A failed or non-OK read isfalse.useProductSourcesreads it alongside the catalog and the Google sources, soloadedstill flips once, and a read for a brand you just switched away from still counts as loading. The strip's chip turns Soon when it isn't offered, and Connected when the brand has the source. - MCP.
get_shopping_readinessreads the same object fromGET /api/internal/integrations-config. The endpoint checksCRON_SECRETthe same way/api/internal/ai-usagedoes, is registered before the/apiauth middleware, and returns booleans only (no credentials). WithoutCRON_SECRET, or when the call fails, Merchant Center counts as not offered. The tool's description names when the key appears. - Deploy order. If the web goes out before the API, the MCP's internal call 404s and Merchant Center counts as not offered. That's the right answer on the cloud anyway. The page keeps working because
/api/integrations/configalready exists. - PostgREST embeds: none added or changed in this commit (no
.select(in the diff). - Read-only workspace:
getMerchantCenterOfferedis a read (a GET with no writes), and the internal route is a GET.subscription-guard-coverage.test.tspasses on the stack merged with main. - Merge. This commit merges clean onto #1733. The stack (#1729 → #1733) conflicts with main since #1715 in
web/src/lib/mcp/server.ts,web/src/lib/mcp/subscription-gate.test.tsanddocs/guides/mcp-server.mdx. All three conflicts are additive: both sides add tools, and the tool counts become 60 tools and 45 read tools. Nothing in this commit's own files conflicts. - Tests on the stack merged with main and with #1752 and #1765: the shopping folder,
lib/shopping,lib/mcp,app/api/mcp,catalog-sources-cardand the subscription guard tests (66 files, 435 of 436 tests). The one failure is #1733's, see 1 below. The server'sintegrations-configtest passes. In the full server suite, the only failures are unrelated: Framer tests that can't load a package locally, plus the known timing tests.tscpasses, and prettier and eslint pass on the touched files.
Follow-ups
- Not from this commit, but it lands with it: on main since #1741,
product-visibility.test.ts(from #1733) expects "Reseller cheaper than you · 1 products". Main now says "1 product", so that test fails once the stack is merged with main. It needs fixing in #1733. merchantCenterOffered()makes a request to the API on everyget_shopping_readinesscall. The answer only changes with a redeploy, so caching it for a few minutes in the module would save a round trip.
7 of 8 tasks
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
Google Merchant Center can't be connected on the managed cloud (the Merchant API access wasn't obtained; see #1270). Product Visibility still asked for it, which lowered every brand's readiness score and offered a Connect button that led to "Coming soon".
Stacked on #1733 (MCP Product Visibility tools, on #1729), since both touch the readiness checklist. Review the last commit; merge after #1733.
web/src/lib/shopping/readiness.ts):readinessChecklisttakesmerchantCenterOffered.COMPOSIO_GMC_AUTH_CONFIG_ID), so there is no new env variable./api/integrations/config→googleMerchantCenter(newgetMerchantCenterOffered()inlib/actions/integrations.ts, false when it can't be read) and passes it throughuseProductSources.integrationsConfig()(routes/integrations.js), which/configuses.GET /api/internal/integrations-config(CRON_SECRET, the ai-usage pattern). If that read fails, Merchant Center counts as not offered: say less, never more._data-strip.tsx): the Merchant Center chip says Soon like the other marketplaces when it isn't offered and there's no source, and Connected when there is one.get_shopping_readinessgives the same result; its description says the Merchant Center item appears only where it's offered or connected.catalog_item_issuesstay as they are, dormant.Deploy: server before web, for the new internal endpoint.
Related issue
Follows #1270 (Merchant Center connector, to be closed as not planned).
Type of change
fix— Bug fixHow to test
COMPOSIO_GMC_AUTH_CONFIG_ID, open Product Visibility › Readiness for a US brand and an EU brand. There is no Merchant Center item and no "Connect", and the score doesn't drop for it. The strip's Merchant Center chip says "Soon".get_shopping_readinessmatches the page.Checklist
npm run format,npm run lint,npm testpass (280/280 files)yarn lint(0 errors),yarn typecheck,yarn buildpass.yarn test: 562/563 files;_before-publishtimed out under load (known).🤖 Generated with Claude Code