mcp: add async "audits" tools module (start_audit + get_audit) - #111
Merged
Merged
Conversation
Third MCP capability — AEO audits. Audits run asynchronously (the worker runs
each engine and fills in the score later), so this is a start + poll pair,
mirroring the in-app runAudit flow:
- start_audit({ url, engines? }) — validate URL, charge credits (engines default
to the free rule+dns; AI engines cost credits), insert queued audit rows with
a shared scan_run_id, notify the worker /enqueue. Returns the run id.
- get_audit({ run_id }) — per-engine status + scores (+ public report links when
complete) for that run.
Owner-scoped throughout (service-role client). Registered alongside promote +
stats in app/api/mcp/route.ts. Docs + API-tokens UI updated. Contract test
asserts both tools register + are discoverable over the real SDK.
Built in an isolated worktree off master to stay clear of the concurrent
@profullstack/stack refactor. tsc + next build clean; 3 MCP contract tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
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.
What
Third MCP capability — AEO audits. Audits are asynchronous (the worker runs each engine and fills in the score later), so this is a start + poll pair, mirroring the in-app
runAuditflow.start_auditscan_run_id) → notify the worker/enqueue. Returns the run id. Engines default to rule+dns (free); AI engines (claude/openai/gemini/perplexity/…) cost credits.{ url, engines? }get_audit{ run_id }So an agent can:
start_audit({ url })→ get a run id →get_audit({ run_id })until the scores land.Safety / scoping
owner_id).engines, it runs the free rule+dns engines — no surprise credit burn. AI engines are opt-in.isAllowedTargetUrl,checkPerTargetLimit(refunds credits if the per-target cooldown blocks it),consumeCredit/refundCredit.triggered_by='manual'(the only allowed non-scheduled value).Changes
lib/mcp/audits.ts—registerAuditTools(server)app/api/mcp/route.ts— register alongside promote + statsdocs/mcp.md+ API-tokens UI — tool listtests/contract/mcp-audits.test.ts— both tools register + discoverable over the real SDKVerified
Built in an isolated worktree off master (clear of the concurrent
@profullstack/stackrefactor).tscclean,next buildcompiles/api/mcp, all 3 MCP contract tests pass (promote + stats + audits). Same instance, no migration, no new deps.🤖 Generated with Claude Code