Repository navigation
Description
What
Add a new MCP tool get_content_opportunity (plus a parallel REST
endpoint at /api/mcp/content-opportunities/[id]) that returns the
full detail for one content opportunity — including the source_data
payload (prompt text, estimated AI volume, visibility score,
competitor gap, intent, keywords, cited competitors) and the
generated brief if one exists.
Second of four small issues that expose the content-opportunity layer
to MCP/skills. Companion issues: #64 (list_content_opportunities),
plus upcoming generate_content_brief and update_opportunity_status.
Why
list_content_opportunities returns a thin overview row. Once the
user (or Claude) picks one, the next question is "tell me everything
you know about this one" — volume, gap data, the brief if it's
already been generated. That's this tool.
Signature
get_content_opportunity(opportunity_id: string (uuid, required))
→
{
id, title, description, type, impact, opportunity_score, status,
prompt_id, prompt_text,
source_data: { // raw JSONB from the table
promptText, estAiVolume, visibilityScore, competitorGap,
intent, keywords, competitorsCited
},
brief: object | null, // the generated brief JSONB, if any
created_at, updated_at
}
Returns null (→ 404 from the REST route) if the opportunity does
not belong to a brand in the caller's organization.
Where to change
1. Shared data layer
web/src/lib/mcp/data.ts — add
getContentOpportunityFor(auth, opportunityId):
- Join
content_opportunities→brandsto verify
organization_idmatchesauth.organizationId - Join to
promptsforprompt_text - Return all columns including
source_dataandbriefJSONB
2. MCP tool registration
web/src/lib/mcp/server.ts — register get_content_opportunity with
a zod schema requiring opportunity_id as a UUID. Description should
say: "use this after list_content_opportunities when the user picks
one and wants the full data behind it (volume, gap, brief if any)".
3. REST endpoint
web/src/app/api/mcp/content-opportunities/[id]/route.ts — dynamic
route GET handler. Authenticate, call data function, return the
opportunity payload as JSON. 404 when ownership check fails.
How to verify
-
curl /api/mcp/content-opportunities/<UUID>with a valid API
key returns the full opportunity includingsource_dataand
brief(if present) - An opportunity ID belonging to a different organization
returns 404 - An opportunity with no brief returns
brief: nullcleanly - MCP tool call from Claude Desktop: "Show me the details of
that pricing-page opportunity" → tool fires with the right
opportunity_id, formatted detail returned
Out of scope
- Generating the brief if it's missing (separate issue —
generate_content_brief) - Updating status (separate issue —
update_opportunity_status)
Contribution guide
See CONTRIBUTING.md for branch
naming, commit conventions, and PR workflow.
Activity