Learn · guide3 min read

Learn / The audit-fix loop

The audit-fix loop: let your AI assistant grade its own homework

Connect Lekta to Claude, Cursor or any MCP client and turn a one-off audit into a closed loop: audit, apply the fixes, re-audit, show the diff.

PublishedUpdatedCited basis
MCPAnswerability layer

A report you read is a to-do list. A report your AI assistant reads is a work order. Once Lekta is connected over MCP, one sentence starts the whole cycle: “Audit this URL with Lekta, apply the fixes it suggests, re-audit, and show me the difference.” The assistant runs the audit, reads the fix plan, edits the markup, runs the audit again and hands you a before/after diff — grades, scores and every check that moved.

The protocol and the five Lekta tools

The Model Context Protocol, published by Anthropic on 2024-11-25 and since adopted across Claude, Cursor and a long list of agent runtimes, gives an assistant a standard way to call external tools. Lekta exposes its engine at https://lekta.dev/mcp as a hosted endpoint: no local server, no install — a client config block with one URL and one API key header connects it.

Five tools cross that wire. lekta_audit runs a fresh audit or returns the cached report for a URL. lekta_report reads the last stored report without spending quota. lekta_fix_plan turns the findings into a prioritized list with the point impact of each fix. lekta_diff compares two runs of the same URL — the loop’s scoreboard. lekta_my_sites lists your tracked sites with their latest grades.

Connecting a client: key, endpoint, config

Setup is documented per platform in the lekta-mcp repository for Windows, macOS and Linux. The short version: create an API key on your Lekta panel (lekta.dev/en/panel/api, keys start with lekta_), then point your MCP client at https://lekta.dev/mcp with that key as a bearer token — the endpoint speaks JSON-RPC 2.0 over plain HTTPS on port 443. Tool responses arrive in English regardless of site language — they are written for the agent, and the agent translates for you.

The loop prompt and the quota that funds it

A fresh audit finishes in 5–30 seconds with a hard limit of 75, so a full three-iteration loop fits inside five minutes. Paste this into a connected assistant that also has access to your site’s code, and replace the URL:

Audit https://example.com/docs/getting-started with Lekta (lekta_audit).
Read the fix plan (lekta_fix_plan). Apply every fix that does not change
what the page says — Article JSON-LD, dateModified, robots rules,
canonical tags — directly in the repository.
Deploy, re-audit the same URL, and show me the diff between the two runs
(lekta_diff): grade, score, and every check that changed.
Stop when the grade reaches A-, or after 3 fresh audits.

The quota design assumes exactly this shape of work. Fresh audits draw from a daily budget of 10; reading reports, fix plans and diffs costs nothing; a fresh re-run of the same URL is paced at one per minute. Iteration is the cheap part on purpose — the expensive part was always deciding what to fix, and that is what the fix plan hands to the agent for free.

Three guardrails for unattended runs

Three rules keep the loop safe. First, scope the edits: the prompt above authorizes markup, dates, robots rules and canonical tags — changes that alter no sentence a reader sees. Content rewrites deserve a human review, so keep them out of the automated pass. Second, cap the iterations: three fresh audits resolve the typical markup gap, and a loop that has not converged by then is stuck on a finding that needs a person. Third, end with evidence: the final lekta_diff is the receipt — it names the before and after grade, the score delta and each check that flipped, all stamped with the engine version that measured them.

The audits themselves fetch your page as LektaBot, honor robots.txt, and count against one tracked site per day — the loop budget belongs to the site you are actually fixing. The grades it reports follow the same public contract as the web report: 8 letters from A+ to F plus U for unknown, a 100-point score over 4 weighted layers, and a changelog entry with a measured shift table for every scoring change.

Sources

The protocol site documents the standard itself; the Anthropic announcement records its 2024-11-25 launch; the Lekta repository holds the per-platform connection steps. All three links go to canonical, maintained pages.

Continue4 of 4 guides
The audit-fix loop: let your AI assistant grade its own homework — Lekta