Repository navigation
Description
Epic — large, multi-part feature. Not a good-first-issue. Should land after the MCP read-tool surface is solid (see Dependencies).
What
An in-dashboard conversational AI assistant — chat with your dashboard about visibility trends, competitor moves, and content gaps without leaving the page (roadmap item from the README's "What's next").
It should be agentic (calls tools to pull the user's real data, never makes numbers up) and able to render charts/visualizations in its answers — e.g. "compare the last 30 days" returns a trend chart, "who's gaining share of voice?" returns a bar chart — not just prose.
Why
The dashboard already holds rich AI-search data; today users have to navigate pages and read charts themselves. A grounded chat that answers in plain language and draws the relevant chart turns analysis into a conversation — a strong differentiator and retention driver. Modern assistants present visuals, so chart output is part of the bar, not a nice-to-have.
How it fits the codebase
The assistant is essentially an agent over the existing tool/data layer + a chat UI + chart rendering — it should compose what we already have, not build a parallel stack:
- Tools = the MCP data layer. The read functions in
web/src/lib/mcp/data.ts(brands, visibility summary, prompts, topics, content opportunities) are the assistant's tools. Call them server-side; reuse the org/brand ownership scoping already inweb/src/lib/mcp-auth.ts. - Agent loop: the backend already uses the Vercel AI SDK — use it for tool-calling + streaming.
- Charts: tools return chart-ready structured data; the client renders with the existing Recharts components on the Insights page (
insights/_charts.tsx). The model selects the chart type / returns a small spec (type + series); we render it with our components — the model does not draw images. - Analyst behavior: the Anthropic Skills (
ansvisor-aeo-coach) AEO knowledge can inform the assistant's system prompt.
Dependencies & sequencing
- Hard dependency — the MCP read-tool surface. Finish the in-flight content-opportunity tools (feat(mcp): expose list_content_opportunities tool + REST endpoint #64 / feat(mcp): expose get_content_opportunity tool + REST endpoint #65 / feat(mcp): expose generate_content_brief tool that triggers the brief endpoint #66) and make sure the read tools cover what the assistant needs: visibility time-series (for trend charts), competitors, citations, prompts. Build the assistant after this so it reuses the tools instead of duplicating them.
- Performance — the chart/time-series tools should build on the DB-side aggregation in perf(insights): speed up the dashboard insights page (DB-side aggregation + cache with invalidation) #93 (the current insights actions aggregate in JS; an assistant firing many queries would amplify that).
- Soft / parallel — Skills. Feeds the analyst prompt; not a blocker.
Phased plan (suggested)
- Tool readiness — confirm/extend the MCP data layer for the assistant's needs, incl. chart-shaped time-series data (builds on perf(insights): speed up the dashboard insights page (DB-side aggregation + cache with invalidation) #93).
- Agent + chat UI (text-only) — a chat panel in the dashboard; AI SDK agent loop calling the tools; streamed answers grounded strictly in the user's own data; brand/org scoped.
- Chart rendering — agent returns a chart spec (type + series); render with Recharts (trend / bar / comparison).
- Polish — suggested starter prompts, conversation history, and guardrails (answer only from the user's data; an LLM cost/rate guard).
Cross-cutting requirements
- Grounded only in the user's own data — answers come from tool calls scoped to the user's org/brand (reuse the
mcp-authscoping); no fabricated numbers, never another org's data. - i18n — the dashboard ships 13 languages (next-intl); the assistant should reply in the user's locale.
- LLM provider — reuse the project's multi-provider setup (OpenAI / Anthropic / Google / …); self-hosted instances use their own keys (BYO). Don't hardcode a provider.
- Cost & gating — LLM calls cost money: add a cost/rate guard, and in cloud gate the feature behind a plan flag (there's no
ai_assistantfeature inconfig/plans.tsyet — add one). Self-hosted stays unlocked like other features. - Empty / new-brand state — handle brands with little or no tracking data gracefully (say so, suggest running tracking) instead of erroring or hallucinating.
Current MCP read surface (
web/src/lib/mcp/data.ts):list_brands,get_visibility_summary,list_topics,list_prompts,list_content_opportunities,get_content_opportunity. The assistant additionally needs visibility time-series (for trend charts), competitors, and citations read tools — not present yet, so building them is part of "Tool readiness".
Acceptance criteria
- A chat panel inside the dashboard answers questions about the brand's AI-search performance with streamed, data-grounded replies.
- Every answer is backed by real tool calls scoped to the user's org/brand — numbers match the dashboard; no cross-org leakage.
- Visualization questions (e.g. "compare the last 30 days", "top competitors by share of voice") render a chart via the existing Recharts components, not just text.
- Replies follow the user's locale.
- LLM usage is gated (plan feature in cloud / BYO key self-hosted) and has a cost/rate guard.
- Brands with no/low data are handled gracefully.
- Existing MCP tools are reused, not forked — no regressions.
Out of scope (for now)
- Write actions from chat (trigger tracking, generate briefs) — later, via the existing tools.
- Voice input, cross-brand analysis, scheduled digests.
- A new charting library — reuse Recharts.
Notes
This issue captures the plan; implementation should wait on the MCP tool surface and #93. Happy to split into sub-issues per phase once we start.
Activity
feat(mcp): expose get_visibility_trend tool (visibility time-series) …
feat(agent): db schema + plan flag for the in-product AI agent (#120)
feat(agent): end-to-end in-product AI agent chat (#121)
gkhngyk commentedon Jun 2, 2026
Closing as functionally complete. The epic shipped across four phases plus a polish layer:
Phase 1 — Tool readiness
get_competitor_comparisonMCP tool + RESTlist_citationsMCP tool + RESTget_visibility_trendMCP tool + RESTPhase 2 — Agent + chat UI
/auth/confirm, password set on accept)Phase 3 — Chart rendering
render_charttool + Recharts wrapper, inline charts in assistant bubblesPhase 4 — Polish
useUserRole/<RoleGate>) for the broader RBAC story this epic surfacedAcceptance, item by item
Open follow-ups (independent, not gating this epic)
get_ai_trafficMCP toolget_prompt_volumesMCP toolget_prompt_performanceMCP tool (closes the "what's the best prompt today" gap surfaced while testing)These are standalone MCP tool additions and will be picked up individually.