Repository navigation
fix(chat): read what the MCP Server already reads, and keep the two in step - #2464
Merged
Merged
Conversation
…n step Chat had no row for 17 reads the MCP Server offers, so questions about the History scorecard, tasks waiting for review, Product Visibility, the catalog, the Content plan, one opportunity, a draft's live page and sources, a saved report, prompts by location, prompt usage, topic suggestions and the month's Site Audits had no read. Each new row (registry/mcp-wrapped-reads.ts) calls the MCP tool's own data function with its plan gate, its role rule and its brand scope. Lists come a page at a time; shopping cards go by their keyset cursor. The parity test now fails on an MCP read with neither a Chat row nor a reason in MCP_ONLY_READS (one: the CMS-ready draft package). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
gkhngyk
previously approved these changes
Nov 17, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Minor: list_shopping_cards now passes the model's cursor into listShoppingCards, which builds .or() from the decoded created_at/id (data.ts ~3264); validate ISO date + uuid first. get_action_scorecard's date_from isn't validated, so a bad date throws a RangeError in learning.ts:74.
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
This was referenced Nov 17, 2026
gkhngyk
approved these changes
Nov 17, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Re-approving after the main merge: the PR's own changes are unchanged (numstat matches; the tools.test.ts resolution keeps both sides).
This was referenced Nov 17, 2026
gkhngyk
pushed a commit
that referenced
this pull request
Nov 18, 2026
…erge The merged base runs #2462's page periods over the reads #2464 and #2466 add: Prompts › Tracked's locations, the Topics tab, and AI Referral Traffic's bots and Search Console pages cut a preset as their pages do (the last N × 24 hours to today), and the eval set now has rows 38 (Today's first action) and 39 (losses to a competitor). Their tests say so. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
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
Step 6a of the "Chat must read everything a page shows" plan (owner, 16 Nov).
The MCP Server had 18 reads that Chat didn't offer. Chat now has 17 of them. Each one calls the same data function MCP calls, with the same plan gate, role rule and brand scope. The 18th is an export format only an outside tool needs. It is listed with its reason.
A new parity test fails when someone adds an MCP read without a Chat row, or without a reason it is MCP only. So Chat and MCP can't drift apart again.
Changes
get_action_scorecardget_action_scorecardlist_task_reviewslist_task_reviewsget_prompt_locationsget_prompt_locationsget_prompt_usageget_prompt_usagelist_topic_suggestionslist_topic_suggestionsget_shopping_shelfget_shopping_shelfshopping_analytics(Growth+)get_shopping_readinessget_shopping_readinessshopping_analytics(Growth+)get_product_ai_saysget_product_ai_saysshopping_analytics(Growth+)list_shopping_cardslist_shopping_cardsshopping_analytics(Growth+)list_catalog_productslist_catalog_productsget_catalog_sourcesget_catalog_sourcesget_content_planget_content_planget_content_opportunityget_content_opportunityget_content_impactget_content_impactget_content_sourcesget_content_sourcesget_reportget_reportget_site_audit_quotaget_site_audit_quotaregistry/mcp-wrapped-reads.ts. The 17 rows andMCP_ONLY_READS.tools.tsadds it afterREAD_TOOLS.offset,total,next_offset,note): task reviews, topic suggestions, shelves, catalog products, prompts by location, and the Content plan's rows.countsgives each card's full count.compared), so a page cut for size never cuts the location list.search(fix(chat): look up any listed item by its code, id, words or address #2460): an opportunity (list_content_opportunities), a draft (list_drafts), a report (get_reports), a product (list_catalog_products).brand_id,platform,region,date_from/date_to(scorecard: start only, as MCP), anddaysfor the Content plan, a live page's impact and Product Visibility. Soscope.tssets each read's period from the run's range, and fix(chat): read over the page's dates and filters in the side panel #2459's page dates apply once it lands.days(7, 30 or 90) and passes it on as MCP'speriod("30d"). Its default is 30 days, as the page opens.RESULT_CHARS.get_report = 20_000(as Actions'). A draft's sources come the same way: each list on its own.get_reports→get_report,list_content_opportunities→get_content_opportunity,get_shopping_visibility→ a shelf or the cards for a product's title.en.json(chatTools.*), one block afterreports.BRAND_LOOKUP_TABLESgainsreports, so a report's brand is found from its id before the read runs, as for drafts and opportunities.approved-articles.jsonwas regenerated by the help tests.Safety
brandAllowed, or the row's join onbrands.organization_idandmayUseBrand). The month's audits are the workspace's own, about no brand. Another workspace's brand, or one not shared with the person, answers null (not found) and reads nothing else.brand-scope.test.tscovers the 9 functions it didn't yet.brand_scope), the plan gate (plan_locked) and the role (forbidden_role) before anything runs.get_prompt_performance). Everything with outside text is untrusted and taints the run: AI answers, product and page titles, merchants, report text, AI-written tasks and suggestions, a draft's sources.prompt_resultswith OFFSET. Shopping cards use MCP's keyset cursor (21 rows a read). Three MCP functions are heavy, and Chat calls them as MCP does, with MCP's caps:get_prompt_locations: the page's matrix loader, at most 12 locations, a few at a time. Each page of prompts reads the matrix again, as MCP's paging does.get_shopping_shelf: the page's shelf loader reads every shelf of the window, then cuts the page. As MCP.list_catalog_products: OFFSET oncatalog_products(one brand's catalog, capped by the plan), plus the brand's 30-day AI stats per product. As MCP.chat-thread-view.tsx,page-pane.tsx,page-open.ts, the content editor folder or Action Center site-type files.How to test
Checks
npx tsc --noEmit -p .: clean.src/lib/chat,src/lib/mcp,src/app/api/mcp,src/components/chat,src/lib/help,src/i18n,use-server-exports,subscription-guard-coverage: 333 files, 4552 passed, 1 skipped.mcp-wrapped-reads.test.ts(20 tests): labels, pages and routes; trusted or not; brand lookups; plan gate, role rule and brand scope per row; not found for every row; arguments per row; paging per list; the cursor and compact cards; the period and pagingscope.tsgives each.mcp-parity.test.ts: +3 tests (every MCP read covered; a new uncovered read fails;MCP_ONLY_READSis valid).brand-scope.test.ts: +9 rows.tools.test.ts: mocks and page sources for the new modules; Starter's and the roles' lists updated.help/chat/chat.mdandapproved-articles.jsonwere not Prettier-clean before this PR either.)git merge-tree --write-tree HEAD upstream/main: clean.Not in this PR
get_content_draft_packagestays MCP only (MCP_ONLY_READS). It hands an outside AI tool a CMS-ready page for its own CMS connector. Chat sends a draft withpush_cms_draftandpublish_cms.daysreads do. An all-time question reads 90 days.fix/chat-today-agents-reads,fix/chat-visibility-extra-reads).Choices made
get_reportmarks the run untrusted. A saved report holds AI answer excerpts word for word. The list readget_reportsstays inWORKSPACE_READS; addingget_reportthere would let agents in Full auto keep making changes after reading one.Generated by Claude Code