Repository navigation
Closed
Labels
enhancementNew feature or request
Description
What
Expose Site Audit through the MCP server so an AI assistant (Claude Desktop / Code / Cursor) can audit a page and read the result — charging the same monthly Site Audit quota as the dashboard.
Two tools:
run_site_audit(write/trigger) — inputsbrand_id+url. Starts an audit and returns the new audit'sid+status: "running"(the audit runs async, ~30s). Charges the monthly quota.get_site_audit(read) — inputaudit_id. Returns the full result (total score, category scores, signals, AI recommendations) oncestatusiscompleted(orfailed). The assistant polls this afterrun_site_audit.
Why
The audit + AI fix recommendations are the most actionable output of the product; letting an agent trigger and read them (then act on the drafted fixes) is a natural extension of the existing MCP toolkit.
Approach (mirror the existing generate_content_brief pattern)
- Auth / ownership: MCP requests authenticate via
ans_API key → org (seeweb/src/lib/mcp-auth.ts). Verify the caller's org ownsbrand_idin the web data layer before any outbound call (returnnull→ 404 on mismatch, so probing ids costs nothing) — same guard aslistContentOpportunitiesFor. - Trigger path: add a data fn
runSiteAuditFor(auth, brandId, url)inweb/src/lib/mcp/data.tsthat, after the ownership check, calls a new internal server endpoint (POST /api/internal/site-audits,CRON_SECRET-auth) — exactly howgenerateBriefForcalls/api/internal/content/:id/brief. The internal endpoint reuses the existing audit pipeline inserver/src/routes/audits.js(create running row →runAuditJob→ quota charged on completion). - Quota: the internal endpoint enforces
enforceSiteAuditQuota(orgId)(already inserver/src/lib/plan-guard.js). On exhaustion it returns 402/429; surface that message to the agent. MCP-triggered audits count against the samesite_audit_usagepool, so dashboard + MCP share the limit. - Tools: register
run_site_audit+get_site_auditinweb/src/lib/mcp/server.ts(write-tool description should warn it consumes a monthly audit credit, like thegenerate_content_briefwarning). - REST parity:
POST /api/mcp/site-audits+GET /api/mcp/site-audits/[id]underweb/src/app/api/mcp/, mirroring the data fns.
Acceptance
-
run_site_auditstarts an audit for an owned brand + URL and returns its id; a foreign/unknown brand returns not-found with no audit created -
get_site_auditreturns the running→completed result with score, categories, signals, and recommendations - A run charges the monthly quota; when the quota is exhausted the tool returns the upgrade/limit message (no audit created)
- REST endpoints under
/api/mcp/site-auditsbehave identically - Tool descriptions make the credit cost + async (poll
get_site_audit) behavior explicit
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
gkhngyk commentedon Jun 26, 2026
Picking this up — implementing the two MCP tools (
run_site_audit+get_site_audit) mirroring thegenerate_content_briefpattern, sharing the existingsite_audit_usagequota pool. PR to follow.feat(mcp): run a Site Audit via MCP (run_site_audit + get_site_audit) (…
feat(mcp): list_site_audits + get_site_audit_quota read tools (#306)
feat(agent): use Site Audit from the in-product assistant (#307)