Skip to content

fix(shopping): don't ask for Merchant Center where the server doesn't offer it - #1747

Merged
gkhngyk merged 8 commits into
ansvisor:mainfrom
cihan-gyk:fix/shopping-gmc-not-offered
Oct 29, 2026
Merged

gkhngyk merged 8 commits into
ansvisor:mainfrom
cihan-gyk:fix/shopping-gmc-not-offered

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

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.

  • Readiness (web/src/lib/shopping/readiness.ts): readinessChecklist takes merchantCenterOffered.
    • Where the server doesn't offer Merchant Center and the brand has no Merchant Center source, the "Google Merchant Center feed connected" item is left out and doesn't count toward the score, in the US and in Europe alike. Before, it was a warning in the US and a failure in Europe, so even a flawless store scored about 93 (US) / 86 (EU).
    • If the sources can't be read, the item is also left out.
    • A brand that already has a Merchant Center source keeps the item (pass).
  • "Offered" comes from the server's existing switch (COMPOSIO_GMC_AUTH_CONFIG_ID), so there is no new env variable.
    • The page reads it from /api/integrations/config → googleMerchantCenter (new getMerchantCenterOffered() in lib/actions/integrations.ts, false when it can't be read) and passes it through useProductSources.
    • The server's config object moved into integrationsConfig() (routes/integrations.js), which /config uses.
    • The MCP has no member session, so it reads the same object from a new internal endpoint, 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.
  • Strip (_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.
  • Copy: the EU note now reads "…so what Google Shopping has of yours (a Merchant Center feed or your pages' product schema) decides ChatGPT too".
  • MCP: get_shopping_readiness gives the same result; its description says the Merchant Center item appears only where it's offered or connected.
  • The Merchant Center connector code and catalog_item_issues stay 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 fix

How to test

  1. On a server without 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".
  2. With the variable set (or a brand with a Merchant Center source): the item shows as before.
  3. MCP get_shopping_readiness matches the page.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • Server: npm run format, npm run lint, npm test pass (280/280 files)
  • Web: yarn lint (0 errors), yarn typecheck, yarn build pass. yarn test: 562/563 files; _before-publish timed out under load (known).
  • Tests added (readiness not offered / unreadable, strip "Soon", MCP not offered / unreadable, internal config route)
  • The embed guard from test(web): fail on an embed between twice-joined tables that doesn't name its foreign key #1714 passes on this branch
  • Browser check: in the batched local test (the item only disappears on a server without the GMC variable)

🤖 Generated with Claude Code

cihan-gyk and others added 7 commits October 28, 2026 23:16
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]>

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. readinessChecklist leaves 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/config with the member's token through the new getMerchantCenterOffered(). A failed or non-OK read is false. useProductSources reads it alongside the catalog and the Google sources, so loaded still 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_readiness reads the same object from GET /api/internal/integrations-config. The endpoint checks CRON_SECRET the same way /api/internal/ai-usage does, is registered before the /api auth middleware, and returns booleans only (no credentials). Without CRON_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/config already exists.
  • PostgREST embeds: none added or changed in this commit (no .select( in the diff).
  • Read-only workspace: getMerchantCenterOffered is a read (a GET with no writes), and the internal route is a GET. subscription-guard-coverage.test.ts passes 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.ts and docs/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-card and the subscription guard tests (66 files, 435 of 436 tests). The one failure is #1733's, see 1 below. The server's integrations-config test 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. tsc passes, and prettier and eslint pass on the touched files.

Follow-ups

  1. 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.
  2. merchantCenterOffered() makes a request to the API on every get_shopping_readiness call. The answer only changes with a redeploy, so caching it for a few minutes in the module would save a round trip.

@gkhngyk
gkhngyk merged commit 86784d5 into ansvisor:main Oct 29, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants