Repository navigation
feat(mcp): expose get_prompt_volumes tool and REST endpoint - #160
Merged
Merged
Conversation
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]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an MCP tool
get_prompt_volumes(+/api/mcp/prompt-volumesREST 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— newgetPromptVolumesFor(auth, { brandId, limit? }). Org-ownership check on the brand first (wrong-org / missing →null→ 404, before any volume rows are read), then readsprompt_volumesscopedbrand → prompt_sets → prompts → prompt_volumesvia nested inner joins, sorted byest_ai_volumedesc. Returnskeywords,google_volumes,total_google_volume,est_ai_volume,ai_volume_multiplier,competition_index,competition(plusprompt_id,prompt_text,intent,fetched_at).web/src/lib/mcp/server.ts— registers theget_prompt_volumestool (brand_idrequired, optionallimit), calling the same data function.web/src/app/api/mcp/prompt-volumes/route.ts— GET route mirroring theai-traffic/promptspattern, sharinggetPromptVolumesFor.Acceptance criteria
prompt_volumesrows (with competition) for the brand's promptsOut 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 competitionbrand_id→ 404brand_id→ 400get_prompt_volumesMCP tool returns the same payload as the REST routetsc --noEmitandeslintpassMade with Cursor