Skip to content

feat(mcp/agent): expose prompt-level performance tool (get_prompt_performance) - #181

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
Pallavikumarimdb:feat/mcp-prompt-performance
Jun 7, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
Pallavikumarimdb:feat/mcp-prompt-performance

Conversation

@Pallavikumarimdb

Copy link
Copy Markdown
Contributor

Exposes a prompt-level performance tool (get_prompt_performance) to let the in-product agent and external MCP clients answer questions about prompt performance metrics (average visibility, total mentions, citations, appearances, and competitor scores).

How

  • Database Function: Added migration 00013 defining prompt_performance_aggregates to group prompt_results by prompt_id, isolating organic results from ChatGPT Shopping (chatgpt-shopping).
  • Data Layer & API: Added getPromptPerformanceFor to handle tenant ownership check, average calculations, sorting, and slicing. Exposed this function via a new REST API endpoint /api/mcp/prompt-performance.
  • Agent Integration: Registered get_prompt_performance with the in-product agent tools, the MCP server registry, and updated the system prompt instructions to leverage it alongside bar charts.

Closes: #139

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the migration, data layer, REST route, and agent/MCP registration — all consistent with the existing aggregate-RPC and MCP-tool patterns. The chatgpt-shopping isolation matches #155, ownership check returns 404 before any data read, averages are computed in JS from raw sums per the parity convention, and sorting has a stable prompt_id tiebreak. Migration number 00013 is free on main. Nicely done @Pallavikumarimdb — merging.

@gkhngyk
gkhngyk marked this pull request as ready for review June 7, 2026 14:11
@gkhngyk
gkhngyk merged commit e467943 into ansvisor:main Jun 7, 2026
2 checks passed
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/agent): expose prompt-level performance tool (get_prompt_performance)

2 participants