Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
import { z } from 'zod';
import { MENTION_SENTIMENTS, MENTION_SORTS } from '@/lib/mentions-list';
import { getAiUsageFor, getMeFor } from '@/lib/mcp/account';
import { getContentDraftFor, listContentDraftsFor } from '@/lib/mcp/content';
import { contentUuid, listDraftsShape } from '@/lib/mcp/content-schemas';
import {
getActionFor,
getAiTrafficFor,
getCompetitorComparisonFor,
getProductVisibility,
getPromptPerformanceFor,
getPromptVolumesFor,
getSiteAuditFor,
getVisibilitySummaryFor,
getVisibilityTrendFor,
listActionHistoryFor,
listActionsFor,
listBrandsFor,
listCitationsFor,
listCompetitorsFor,
listContentOpportunitiesFor,
listPromptSuggestionsFor,
listPromptsFor,
listReportsFor,
listSignalsFor,
listSiteAuditsFor,
listTopicsFor,
} from '@/lib/mcp/data';
import {
getMentionCompetitorsFor,
getMentionFor,
getMentionsPerceptionFor,
getMentionsSummaryFor,
listMentionsFor,
} from '@/lib/mcp/mentions';
import { FIXTURE_IDS, defineTool } from './define-tool';
/**
* Chat's READ rows (CHAT-20 §9): each one calls the data function the MCP
* tool of the same work calls, so Chat, the MCP Server and the in-product
* agent read the same numbers with the same organization scoping. Inputs
* are the MCP tool's, in its snake_case.
*/
const brandId = contentUuid.describe('Brand id, from list_brands.');
const dateFrom = z.string().optional().describe('ISO timestamp (inclusive) lower bound.');
const dateTo = z.string().optional().describe('ISO timestamp (inclusive) upper bound.');
const model = z.string().optional().describe('A model slug, or comma-separated slugs.');
const region = z.string().optional().describe('A region code, e.g. "US" or "TR".');
const topicId = contentUuid.optional().describe('Topic id, from list_topics.');
const rowCap = (max: number) => z.number().int().min(1).max(max).optional();
/** The Mentions & Sentiment page's filters, the same on both mentions reads. */
const mentionFilters = {
brand_id: brandId,
date_from: dateFrom,
date_to: dateTo,
platform: z.string().optional().describe('One platform id, e.g. "chatgpt-web".'),
region,
topic_id: topicId,
search: z.string().optional().describe("Matched against the prompts' text."),
};
function mentionParams(input: z.output<z.ZodObject<typeof mentionFilters>>) {
return {
brandId: input.brand_id,
dateFrom: input.date_from,
dateTo: input.date_to,
platform: input.platform,
region: input.region,
topicId: input.topic_id,
search: input.search,
};
}
const BRAND = FIXTURE_IDS.brand;
const ITEM = FIXTURE_IDS.item;
export const READ_TOOLS = [
defineTool({
name: 'get_profile',
class: 'read',
area: 'account',
description:
'Who the user is: their id, email, organization, role (admin, manager, analyst or agency_partner) and work areas. Read it before suggesting something only an admin or a manager may do.',
minRole: 'analyst',
planGate: null,
brandOf: null,
costClass: 'C0',
labelKey: 'profile',
route: '/dashboard/settings/account',
mcpTool: 'get_me',
specRow: '4',
inputSchema: z.object({}),
run: (ctx) => getMeFor(ctx),
fixture: { input: {} },
}),
defineTool({
name: 'get_usage',
class: 'read',
area: 'usage',
description:
"How much of the workspace's monthly AI limit is used this period, as a percent, with each feature's share, the plan and the renewal date. No dollar amounts.",
minRole: 'analyst',
planGate: null,
brandOf: null,
costClass: 'C0',
labelKey: 'aiUsage',
route: '/dashboard/settings/billing',
mcpTool: 'get_ai_usage',
specRow: '6',
inputSchema: z.object({}),
run: (ctx) => getAiUsageFor(ctx),
fixture: { input: {} },
}),
defineTool({
name: 'list_brands',
class: 'read',
area: 'brands',
description:
'The brands the user can access: id, name, slug, industry, region. Call it first when the user has not named a brand.',
minRole: 'analyst',
planGate: null,
brandOf: null,
costClass: 'C1',
labelKey: 'brands',
route: '/dashboard/brands',
mcpTool: 'list_brands',
specRow: '7',
inputSchema: z.object({}),
run: (ctx) => listBrandsFor(ctx),
fixture: { input: {} },
}),
defineTool({
name: 'get_visibility_summary',
class: 'read',
area: 'visibility',
description:
'A brand\'s visibility over a period: results, average visibility (0–100), mentions, citations and the top competitors. For "how is my brand doing" questions.',
minRole: 'analyst',
planGate: { platforms: true },
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'visibility',
route: '/dashboard/insights',
mcpTool: 'get_visibility_summary',
specRow: '12',
inputSchema: z.object({
brand_id: brandId,
date_from: dateFrom,
date_to: dateTo,
model,
region,
}),
run: (ctx, input) =>
getVisibilitySummaryFor(ctx, {
brandId: input.brand_id,
dateFrom: input.date_from,
dateTo: input.date_to,
model: input.model,
region: input.region,
}),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'get_visibility_trend',
class: 'read',
area: 'visibility',
description:
"A brand's visibility, mentions and citations over time, by day or week. For trend questions and charts.",
minRole: 'analyst',
planGate: { platforms: true },
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'visibilityTrend',
route: '/dashboard/insights',
mcpTool: 'get_visibility_trend',
specRow: '12',
inputSchema: z.object({
brand_id: brandId,
date_from: dateFrom,
date_to: dateTo,
granularity: z.enum(['day', 'week']).optional(),
model,
region,
topic_id: topicId,
}),
run: (ctx, input) =>
getVisibilityTrendFor(ctx, {
brandId: input.brand_id,
dateFrom: input.date_from,
dateTo: input.date_to,
granularity: input.granularity,
model: input.model,
region: input.region,
topicId: input.topic_id,
}),
fixture: { input: { brand_id: BRAND, granularity: 'week' } },
}),
defineTool({
name: 'list_prompts',
class: 'read',
area: 'prompts',
description:
'The prompts tracked for a brand, with topic, platforms, regions and whether each is active; newest first. Filter by topic or active state.',
minRole: 'analyst',
planGate: { platforms: true },
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'trackedPrompts',
route: '/dashboard/prompts/tracked',
mcpTool: 'list_prompts',
specRow: '13',
inputSchema: z.object({
brand_id: brandId,
topic_id: topicId,
is_active: z.boolean().optional(),
limit: rowCap(500).describe('Row cap, default 100.'),
}),
run: (ctx, input) =>
listPromptsFor(ctx, {
brandId: input.brand_id,
topicId: input.topic_id,
isActive: input.is_active,
limit: input.limit,
}),
fixture: { input: { brand_id: BRAND, is_active: true } },
}),
defineTool({
name: 'get_prompt_performance',
class: 'read',
area: 'prompts',
description:
'Visibility, mentions, citations and appearances per prompt over a period, sorted. For "which prompts do best" or "which dropped this week".',
minRole: 'analyst',
planGate: { platforms: true },
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'promptPerformance',
route: '/dashboard/prompts/tracked',
mcpTool: 'get_prompt_performance',
specRow: '13',
inputSchema: z.object({
brand_id: brandId,
date_from: dateFrom,
date_to: dateTo,
topic_id: topicId,
sort_by: z.enum(['visibility', 'mentions', 'citations', 'appearances']).optional(),
order: z.enum(['desc', 'asc']).optional(),
limit: rowCap(100).describe('Row cap, default 10.'),
model,
region,
}),
run: (ctx, input) =>
getPromptPerformanceFor(ctx, {
brandId: input.brand_id,
dateFrom: input.date_from,
dateTo: input.date_to,
topicId: input.topic_id,
sortBy: input.sort_by,
order: input.order,
limit: input.limit,
model: input.model,
region: input.region,
}),
fixture: { input: { brand_id: BRAND, sort_by: 'visibility' } },
}),
defineTool({
name: 'list_prompt_suggestions',
class: 'read',
area: 'prompts',
description:
"The brand's pending prompt suggestions with topic, reason and an estimated volume. The volume is an AI guess, low confidence: say so when quoting it.",
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'promptSuggestions',
route: '/dashboard/prompts/suggestions',
mcpTool: 'list_prompt_suggestions',
specRow: '15',
inputSchema: z.object({ brand_id: brandId }),
run: (ctx, input) => listPromptSuggestionsFor(ctx, input.brand_id),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'get_prompt_volumes',
class: 'read',
area: 'prompts',
description:
"Each tracked prompt's estimated AI searches a month, with its range and confidence. An estimate, not a measurement.",
minRole: 'analyst',
planGate: { feature: 'prompt_volumes' },
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'promptVolumes',
route: '/dashboard/prompts/tracked',
mcpTool: 'get_prompt_volumes',
specRow: '17',
inputSchema: z.object({
brand_id: brandId,
limit: rowCap(500).describe('Row cap, default 100.'),
}),
run: (ctx, input) => getPromptVolumesFor(ctx, { brandId: input.brand_id, limit: input.limit }),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'list_topics',
class: 'read',
area: 'topics',
description: "The brand's topics, each with its number of prompts.",
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'topics',
route: '/dashboard/prompts/topics',
mcpTool: 'list_topics',
specRow: '24',
inputSchema: z.object({ brand_id: brandId }),
run: (ctx, input) => listTopicsFor(ctx, input.brand_id),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'get_mentions_summary',
class: 'read',
area: 'mentions',
description:
'How often AI answers name the brand and how they speak of it, against the period before: mention rate, net sentiment (−100…+100) and the sentiment split. Under 20 mentions it is a low sample: say so.',
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'mentionsSummary',
route: '/dashboard/mentions',
mcpTool: 'get_mentions_summary',
specRow: '27',
inputSchema: z.object(mentionFilters),
run: (ctx, input) => getMentionsSummaryFor(ctx, mentionParams(input)),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'list_mentions',
class: 'read',
area: 'mentions',
description:
'The AI answers naming the brand, 100 a page: prompt, platform, sentiment, position, competitors named alongside and an excerpt.',
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'mentions',
route: '/dashboard/mentions',
mcpTool: 'list_mentions',
specRow: '27',
inputSchema: z.object({
...mentionFilters,
sentiment: z.enum(MENTION_SENTIMENTS).optional(),
competitor_id: z
.string()
.optional()
.describe('Only answers also naming this competitor, or "none" for none.'),
sort: z.enum(MENTION_SORTS).optional(),
page: z.number().int().min(1).optional(),
}),
run: (ctx, input) =>
listMentionsFor(ctx, {
...mentionParams(input),
sentiment: input.sentiment,
competitorId: input.competitor_id,
sort: input.sort,
page: input.page,
}),
fixture: { input: { brand_id: BRAND, sentiment: 'negative' } },
}),
// Not in CHAT-20 §9 yet: the Mentions area's reads (§8a "snippets, themes")
// that today's agent (/dashboard/agent) has, so Chat answers what it does.
defineTool({
name: 'get_mention',
class: 'read',
area: 'mentions',
description:
'One AI answer naming the brand, in full: its text, citations, the competitors it names, its sentiment and any correction to it.',
minRole: 'analyst',
planGate: null,
brandOf: { lookup: 'prompt_results', idField: 'id' },
costClass: 'C1',
labelKey: 'mention',
route: '/dashboard/mentions',
mcpTool: 'get_mention',
specRow: '27',
inputSchema: z.object({ id: contentUuid.describe('The answer id, from list_mentions.') }),
run: (ctx, input) => getMentionFor(ctx, input.id),
fixture: { input: { id: ITEM } },
}),
defineTool({
name: 'get_mention_competitors',
class: 'read',
area: 'mentions',
description:
"How often AI answers name each competitor in the brand's tracked answers (count, share, change against the period before) and how often alongside the brand.",
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'mentionCompetitors',
route: '/dashboard/mentions',
mcpTool: 'get_mention_competitors',
specRow: '27',
inputSchema: z.object(mentionFilters),
run: (ctx, input) => getMentionCompetitorsFor(ctx, mentionParams(input)),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'get_mentions_perception',
class: 'read',
area: 'mentions',
description:
'What AI associates with the brand: the terms next to it, now and before, the attributes that set it apart from its top competitors, and the biggest gap a competitor leads. Found by rule, no model.',
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'mentionsPerception',
route: '/dashboard/mentions',
mcpTool: 'get_mentions_perception',
specRow: '27',
inputSchema: z.object(mentionFilters),
run: (ctx, input) => getMentionsPerceptionFor(ctx, mentionParams(input)),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'list_citations',
class: 'read',
area: 'citations',
description:
'The domains and pages AI answers cite for the brand over a period, owned, competitor or external.',
minRole: 'analyst',
planGate: { platforms: true },
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'citations',
route: '/dashboard/citations',
mcpTool: 'list_citations',
specRow: '28',
inputSchema: z.object({
brand_id: brandId,
date_from: dateFrom,
date_to: dateTo,
model,
region,
topic_id: topicId,
limit: rowCap(200).describe('Cap on the top domains and pages, default 50.'),
source_filter: z.enum(['all', 'owned', 'competitor', 'external']).optional(),
}),
run: (ctx, input) =>
listCitationsFor(ctx, {
brandId: input.brand_id,
dateFrom: input.date_from,
dateTo: input.date_to,
model: input.model,
region: input.region,
topicId: input.topic_id,
limit: input.limit,
sourceFilter: input.source_filter,
}),
fixture: { input: { brand_id: BRAND, source_filter: 'competitor' } },
}),
defineTool({
name: 'list_competitors',
class: 'read',
area: 'competitors',
description: 'The competitors set up for the brand: id, name and domain. Not a ranking.',
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'competitors',
route: '/dashboard/competitors',
mcpTool: 'list_competitors',
specRow: '29',
inputSchema: z.object({ brand_id: brandId }),
run: (ctx, input) => listCompetitorsFor(ctx, input.brand_id),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'get_competitor_comparison',
class: 'read',
area: 'competitors',
description:
'The brand against each competitor over a period: visibility, mentions, citations and share of voice, also per platform.',
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'competitorComparison',
route: '/dashboard/competitors',
mcpTool: 'get_competitor_comparison',
specRow: '29',
inputSchema: z.object({
brand_id: brandId,
date_from: dateFrom,
date_to: dateTo,
model,
region,
topic_id: topicId,
}),
run: (ctx, input) =>
getCompetitorComparisonFor(ctx, {
brandId: input.brand_id,
dateFrom: input.date_from,
dateTo: input.date_to,
model: input.model,
region: input.region,
topicId: input.topic_id,
}),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'get_shopping_visibility',
class: 'read',
area: 'product_visibility',
description:
"One product's appearances in AI shopping results: by platform, region and date, its rating, reviews and the merchants selling it.",
minRole: 'analyst',
planGate: { feature: 'shopping_analytics' },
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'productVisibility',
route: '/dashboard/shopping',
mcpTool: 'get_product_visibility',
specRow: '33',
inputSchema: z.object({
brand_id: brandId,
product_title: z
.string()
.min(1)
.describe('The product title as AI shopping results show it.'),
}),
run: (ctx, input) =>
getProductVisibility(ctx, { brandId: input.brand_id, productTitle: input.product_title }),
fixture: { input: { brand_id: BRAND, product_title: 'Trail Runner 2' } },
}),
defineTool({
name: 'get_ai_traffic_summary',
class: 'read',
area: 'ai_traffic',
description:
"Visits AI assistants sent to the brand's site over a period: total, by platform, top pages and countries.",
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'aiReferralTraffic',
route: '/dashboard/traffic',
mcpTool: 'get_ai_traffic',
specRow: '35',
inputSchema: z.object({ brand_id: brandId, date_from: dateFrom, date_to: dateTo }),
run: (ctx, input) =>
getAiTrafficFor(ctx, {
brandId: input.brand_id,
dateFrom: input.date_from,
dateTo: input.date_to,
}),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'get_site_audit_summary',
class: 'read',
area: 'site_audit',
description:
"The brand's recent Site Audits, newest first: page, status, score and date. Read one with its issues through list_site_audit_issues.",
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'siteAudits',
route: '/dashboard/audit',
mcpTool: 'list_site_audits',
specRow: '36',
inputSchema: z.object({ brand_id: brandId }),
run: (ctx, input) => listSiteAuditsFor(ctx, input.brand_id),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'list_site_audit_issues',
class: 'read',
area: 'site_audit',
description: 'One Site Audit in full: its score and every check, passed or failed.',
minRole: 'analyst',
planGate: null,
brandOf: { lookup: 'site_audits', idField: 'audit_id' },
costClass: 'C1',
labelKey: 'siteAuditIssues',
route: '/dashboard/audit',
mcpTool: 'get_site_audit',
specRow: '36',
inputSchema: z.object({
audit_id: contentUuid.describe('Site Audit id, from get_site_audit_summary.'),
}),
run: (ctx, input) => getSiteAuditFor(ctx, input.audit_id),
fixture: { input: { audit_id: ITEM } },
}),
defineTool({
name: 'list_action_center_tasks',
class: 'read',
area: 'action_center',
description:
"The brand's Action Center actions, highest priority first: category, impact, priority, status, assignee, due date and task progress.",
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'actions',
route: '/dashboard/action-center/actions',
mcpTool: 'list_actions',
specRow: '38',
inputSchema: z.object({
brand_id: brandId,
status: z.enum(['new', 'in_progress', 'on_hold', 'completed', 'dismissed']).optional(),
category: z.enum(['growth', 'protect', 'recover', 'fix', 'compete']).optional(),
limit: rowCap(200).describe('Row cap, default 50.'),
sort: z.enum(['updated', 'priority']).optional(),
}),
run: (ctx, input) =>
listActionsFor(ctx, {
brandId: input.brand_id,
status: input.status,
category: input.category,
limit: input.limit,
sort: input.sort,
}),
fixture: { input: { brand_id: BRAND, status: 'new' } },
}),
defineTool({
name: 'get_action',
class: 'read',
area: 'action_center',
description:
'One Action Center action in full: what it is about, why, its priority, signals, tasks (What, Where, Why, How, Done when) and outcome.',
minRole: 'analyst',
planGate: null,
brandOf: { lookup: 'actions', idField: 'action_id' },
costClass: 'C1',
labelKey: 'action',
route: '/dashboard/action-center/actions',
mcpTool: 'get_action',
specRow: '39',
inputSchema: z.object({
action_id: contentUuid.describe('Action id, from list_action_center_tasks.'),
}),
run: (ctx, input) => getActionFor(ctx, input.action_id),
fixture: { input: { action_id: ITEM } },
}),
defineTool({
name: 'list_signals',
class: 'read',
area: 'action_center',
description:
'The changes the Action Center detected for the brand, newest first: what moved, by how much, where, and the actions built on each.',
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'signals',
route: '/dashboard/action-center/signals',
mcpTool: 'list_signals',
specRow: '40',
inputSchema: z.object({
brand_id: brandId,
status: z.enum(['new', 'acknowledged', 'resolved', 'dismissed']).optional(),
kind: z.string().optional().describe('A signal kind, as returned in earlier rows.'),
limit: rowCap(200).describe('Row cap, default 50.'),
}),
run: (ctx, input) =>
listSignalsFor(ctx, {
brandId: input.brand_id,
status: input.status,
kind: input.kind,
limit: input.limit,
}),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'get_action_history',
class: 'read',
area: 'action_center',
description:
'Closed actions with their measured outcome, latest first. An outcome before day 30 is a reading so far, and a change is never claimed as caused by the action.',
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'actionHistory',
route: '/dashboard/action-center/history',
mcpTool: 'list_action_history',
specRow: '42',
inputSchema: z.object({
brand_id: brandId,
limit: rowCap(200).describe('Row cap, default 50.'),
}),
run: (ctx, input) => listActionHistoryFor(ctx, { brandId: input.brand_id, limit: input.limit }),
fixture: { input: { brand_id: BRAND } },
}),
defineTool({
name: 'list_content_opportunities',
class: 'read',
area: 'content',
description:
"The brand's content opportunities, highest score first: the prompts where it loses visibility and the page that would win them.",
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'contentOpportunities',
route: '/dashboard/content',
mcpTool: 'list_content_opportunities',
specRow: '48',
inputSchema: z.object({
brand_id: brandId,
status: z
.enum(['new', 'reviewed', 'sent', 'in_progress', 'done', 'dismissed', 'archived'])
.optional(),
impact: z.enum(['high', 'medium', 'low']).optional(),
type: z.enum(['owned', 'earned']).optional(),
limit: rowCap(200).describe('Row cap, default 50.'),
}),
run: (ctx, input) =>
listContentOpportunitiesFor(ctx, {
brandId: input.brand_id,
status: input.status,
impact: input.impact,
type: input.type,
limit: input.limit,
}),
fixture: { input: { brand_id: BRAND, impact: 'high' } },
}),
defineTool({
name: 'list_drafts',
class: 'read',
area: 'content',
description:
"The brand's Content Library drafts, latest changed first: title, status, method, page type and author.",
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'drafts',
route: '/dashboard/content/library',
mcpTool: 'list_content_drafts',
specRow: '53',
inputSchema: z.object(listDraftsShape),
run: (ctx, input) => listContentDraftsFor(ctx, input.brand_id, input.status),
fixture: { input: { brand_id: BRAND, status: 'in_review' } },
}),
defineTool({
name: 'get_draft',
class: 'read',
area: 'content',
description:
'One draft: its HTML passage by passage, where it is live, and the suggestions waiting for review. Passages AI answers quote are locked.',
minRole: 'analyst',
planGate: null,
brandOf: { lookup: 'content_drafts', idField: 'draft_id' },
costClass: 'C1',
labelKey: 'draft',
route: '/dashboard/content/library',
mcpTool: 'get_content_draft',
specRow: '53',
inputSchema: z.object({ draft_id: contentUuid.describe('Draft id, from list_drafts.') }),
run: (ctx, input) => getContentDraftFor(ctx, input.draft_id),
fixture: { input: { draft_id: ITEM } },
}),
defineTool({
name: 'get_reports',
class: 'read',
area: 'reports',
description: "The brand's saved reports, newest first: title, template and date range.",
minRole: 'analyst',
planGate: null,
brandOf: { input: 'brand_id' },
costClass: 'C1',
labelKey: 'reports',
route: '/dashboard/reports',
mcpTool: 'list_reports',
specRow: '63',
inputSchema: z.object({
brand_id: brandId,
limit: rowCap(100).describe('Row cap, default 50.'),
}),
run: (ctx, input) => listReportsFor(ctx, input.brand_id, input.limit),
fixture: { input: { brand_id: BRAND } },
}),
];