Skip to content

MCP: expose topic suggestions (list / accept / dismiss) #498

Closed

Description

@gkhngyk

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):

  1. list_topic_suggestions (brand_id) — pending (status = 'new') suggestions: id, name, reason, generated_at. Read-only; mirrors list_topics.
  2. dismiss_topic_suggestion (suggestion_id) — sets status = 'dismissed'. Dismissed names never reappear in future generations (handled server-side already).
  3. accept_topic_suggestion (suggestion_id) — creates exactly one topic from the suggestion's name and marks the suggestion status = 'added' with added_topic_id set. Reference flow: acceptTopicSuggestion in web/src/lib/actions/topic-suggestions.ts. Use the singular createTopic action semantics — a single insert into topics; the plural createTopics replaces the brand's whole topic list and must not be used here. update_opportunity_status is 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_suggestions returns only status='new' rows for brands the caller can access.
  • accept_topic_suggestion creates one topic, leaves existing topics untouched, and moves the suggestion to added with added_topic_id set; accepting the same suggestion twice returns an error, not a duplicate topic.
  • dismiss_topic_suggestion moves the suggestion to dismissed; it no longer appears in list_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

  1. added
    enhancement
    good first issue
    help wanted
    on Jul 21, 2026
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

    enhancementgood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions