Skip to content

feat(mcp): expose list_shopping_cards / get_product_visibility tools + REST endpoints #107

Closed

Description

@gkhngyk

Context

The MCP server already exposes brands, visibility summary, prompts, topics, and content opportunities (#20, #35, #74). The A-group read tools (#96–#100) extend that to insights/citations/competitors/traffic/volumes. Shopping should ship as part of the same coherent MCP surface so the in-product assistant (#94) and external clients (Claude Desktop, Cursor, Zed) can ask "which of my products are AI engines surfacing?" without hitting random REST endpoints.

Depends on: #103 (normalized prompt_result_shopping_cards).

Acceptance criteria

Follow the established MCP pattern (see web/src/lib/mcp/data.ts, server.ts, mcp-auth.ts, parallel REST routes under web/src/app/api/mcp/):

  • Data functions in web/src/lib/mcp/data.ts:
    • listShoppingCards({ brandId, role?, platform?, region?, limit, cursor }) — returns normalized cards with brand ownership check (null→404).
    • getProductVisibility({ brandId, productTitle }) — aggregates appearances of a single product across platforms/regions/dates; returns null if unknown to the org.
  • MCP tool registrations in web/src/lib/mcp/server.ts — list_shopping_cards and get_product_visibility. Tool descriptions explain commercial-intent context and reference the matched_brand_role enum.
  • REST endpoints under web/src/app/api/mcp/shopping-cards/ mirroring the data fns, sharing the same data layer (don't duplicate the query).
  • Auth via authenticateMcpRequest — accepts only ans_ API keys, returns 401 otherwise. No session-JWT fallback.
  • Wrong-org access returns 404, not 403 — consistent with feat(mcp): expose list_citations tool + REST endpoint #97–feat(mcp): expose get_prompt_volumes tool (search volume + competition) + REST endpoint #100 to prevent enumeration.
  • Pagination on list_shopping_cards (cursor-based, default limit 50, max 200).

Out of scope

  • Action tools like recompute_product_match or flag_card — B-group action tools, separate issue.
  • Pricing-history tool — depends on the pricing-intelligence work (later issue F).
  • Anomaly subscription — separate alerts epic.

Notes

This issue is deliberately scoped narrow so it can land alongside #104/#105 without blocking them. Open the data fn + tool registration in one PR, REST routes in another if needed.

Activity

  1. added
    enhancement
    on May 26, 2026
  2. Pallavikumarimdb commented on Jun 3, 2026

    @Pallavikumarimdb
    Contributor

    @gkhngyk Can I work on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions