Repository navigation
Description
Problem
#463 (PR #497) adds persisted AI topic suggestions to the Topics page, but the MCP surface has no visibility into them. An agent can call list_topics and list_prompts, yet cannot answer "what topics is the platform suggesting I add?" or act on a suggestion — even though the rows sit in topic_suggestions.
Depends on #497 — the topic_suggestions table and the accept/dismiss flows land there. Start after it merges.
Design
Add three tools to the MCP server, following the existing patterns in web/src/lib/mcp/server.ts (tool registration + Zod input schema) and web/src/lib/mcp/data.ts (auth-scoped data helpers):
list_topic_suggestions(brand_id)— pending (status = 'new') suggestions:id,name,reason,generated_at. Read-only; mirrorslist_topics.dismiss_topic_suggestion(suggestion_id)— setsstatus = 'dismissed'. Dismissed names never reappear in future generations (handled server-side already).accept_topic_suggestion(suggestion_id)— creates exactly one topic from the suggestion's name and marks the suggestionstatus = 'added'withadded_topic_idset. Reference flow:acceptTopicSuggestioninweb/src/lib/actions/topic-suggestions.ts. Use the singularcreateTopicaction semantics — a single insert intotopics; the pluralcreateTopicsreplaces the brand's whole topic list and must not be used here.update_opportunity_statusis the pattern reference for a write tool.
Brand/suggestion access must be scoped to the caller like every other tool in data.ts (a suggestion belonging to another org returns not-found, not data).
Out of scope: triggering generation (refresh) from MCP. It runs a search-grounded LLM call and is plan-gated; the Topics page button covers it. A read/act-only MCP surface is the right first step.
Acceptance criteria
list_topic_suggestionsreturns onlystatus='new'rows for brands the caller can access.accept_topic_suggestioncreates one topic, leaves existing topics untouched, and moves the suggestion toaddedwithadded_topic_idset; accepting the same suggestion twice returns an error, not a duplicate topic.dismiss_topic_suggestionmoves the suggestion todismissed; it no longer appears inlist_topic_suggestions.- Tool descriptions explain when an agent should reach for each tool (see existing tools for tone).
Getting started
See CONTRIBUTING.md for setup. From web/, yarn lint, yarn typecheck and yarn format:check must pass. Comment here to claim the issue before opening a PR.
Activity