Repository navigation
feat(mcp): add a create_improve_action tool for sending Improve suggestions to Action Center - #1014
Merged
gkhngyk merged 12 commits intoOct 13, 2026
Merged
Conversation
The Positions panel was fixed to the table's range, so checking a prompt over another period meant changing the whole table. The panel now has its own 24h / 7d / 30d / 90d / Custom control. It opens on the table's range, and changing it reloads only the panel. The open prompt and the panel's range are mirrored to the URL (?positions=<id>&positionsRange=7d) so the view can be shared. A custom range no longer spells its dates twice in the header. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gestions For one prompt and the panel's range, the Positions panel gets an Improve tab: per AI platform where the brand is not mentioned, mentioned late, or mentioned early but not cited, AI-generated suggestions grounded in that platform's own evidence (fan-out sub-queries, cited domains, competitor URLs, the answer text). The server checks every source against that evidence and drops invented ones, so each card names something real. Suggestions are editable drafts: check, edit, remove (undoable) or add your own. Generation is always the user's click and is metered: each call's real token cost is charged against a monthly budget of 1% of the plan price (Growth $2.49, Enterprise $4.99 or 1% of plan_overrides.contractMonthlyUsd), so the share holds whichever model IMPROVE_SUGGESTION_MODEL points at. Sets are cached per prompt, range and location; newer runs show a "Regenerate" notice instead of rebuilding automatically. Growth+ only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Improve tab's footer gets Send Actions: the checked suggestions, exactly as edited, become one Action Center action (kind prompt_improve, category compete). Each suggestion is a task with its body, platform and evidence in the new action_tasks.details column. The action's why and goal are written from the platform states at send time, its impact from the prompt's demand and the size of the gap, and its baseline keeps the positions per platform for PROMPT-008. Validation measures it on its own prompt. After a send the button turns into Open in Actions, the footer shows the action id, and the sent suggestions are marked. The send is recorded on the cached set, so this survives a reload, and is dropped once the action is dismissed. An idempotency key per send makes a double click create one action. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…stions to Action Center Co-Authored-By: Claude Opus 5.5 <[email protected]>
…improve-action # Conflicts: # web/src/components/prompts/prompt-positions-sheet.tsx
# Conflicts: # web/src/components/prompts/prompt-positions-sheet.tsx
- Treat a platform mentioned in fewer than half its runs as not mentioned, and show "mentioned in X of Y runs" in each platform header. - Retry on a failed read re-reads the cache instead of generating; a failed generate keeps the set already on screen. - Charge every model attempt, including schema misses withRetry repeats, and log a failed usage insert. - Price openrouter/ model ids as the model they route to. - Classify platforms from every answer in the window, like the Positions tab; keep the newest 600 for evidence only. - Fix the stale budget name in server/.env.example. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…actions # Conflicts: # web/src/components/prompts/prompt-improve-tab.tsx
Citations are counted on a basket's pages, and the action's payload had none, so the metric was always null. Carry the selected suggestions' brand_page sources as payload.pages, and list citations in kpi_keys only when there are pages to measure. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to feature/mcp-create-improve-action
…improve-action # Conflicts: # server/src/routes/prompts.js
gkhngyk
approved these changes
Oct 13, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good, thanks. A follow-up idea: no MCP tool reads a prompt's Improve suggestions, so an agent can only send suggestions it wrote itself. A read tool would let it send the generated ones.
gkhngyk
added a commit
that referenced
this pull request
Oct 14, 2026
…#1019) * feat(content): show and enforce the monthly content opportunity quota Plans get a monthly limit on new content opportunities (Starter 10, Growth 50, Enterprise/self-hosted unlimited), counted separately from the existing brief quota and renewing with the subscription. Usage is recorded in opportunity_usage, so dismissed and deleted opportunities still count. The nightly generation claims slots atomically per organization (claim_opportunity_usage) before calling the model and hands back the ones it doesn't use. The Content page leads its stat row with a usage card for both counters, and GET /api/content/usage exposes the same figures. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(prompts): show tracked prompt usage against the plan limit (#1009) The Tracked Prompts page showed only "All Prompts (N)", with no sign of the plan limit or how many slots were left, so users found out at save time. The header now shows "used / limit prompt locations · <plan> plan" with a progress bar and the slots left (amber from 80%, red when full or over). When the limit is reached, Add prompt explains it with Upgrade plan (Starter) or Contact us (Growth / Enterprise) instead of the form. The numbers come from getLocationQuota, the same org-wide prompt-location count the plan-limit guard enforces, so the counter can't promise a slot a save would reject. getPromptsPageData returns it in the page's single round trip. Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> * feat(prompts): pick the Positions panel's date range inside the panel (#1010) The Positions panel was fixed to the table's range, so checking a prompt over another period meant changing the whole table. The panel now has its own 24h / 7d / 30d / 90d / Custom control. It opens on the table's range, and changing it reloads only the panel. The open prompt and the panel's range are mirrored to the URL (?positions=<id>&positionsRange=7d) so the view can be shared. A custom range no longer spells its dates twice in the header. Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> * feat(prompts): add an Improve tab with platform-specific position suggestions (#1011) * feat(prompts): pick the Positions panel's date range inside the panel The Positions panel was fixed to the table's range, so checking a prompt over another period meant changing the whole table. The panel now has its own 24h / 7d / 30d / 90d / Custom control. It opens on the table's range, and changing it reloads only the panel. The open prompt and the panel's range are mirrored to the URL (?positions=<id>&positionsRange=7d) so the view can be shared. A custom range no longer spells its dates twice in the header. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(prompts): add an Improve tab with platform-specific position suggestions For one prompt and the panel's range, the Positions panel gets an Improve tab: per AI platform where the brand is not mentioned, mentioned late, or mentioned early but not cited, AI-generated suggestions grounded in that platform's own evidence (fan-out sub-queries, cited domains, competitor URLs, the answer text). The server checks every source against that evidence and drops invented ones, so each card names something real. Suggestions are editable drafts: check, edit, remove (undoable) or add your own. Generation is always the user's click and is metered: each call's real token cost is charged against a monthly budget of 1% of the plan price (Growth $2.49, Enterprise $4.99 or 1% of plan_overrides.contractMonthlyUsd), so the share holds whichever model IMPROVE_SUGGESTION_MODEL points at. Sets are cached per prompt, range and location; newer runs show a "Regenerate" notice instead of rebuilding automatically. Growth+ only. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(prompts): address review on the Improve tab - Treat a platform mentioned in fewer than half its runs as not mentioned, and show "mentioned in X of Y runs" in each platform header. - Retry on a failed read re-reads the cache instead of generating; a failed generate keeps the set already on screen. - Charge every model attempt, including schema misses withRetry repeats, and log a failed usage insert. - Price openrouter/ model ids as the model they route to. - Classify platforms from every answer in the window, like the Positions tab; keep the newest 600 for evidence only. - Fix the stale budget name in server/.env.example. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> * feat(prompts): send selected Improve suggestions to Action Center (#1012) * feat(prompts): pick the Positions panel's date range inside the panel The Positions panel was fixed to the table's range, so checking a prompt over another period meant changing the whole table. The panel now has its own 24h / 7d / 30d / 90d / Custom control. It opens on the table's range, and changing it reloads only the panel. The open prompt and the panel's range are mirrored to the URL (?positions=<id>&positionsRange=7d) so the view can be shared. A custom range no longer spells its dates twice in the header. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(prompts): add an Improve tab with platform-specific position suggestions For one prompt and the panel's range, the Positions panel gets an Improve tab: per AI platform where the brand is not mentioned, mentioned late, or mentioned early but not cited, AI-generated suggestions grounded in that platform's own evidence (fan-out sub-queries, cited domains, competitor URLs, the answer text). The server checks every source against that evidence and drops invented ones, so each card names something real. Suggestions are editable drafts: check, edit, remove (undoable) or add your own. Generation is always the user's click and is metered: each call's real token cost is charged against a monthly budget of 1% of the plan price (Growth $2.49, Enterprise $4.99 or 1% of plan_overrides.contractMonthlyUsd), so the share holds whichever model IMPROVE_SUGGESTION_MODEL points at. Sets are cached per prompt, range and location; newer runs show a "Regenerate" notice instead of rebuilding automatically. Growth+ only. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(prompts): send selected Improve suggestions to Action Center The Improve tab's footer gets Send Actions: the checked suggestions, exactly as edited, become one Action Center action (kind prompt_improve, category compete). Each suggestion is a task with its body, platform and evidence in the new action_tasks.details column. The action's why and goal are written from the platform states at send time, its impact from the prompt's demand and the size of the gap, and its baseline keeps the positions per platform for PROMPT-008. Validation measures it on its own prompt. After a send the button turns into Open in Actions, the footer shows the action id, and the sent suggestions are marked. The send is recorded on the cached set, so this survives a reload, and is dropped once the action is dismissed. An idempotency key per send makes a double click create one action. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(prompts): address review on the Improve tab - Treat a platform mentioned in fewer than half its runs as not mentioned, and show "mentioned in X of Y runs" in each platform header. - Retry on a failed read re-reads the cache instead of generating; a failed generate keeps the set already on screen. - Charge every model attempt, including schema misses withRetry repeats, and log a failed usage insert. - Price openrouter/ model ids as the model they route to. - Classify platforms from every answer in the window, like the Positions tab; keep the newest 600 for evidence only. - Fix the stale budget name in server/.env.example. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(prompts): measure Improve action citations on the pages it names Citations are counted on a basket's pages, and the action's payload had none, so the metric was always null. Carry the selected suggestions' brand_page sources as payload.pages, and list citations in kpi_keys only when there are pages to measure. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]> * feat(mcp): add a create_improve_action tool for sending Improve suggestions to Action Center (#1014) * feat(prompts): pick the Positions panel's date range inside the panel The Positions panel was fixed to the table's range, so checking a prompt over another period meant changing the whole table. The panel now has its own 24h / 7d / 30d / 90d / Custom control. It opens on the table's range, and changing it reloads only the panel. The open prompt and the panel's range are mirrored to the URL (?positions=<id>&positionsRange=7d) so the view can be shared. A custom range no longer spells its dates twice in the header. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(prompts): add an Improve tab with platform-specific position suggestions For one prompt and the panel's range, the Positions panel gets an Improve tab: per AI platform where the brand is not mentioned, mentioned late, or mentioned early but not cited, AI-generated suggestions grounded in that platform's own evidence (fan-out sub-queries, cited domains, competitor URLs, the answer text). The server checks every source against that evidence and drops invented ones, so each card names something real. Suggestions are editable drafts: check, edit, remove (undoable) or add your own. Generation is always the user's click and is metered: each call's real token cost is charged against a monthly budget of 1% of the plan price (Growth $2.49, Enterprise $4.99 or 1% of plan_overrides.contractMonthlyUsd), so the share holds whichever model IMPROVE_SUGGESTION_MODEL points at. Sets are cached per prompt, range and location; newer runs show a "Regenerate" notice instead of rebuilding automatically. Growth+ only. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(prompts): send selected Improve suggestions to Action Center The Improve tab's footer gets Send Actions: the checked suggestions, exactly as edited, become one Action Center action (kind prompt_improve, category compete). Each suggestion is a task with its body, platform and evidence in the new action_tasks.details column. The action's why and goal are written from the platform states at send time, its impact from the prompt's demand and the size of the gap, and its baseline keeps the positions per platform for PROMPT-008. Validation measures it on its own prompt. After a send the button turns into Open in Actions, the footer shows the action id, and the sent suggestions are marked. The send is recorded on the cached set, so this survives a reload, and is dropped once the action is dismissed. An idempotency key per send makes a double click create one action. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(mcp): add a create_improve_action tool for sending Improve suggestions to Action Center Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(prompts): address review on the Improve tab - Treat a platform mentioned in fewer than half its runs as not mentioned, and show "mentioned in X of Y runs" in each platform header. - Retry on a failed read re-reads the cache instead of generating; a failed generate keeps the set already on screen. - Charge every model attempt, including schema misses withRetry repeats, and log a failed usage insert. - Price openrouter/ model ids as the model they route to. - Classify platforms from every answer in the window, like the Positions tab; keep the newest 600 for evidence only. - Fix the stale budget name in server/.env.example. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(prompts): measure Improve action citations on the pages it names Citations are counted on a basket's pages, and the action's payload had none, so the metric was always null. Carry the selected suggestions' brand_page sources as payload.pages, and list citations in kpi_keys only when there are pages to measure. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]> * feat(prompts): replace the row's Edit icon with a ⋯ actions menu (#1015) * feat(prompts): pick the Positions panel's date range inside the panel The Positions panel was fixed to the table's range, so checking a prompt over another period meant changing the whole table. The panel now has its own 24h / 7d / 30d / 90d / Custom control. It opens on the table's range, and changing it reloads only the panel. The open prompt and the panel's range are mirrored to the URL (?positions=<id>&positionsRange=7d) so the view can be shared. A custom range no longer spells its dates twice in the header. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(prompts): add an Improve tab with platform-specific position suggestions For one prompt and the panel's range, the Positions panel gets an Improve tab: per AI platform where the brand is not mentioned, mentioned late, or mentioned early but not cited, AI-generated suggestions grounded in that platform's own evidence (fan-out sub-queries, cited domains, competitor URLs, the answer text). The server checks every source against that evidence and drops invented ones, so each card names something real. Suggestions are editable drafts: check, edit, remove (undoable) or add your own. Generation is always the user's click and is metered: each call's real token cost is charged against a monthly budget of 1% of the plan price (Growth $2.49, Enterprise $4.99 or 1% of plan_overrides.contractMonthlyUsd), so the share holds whichever model IMPROVE_SUGGESTION_MODEL points at. Sets are cached per prompt, range and location; newer runs show a "Regenerate" notice instead of rebuilding automatically. Growth+ only. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(prompts): send selected Improve suggestions to Action Center The Improve tab's footer gets Send Actions: the checked suggestions, exactly as edited, become one Action Center action (kind prompt_improve, category compete). Each suggestion is a task with its body, platform and evidence in the new action_tasks.details column. The action's why and goal are written from the platform states at send time, its impact from the prompt's demand and the size of the gap, and its baseline keeps the positions per platform for PROMPT-008. Validation measures it on its own prompt. After a send the button turns into Open in Actions, the footer shows the action id, and the sent suggestions are marked. The send is recorded on the cached set, so this survives a reload, and is dropped once the action is dismissed. An idempotency key per send makes a double click create one action. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(prompts): replace the row's Edit icon with a ⋯ actions menu The last column of the Tracked Prompts table was a single pencil. It is now a ⋯ menu (Base UI, so it opens from mouse and keyboard and closes on Esc and outside clicks) with: - Edit: the existing dialog - Pause tracking / Resume tracking: one click, with a toast - Improve position…: opens the Positions panel on its Improve tab - Delete: confirms "Delete prompt and its history?", removes the row and its count at once, and offers Undo for 10 s Prompts have no soft delete (a delete drops their history), so the undo window is a delayed delete: the row is hidden at once and deleted when the window ends, or right away if the table unmounts first. Closing the page inside the window leaves the prompt in place. Suggest Content and the bulk action bar from the task are follow-ups. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(prompts): import the row menu icons apart from the limit counter's Keeps this branch merging cleanly with the tracked prompt limit counter (feature/prompts-tracked-limit-counter), which adds an icon to the same list. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(prompts): import the dropdown menu apart from the bulk import's Keeps this branch merging cleanly with bulk import (feature/prompts-bulk-import), which adds imports at the same spot. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]> * feat(prompts): make Prompts an expandable sidebar menu with a route per view (#1016) * feat(prompts): make Prompts an expandable sidebar menu with a route per view The sidebar had a single Prompts link, and the page's views lived behind ?tab= / ?view= query params. Prompts now expands in the sidebar to: - Tracked Prompts, with the brand's prompt count - Prompt Suggestions - Query Fan-outs - Insights Each has its own route: /dashboard/prompts/{tracked,suggestions,fan-outs, insights}. Each route renders the same page, which reads its view from the path. The page's tabs stay, and switching them rewrites the path in place, so the sidebar and the tabs always show the same view. Moving between views from the sidebar keeps the date range and location; location is now in the URL as well. /dashboard/prompts and its old ?tab= / ?view= links redirect to the matching route (next.config redirects). The submenu's open state is remembered in localStorage and opens on any Prompts route. Arrow keys move through the sidebar links (right/left open, enter or leave the submenu), the parent carries aria-expanded, and a collapsed sidebar opens on keyboard focus as it already does on hover. The mobile nav lists the four views under Prompts. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(prompts): define the tracked prompt count apart from bulk import's action Keeps this branch merging cleanly with bulk import (feature/prompts-bulk-import), which adds a function at the same spot. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
4 of 12 tasks
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
PROMPT-004 follow-up. The acceptance criteria say "API: POST /actions from source prompt_improve is also exposed through MCP". This PR adds a
create_improve_actionMCP tool, plus its REST mirrorPOST /api/mcp/prompts/[id]/improve-action. Like the Improve tab's Send Actions, it turns suggestions into oneprompt_improveAction Center action.How it reaches the server. MCP calls authenticate with an
ans_API key, not a session, so they can't callPOST /api/prompts/:id/improve/actiondirectly. The tool follows the same pattern asgenerate_content_briefandrun_site_audit:createImproveActionFor(web) checks that the prompt belongs to the key's org. A foreign or unknown prompt returns "Prompt not found" and never reaches the server.POST /api/internal/prompts/:promptId/improve/action(CRON_SECRETauth), passing the key's user.enforceFeature(userId, 'prompt_improve'). This is the same plan checkrequireFeaturedoes for the dashboard route. Plan or subscription errors come back with their message.One code path. I moved the body of the dashboard route into an exported
sendImproveAction({ promptId, userId, body }). The dashboard route and the internal endpoint both call it, so both get the same:sendImproveToActionCenteridempotencysent_actionsbookkeepingThe dashboard route's behaviour and responses are unchanged.
Tool input:
prompt_id,range { preset, from, to?, region? },idempotency_key,suggestions[{ id, platform, title, body?, sources? }]. It returns{ actionId, actionNo, created, taskCount }. If the sameidempotency_keyis reused, it returns the existing action withcreated: false. The tool description marks it as a write that should only run on explicit user intent.Limitation (same as the panel): the tool sends an existing suggestion set; it does not generate one. If the prompt has no set for the requested range yet, the tool returns the server's "Generate suggestions for this range first" error.
I also added the tool to
docs/guides/mcp-server.mdx, which now lists 29 tools.Related issue
PROMPT-004 (MCP part of the acceptance criteria). Follows #1012.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Automated:
server/src/routes/prompts-improve-send.test.jscovers:prompt_improveis refused before any readweb/src/lib/mcp/improve-action.test.tscovers:CRON_SECRETthrowsManual (needs
CRON_SECRETset for both web and server):created: true, and the action should appear in Action Center with one task.actionIdwithcreated: false.30dwithout generating suggestions for it. You should get "Generate suggestions for this range first".Live test
I ran this branch locally (web + server, self-hosted mode, demo org) and called the tool through the real MCP endpoint (
POST /api/mcp, JSON-RPCtools/call) with a freshans_key for[email protected]. The prompt was "What are the best coffee subscription services in 2026?", which had a stored 30d Improve set.tools/listcreate_improve_actionlisted (29 tools)created: true, action AC-3 with 2 tasksidempotency_key)actionId,created: falsePOST /api/mcp/prompts/:id/improve-actioncreated: true, AC-4I also checked the new action two ways:
get_action:kind: prompt_improve, both tasks aremode: humanwith the titles as sent.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
yarn test(484 passed) andyarn buildinweb/;npm run format,npm run lintandnpm test(1078 passed) inserver/;npm run version:checkat the root.🤖 Generated with Claude Code