Skip to content

feat(mcp): expose get_prompt_volumes tool and REST endpoint - #160

Merged
gkhngyk merged 1 commit into
mainfrom
feat/mcp-get-prompt-volumes
Jun 3, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feat/mcp-get-prompt-volumes

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an MCP tool get_prompt_volumes (+ /api/mcp/prompt-volumes REST endpoint) returning per-prompt search volume + competition for a brand. Lets MCP clients / the assistant answer "which prompts have the most demand / the least competition?" — surfacing the competition meter (#44) on MCP.

Closes #100.

Changes

  • web/src/lib/mcp/data.ts — new getPromptVolumesFor(auth, { brandId, limit? }). Org-ownership check on the brand first (wrong-org / missing → null → 404, before any volume rows are read), then reads prompt_volumes scoped brand → prompt_sets → prompts → prompt_volumes via nested inner joins, sorted by est_ai_volume desc. Returns keywords, google_volumes, total_google_volume, est_ai_volume, ai_volume_multiplier, competition_index, competition (plus prompt_id, prompt_text, intent, fetched_at).
  • web/src/lib/mcp/server.ts — registers the get_prompt_volumes tool (brand_id required, optional limit), calling the same data function.
  • web/src/app/api/mcp/prompt-volumes/route.ts — GET route mirroring the ai-traffic / prompts pattern, sharing getPromptVolumesFor.

Acceptance criteria

  • Returns prompt_volumes rows (with competition) for the brand's prompts
  • Org-ownership enforced — wrong-org → 404
  • MCP tool and REST route share the same data function

Out of scope

Triggering volume analysis (the paid DataForSEO call on aeo-server); UI.

Test plan

  • GET /api/mcp/prompt-volumes?brand_id=<owned> returns volume rows with competition
  • Wrong-org brand_id → 404
  • Missing brand_id → 400
  • get_prompt_volumes MCP tool returns the same payload as the REST route
  • tsc --noEmit and eslint pass

Made with Cursor

Add an MCP tool `get_prompt_volumes` plus `/api/mcp/prompt-volumes` REST
route returning per-prompt search volume + competition for a brand, so
clients / the assistant can answer "which prompts have the most demand /
the least competition?".

Scoped brand -> prompt_sets -> prompts -> prompt_volumes with an
ownership-check-first guard (wrong-org -> 404). The MCP tool and REST
route share the same getPromptVolumesFor data function.

Closes #100

Co-authored-by: Cursor <[email protected]>
@gkhngyk
gkhngyk merged commit ec36ea3 into main Jun 3, 2026
2 checks passed
@gkhngyk
gkhngyk deleted the feat/mcp-get-prompt-volumes branch June 3, 2026 17:02

This branch was successfully deployed

1 active deployment
Preview — eb5766c2 Deployed Jun 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(mcp): expose get_prompt_volumes tool (search volume + competition) + REST endpoint

1 participant