Repository navigation
Description
What
Add a new MCP tool list_content_opportunities (plus a parallel
REST endpoint at /api/mcp/content-opportunities) so Claude can answer
content-strategy questions from inside any MCP-aware client:
- "What content gaps are open for my brand?"
- "Show me the highest-impact opportunities I haven't started yet."
- "List all dismissed opportunities so I can re-evaluate them."
First of four small issues that expose the content-opportunity layer to
MCP/skills (see #62 for the related delete-vs-accumulate bug).
Companion issues to follow: get_content_opportunity,
generate_content_brief, update_opportunity_status.
Why
The MCP server currently exposes brands, visibility, topics, prompts.
Content opportunities are the next natural surface — they're how the
AEO insights turn into actual writing work. Without this tool the AEO
Coach skill can describe gaps in the abstract ("you're losing
visibility on these prompts") but can't reach the concrete suggestion
list ("here are the briefs to start with").
Signature
list_content_opportunities(
brand_id: string (uuid, required),
status?: 'new' | 'sent' | 'in_progress' | 'done' | 'dismissed',
impact?: 'high' | 'medium' | 'low',
type?: 'owned' | 'earned',
limit?: number (1–200, default 50)
) →
Array<{
id, title, description, type, impact, opportunity_score, status,
prompt_id, prompt_text, has_brief, created_at, updated_at
}>
Sort by opportunity_score desc by default. has_brief is a boolean
derived from whether the brief JSONB column on
content_opportunities is non-null (the brief object itself is
returned by get_content_opportunity, not here, to keep this list
lightweight).
Where to change
The MCP stack already has the right shape from prior tools — copy that
pattern:
1. Shared data layer
web/src/lib/mcp/data.ts — add listContentOpportunitiesFor(auth, params):
- Ownership check via
auth.organizationId(same pattern as
listTopicsFor/listPromptsFor) - Query
content_opportunitiesjoined topromptsforprompt_text - Apply optional filters:
status,impact,type - Sort
opportunity_scoredesc, thencreated_atdesc - Cap
limitto 1–200 (default 50) - Compute
has_brieffrombrief IS NOT NULL - Return
nullif the brand doesn't belong to the caller's org
(returns 404 from the REST route)
2. MCP tool registration
web/src/lib/mcp/server.ts — register list_content_opportunities
with zod schema for inputs, description that explains when to use it
(content gap audits, "what should I write next" questions).
3. REST endpoint
web/src/app/api/mcp/content-opportunities/route.ts — GET handler
that parses query params (brand_id, status, impact, type,
limit), authenticates via authenticateMcpRequest, calls the data
function, returns { opportunities: [...] }.
How to verify
-
curl /api/mcp/content-opportunities?brand_id=<UUID>with a
valid Ansvisor API key returns the brand's opportunities,
sorted by score desc - Adding
&status=new&impact=highcorrectly narrows the list - Wrong-org
brand_idreturns 404 - MCP tool call from Claude Desktop: "List my open content
opportunities for brand X" → tool fires, formatted result
comes back
Out of scope
- Returning the full
briefpayload inline (use
get_content_opportunityfor that — separate issue) - Filtering by date range or score range (add later if asked)
- Updating opportunity status (separate issue)
- Generating new briefs (separate issue)
Contribution guide
See CONTRIBUTING.md for branch
naming, commit conventions, and PR workflow.
Activity