@automatelab/ai-seo-mcp 0.3.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -22,10 +22,11 @@ import { diffPages, diffPagesInputSchema } from "./tools/diff-pages.js";
22
22
  import { auditSite, auditSiteInputSchema } from "./tools/audit-site.js";
23
23
  import { auditSitemap, auditSitemapInputSchema } from "./tools/audit-sitemap.js";
24
24
  import { saveAuditReport, saveAuditReportInputSchema } from "./tools/save-audit-report.js";
25
+ import { auditPageOutputShape, auditSchemaOutputShape, auditCanonicalOutputShape, auditSiteOutputShape, auditSitemapOutputShape, checkRobotsOutputShape, checkSitemapOutputShape, checkTechnicalOutputShape, scoreAiOverviewOutputShape, scoreCitationOutputShape, generateLlmsTxtOutputShape, validateLlmsTxtOutputShape, rewriteOutputShape, extractEntitiesOutputShape, testCitationOutputShape, diffPagesOutputShape, saveReportOutputShape, } from "./output-schemas.js";
25
26
  import { ToolFetchError } from "./lib/fetch.js";
26
27
  const server = new McpServer({
27
28
  name: "@automatelab/ai-seo-mcp",
28
- version: "0.3.4",
29
+ version: "0.4.1",
29
30
  });
30
31
  /** Serialize a ToolError to MCP error content. */
31
32
  function toolError(err) {
@@ -34,11 +35,17 @@ function toolError(err) {
34
35
  isError: true,
35
36
  };
36
37
  }
37
- /** Wrap a tool handler to catch errors and return structured ToolError responses. */
38
+ /**
39
+ * Wrap a tool handler:
40
+ * - On success, returns both `content` (JSON text for legacy clients) and
41
+ * `structuredContent` (parsed object validated against the tool's outputSchema).
42
+ * - On failure, returns a typed ToolError as a text-only error response.
43
+ */
38
44
  function wrapHandler(handler) {
39
45
  return handler()
40
46
  .then((result) => ({
41
47
  content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
48
+ structuredContent: result,
42
49
  }))
43
50
  .catch((err) => {
44
51
  if (err instanceof ToolFetchError) {
@@ -49,320 +56,555 @@ function wrapHandler(handler) {
49
56
  return toolError({ type: "fetch_error", url: "", message });
50
57
  });
51
58
  }
52
- // --- Tool 1: audit_page ---
53
- server.tool("audit_page", [
54
- "Full AI-SEO audit of a single URL: returns categorized findings (info/warning/error) with severity, fix instructions, and a 0-100 composite score plus per-dimension subscores.",
55
- "Read-only. Fetches the URL once and runs every sub-audit (schema, robots, technical, sitemap, AI-Overview eligibility) against the response. No writes, no third-party APIs, no auth required, no rate limits beyond polite per-host throttling.",
56
- "Deterministic, rule-based scoring; no LLM calls. Same URL + same input flags returns the same score.",
57
- "Supports `render: \"static\" | \"headless\"`. Default `static` (fast, raw HTML only). Use `headless` for React/Vue/Angular SPAs — adds 3-10s and requires the optional `playwright-core` peer dep plus a one-time `npx playwright install chromium`.",
58
- "When to use: the default entry point for `audit any page`. Use this instead of calling check_technical / audit_schema / check_robots / check_sitemap / score_ai_overview_eligibility individually unless you specifically need only one dimension - this tool composes all of them.",
59
- ].join("\n\n"), auditPageInputSchema.shape, async (input) => wrapHandler(() => auditPage(input)));
60
- // --- Tool 2: audit_schema ---
61
- server.tool("audit_schema", [
62
- "Validate JSON-LD structured data against Schema.org rules and AI-citation best practices. Accepts either a URL (fetched) or a raw JSON string (parsed directly).",
63
- "Read-only when given `url` (one HTTP GET). Zero network when given `schema_json`. No writes.",
64
- "Deterministic, rule-based; no LLM. Validates required/recommended properties, @context correctness, sameAs links, and AI-search-friendly patterns.",
65
- "When to use: focused JSON-LD audits, or to validate a schema block you're about to ship. For a full page audit that includes schema + everything else, use `audit_page` instead.",
66
- "Either `url` or `schema_json` must be provided (not both). If both are provided, `schema_json` wins and no fetch happens.",
67
- ].join("\n\n"), {
68
- url: z
69
- .string()
70
- .url()
71
- .optional()
72
- .describe("Public URL to fetch and audit. Either this OR `schema_json` is required. Read-only HTTP GET."),
73
- schema_json: z
74
- .string()
75
- .optional()
76
- .describe("Raw JSON-LD as a string (the contents of a `<script type=\"application/ld+json\">` block). Use this to validate a schema block offline without fetching a URL. Either this OR `url` is required."),
77
- respect_robots: z
78
- .boolean()
79
- .optional()
80
- .default(true)
81
- .describe("If true (default), respect robots.txt before fetching `url`. Ignored when `schema_json` is used."),
59
+ // ---------------------------------------------------------------------------
60
+ // Tool naming convention: dot-notation forms a navigable tree.
61
+ // audit.* - composite audits that fetch and analyse a page or site
62
+ // check.* - focused single-dimension checks (robots, sitemap, technical)
63
+ // score.* - numeric scoring of citation / AI-Overview eligibility / cite-or-not
64
+ // llms_txt.* - generate / validate llms.txt files
65
+ // rewrite.* - LLM-assisted content rewrites (delegated via MCP sampling)
66
+ // extract.* - entity / structure extraction
67
+ // diff.* - comparisons between pages
68
+ // report.* - report rendering and storage
69
+ // Renamed in v0.4.0 from the previous flat snake_case names.
70
+ // ---------------------------------------------------------------------------
71
+ // --- audit.page ---
72
+ server.registerTool("audit.page", {
73
+ title: "Audit page (full)",
74
+ description: [
75
+ "Full AI-SEO audit of a single URL: returns categorized findings (info/warning/error) with severity, fix instructions, and a 0-100 composite score plus per-dimension subscores.",
76
+ "Read-only. Fetches the URL once and runs every sub-audit (schema, robots, technical, sitemap, AI-Overview eligibility) against the response. No writes, no third-party APIs, no auth required, no rate limits beyond polite per-host throttling.",
77
+ "Deterministic, rule-based scoring; no LLM calls. Same URL + same input flags returns the same score.",
78
+ "Supports `render: \"static\" | \"headless\"`. Default `static` (fast, raw HTML only). Use `headless` for React/Vue/Angular SPAs — adds 3-10s and requires the optional `playwright-core` peer dep plus a one-time `npx playwright install chromium`.",
79
+ "When to use: the default entry point for `audit any page`. Use this instead of calling check.technical / audit.schema / check.robots / check.sitemap / score.ai_overview_eligibility individually unless you specifically need only one dimension - this tool composes all of them.",
80
+ ].join("\n\n"),
81
+ inputSchema: auditPageInputSchema.shape,
82
+ outputSchema: auditPageOutputShape,
83
+ annotations: {
84
+ title: "Audit page (full)",
85
+ readOnlyHint: true,
86
+ destructiveHint: false,
87
+ idempotentHint: true,
88
+ openWorldHint: true,
89
+ },
90
+ }, async (input) => wrapHandler(() => auditPage(input)));
91
+ // --- audit.schema ---
92
+ server.registerTool("audit.schema", {
93
+ title: "Audit JSON-LD schema",
94
+ description: [
95
+ "Validate JSON-LD structured data against Schema.org rules and AI-citation best practices. Accepts either a URL (fetched) or a raw JSON string (parsed directly).",
96
+ "Read-only when given `url` (one HTTP GET). Zero network when given `schema_json`. No writes.",
97
+ "Deterministic, rule-based; no LLM. Validates required/recommended properties, @context correctness, sameAs links, and AI-search-friendly patterns.",
98
+ "When to use: focused JSON-LD audits, or to validate a schema block you're about to ship. For a full page audit that includes schema + everything else, use `audit.page` instead.",
99
+ "Either `url` or `schema_json` must be provided (not both). If both are provided, `schema_json` wins and no fetch happens.",
100
+ ].join("\n\n"),
101
+ inputSchema: {
102
+ url: z
103
+ .string()
104
+ .url()
105
+ .optional()
106
+ .describe("Public URL to fetch and audit. Either this OR `schema_json` is required. Read-only HTTP GET."),
107
+ schema_json: z
108
+ .string()
109
+ .optional()
110
+ .describe("Raw JSON-LD as a string (the contents of a `<script type=\"application/ld+json\">` block). Use this to validate a schema block offline without fetching a URL. Either this OR `url` is required."),
111
+ respect_robots: z
112
+ .boolean()
113
+ .optional()
114
+ .default(true)
115
+ .describe("If true (default), respect robots.txt before fetching `url`. Ignored when `schema_json` is used."),
116
+ },
117
+ outputSchema: auditSchemaOutputShape,
118
+ annotations: {
119
+ title: "Audit JSON-LD schema",
120
+ readOnlyHint: true,
121
+ destructiveHint: false,
122
+ idempotentHint: true,
123
+ openWorldHint: true,
124
+ },
82
125
  }, async (input) => {
83
126
  if (!input.url && !input.schema_json) {
84
127
  return toolError({ type: "invalid_url", message: "One of url or schema_json is required" });
85
128
  }
86
129
  return wrapHandler(() => auditSchema(input));
87
130
  });
88
- // --- Tool 3: audit_canonical ---
89
- server.tool("audit_canonical", [
90
- "Audit a page's canonical link integrity: presence, self-reference, cross-domain mismatches, trailing-slash hygiene, and og:url consistency.",
91
- "Read-only. One HTTP GET to fetch the HEAD section.",
92
- "Deterministic, rule-based; no LLM.",
93
- "When to use: a focused canonical-only audit (e.g. debugging a duplicate-content issue). For a full HEAD audit including OpenGraph, hreflang, noindex, title, use `check_technical`. For everything-on-a-page, use `audit_page`.",
94
- ].join("\n\n"), auditCanonicalInputSchema.shape, async (input) => wrapHandler(() => auditCanonical(input)));
95
- // --- Tool 4: check_robots ---
96
- server.tool("check_robots", [
97
- "Fetch and parse a domain's robots.txt; report per-crawler allow/disallow posture for every known AI training crawler (GPTBot, CCBot, Anthropic-AI, Google-Extended, etc.), AI search crawlers (ChatGPT-User, PerplexityBot, OAI-SearchBot), and user-triggered fetchers.",
98
- "Read-only. One HTTP GET to /robots.txt. No auth, no rate limits applied.",
99
- "Deterministic, rule-based; no LLM. Returns structured findings with per-crawler status.",
100
- "When to use: figuring out which AI crawlers a site blocks vs allows. Combine with `check_sitemap` for a full pre-crawl audit. Distinct from `audit_page` which evaluates a single URL; this evaluates a whole-domain policy.",
101
- ].join("\n\n"), checkRobotsInputSchema.shape, async (input) => wrapHandler(() => checkRobots(input)));
102
- // --- Tool 5: check_sitemap ---
103
- server.tool("check_sitemap", [
104
- "Validate a domain's XML sitemap: presence, accessibility, URL count, lastmod freshness, sitemap-index handling, and image/video sitemap extensions.",
105
- "Read-only. Issues N+1 HTTP GETs: one for robots.txt + sitemap, then up to `max_urls_to_check` HEADs against sampled URLs.",
106
- "Deterministic, rule-based; no LLM.",
107
- "When to use: site-wide indexing audits. Pair with `check_robots` for a full pre-crawl picture. For per-page checks, use `audit_page` or `check_technical` instead.",
108
- ].join("\n\n"), checkSitemapInputSchema.shape, async (input) => wrapHandler(() => checkSitemap(input)));
109
- // --- Tool 6: check_technical ---
110
- server.tool("check_technical", [
111
- "Audit a page's HEAD section for technical signals relevant to AI crawlers: HTTPS, canonical, OpenGraph, Twitter Card, hreflang, noindex, and title-vs-H1 hygiene.",
112
- "Read-only. One HTTP GET, inspects HEAD only (body is not parsed).",
113
- "Deterministic, rule-based; no LLM.",
114
- "When to use: when you specifically need HEAD-tag audit findings. For the full page including schema and AI-Overview scoring, use `audit_page`. For canonical-only, use `audit_canonical`.",
115
- ].join("\n\n"), checkTechnicalInputSchema.shape, async (input) => wrapHandler(() => checkTechnical(input)));
116
- // --- Tool 7: score_ai_overview_eligibility ---
117
- server.tool("score_ai_overview_eligibility", [
118
- "Score a page's probability of appearing in Google AI Overviews. Returns an overall 0-100 score plus six factor subscores: semantic completeness, structured data, E-E-A-T signals, entity density, freshness, and technical hygiene.",
119
- "Read-only. One HTTP GET.",
120
- "Deterministic, rule-based scoring derived from published 2025-2026 AI-Overview correlation studies. No LLM calls. Same URL returns the same score on repeated runs.",
121
- "When to use: AI-Overview-specific prioritization. For a multi-dimensional audit that includes this scoring plus everything else, use `audit_page`. For citation-worthiness of a specific text passage (rather than a URL ranking probability), use `score_citation_worthiness`.",
122
- ].join("\n\n"), scoreAiOverviewEligibilityInputSchema.shape, async (input) => wrapHandler(() => scoreAiOverviewEligibility(input)));
123
- // --- Tool 8: generate_llms_txt ---
124
- server.tool("generate_llms_txt", [
125
- "Generate a spec-compliant llms.txt (and optionally llms-full.txt) for a domain by reading its sitemap, sampling up to `max_pages` pages, and synthesizing a grouped, sectioned summary.",
126
- "Read-only. Issues one HTTP GET for the sitemap then one per sampled page.",
127
- "Deterministic; no LLM. Output is the file content as a string - this tool does NOT write to disk or upload anywhere. The caller is responsible for hosting the resulting file at `https://<domain>/llms.txt`.",
128
- "When to use: bootstrapping llms.txt for a site you own. To check an existing llms.txt, use `validate_llms_txt` instead.",
129
- ].join("\n\n"), generateLlmsTxtInputSchema.shape, async (input) => wrapHandler(() => generateLlmsTxtTool(input)));
130
- // --- Tool 9: validate_llms_txt ---
131
- server.tool("validate_llms_txt", [
132
- "Validate an existing llms.txt or llms-full.txt against the spec: structure, section ordering, link format, and (optionally) broken-link detection.",
133
- "Read-only. One HTTP GET when given `url`; zero network when given `content`. Optional link-check issues HEAD requests against each link if `check_links` is true.",
134
- "Deterministic; no LLM.",
135
- "When to use: auditing an llms.txt you already have. To generate one from scratch, use `generate_llms_txt`.",
136
- "Either `url` or `content` must be provided.",
137
- ].join("\n\n"), {
138
- url: z
139
- .string()
140
- .url()
141
- .optional()
142
- .describe("Public URL of an existing llms.txt or llms-full.txt to validate (e.g. `https://example.com/llms.txt`). Either this OR `content` is required."),
143
- content: z
144
- .string()
145
- .optional()
146
- .describe("Raw llms.txt content as a string. Use this to validate a file offline without fetching. Either this OR `url` is required."),
147
- check_links: z
148
- .boolean()
149
- .optional()
150
- .default(true)
151
- .describe("If true (default), HEAD each linked URL to detect broken links. Set false to skip link checks for faster, network-light validation of just the structural rules."),
131
+ // --- audit.canonical ---
132
+ server.registerTool("audit.canonical", {
133
+ title: "Audit canonical link integrity",
134
+ description: [
135
+ "Audit a page's canonical link integrity: presence, self-reference, cross-domain mismatches, trailing-slash hygiene, and og:url consistency.",
136
+ "Read-only. One HTTP GET to fetch the HEAD section.",
137
+ "Deterministic, rule-based; no LLM.",
138
+ "When to use: a focused canonical-only audit (e.g. debugging a duplicate-content issue). For a full HEAD audit including OpenGraph, hreflang, noindex, title, use `check.technical`. For everything-on-a-page, use `audit.page`.",
139
+ ].join("\n\n"),
140
+ inputSchema: auditCanonicalInputSchema.shape,
141
+ outputSchema: auditCanonicalOutputShape,
142
+ annotations: {
143
+ title: "Audit canonical link integrity",
144
+ readOnlyHint: true,
145
+ destructiveHint: false,
146
+ idempotentHint: true,
147
+ openWorldHint: true,
148
+ },
149
+ }, async (input) => wrapHandler(() => auditCanonical(input)));
150
+ // --- check.robots ---
151
+ server.registerTool("check.robots", {
152
+ title: "Check robots.txt crawler posture",
153
+ description: [
154
+ "Fetch and parse a domain's robots.txt; report per-crawler allow/disallow posture for every known AI training crawler (GPTBot, CCBot, Anthropic-AI, Google-Extended, etc.), AI search crawlers (ChatGPT-User, PerplexityBot, OAI-SearchBot), and user-triggered fetchers.",
155
+ "Read-only. One HTTP GET to /robots.txt. No auth, no rate limits applied.",
156
+ "Deterministic, rule-based; no LLM. Returns structured findings with per-crawler status.",
157
+ "When to use: figuring out which AI crawlers a site blocks vs allows. Combine with `check.sitemap` for a full pre-crawl audit. Distinct from `audit.page` which evaluates a single URL; this evaluates a whole-domain policy.",
158
+ ].join("\n\n"),
159
+ inputSchema: checkRobotsInputSchema.shape,
160
+ outputSchema: checkRobotsOutputShape,
161
+ annotations: {
162
+ title: "Check robots.txt crawler posture",
163
+ readOnlyHint: true,
164
+ destructiveHint: false,
165
+ idempotentHint: true,
166
+ openWorldHint: true,
167
+ },
168
+ }, async (input) => wrapHandler(() => checkRobots(input)));
169
+ // --- check.sitemap ---
170
+ server.registerTool("check.sitemap", {
171
+ title: "Check XML sitemap health",
172
+ description: [
173
+ "Validate a domain's XML sitemap: presence, accessibility, URL count, lastmod freshness, sitemap-index handling, and image/video sitemap extensions.",
174
+ "Read-only. Issues N+1 HTTP GETs: one for robots.txt + sitemap, then up to `max_urls_to_check` HEADs against sampled URLs.",
175
+ "Deterministic, rule-based; no LLM.",
176
+ "When to use: site-wide indexing audits. Pair with `check.robots` for a full pre-crawl picture. For per-page checks, use `audit.page` or `check.technical` instead.",
177
+ ].join("\n\n"),
178
+ inputSchema: checkSitemapInputSchema.shape,
179
+ outputSchema: checkSitemapOutputShape,
180
+ annotations: {
181
+ title: "Check XML sitemap health",
182
+ readOnlyHint: true,
183
+ destructiveHint: false,
184
+ idempotentHint: true,
185
+ openWorldHint: true,
186
+ },
187
+ }, async (input) => wrapHandler(() => checkSitemap(input)));
188
+ // --- check.technical ---
189
+ server.registerTool("check.technical", {
190
+ title: "Check technical HEAD signals",
191
+ description: [
192
+ "Audit a page's HEAD section for technical signals relevant to AI crawlers: HTTPS, canonical, OpenGraph, Twitter Card, hreflang, noindex, and title-vs-H1 hygiene.",
193
+ "Read-only. One HTTP GET, inspects HEAD only (body is not parsed).",
194
+ "Deterministic, rule-based; no LLM.",
195
+ "When to use: when you specifically need HEAD-tag audit findings. For the full page including schema and AI-Overview scoring, use `audit.page`. For canonical-only, use `audit.canonical`.",
196
+ ].join("\n\n"),
197
+ inputSchema: checkTechnicalInputSchema.shape,
198
+ outputSchema: checkTechnicalOutputShape,
199
+ annotations: {
200
+ title: "Check technical HEAD signals",
201
+ readOnlyHint: true,
202
+ destructiveHint: false,
203
+ idempotentHint: true,
204
+ openWorldHint: true,
205
+ },
206
+ }, async (input) => wrapHandler(() => checkTechnical(input)));
207
+ // --- score.ai_overview_eligibility ---
208
+ server.registerTool("score.ai_overview_eligibility", {
209
+ title: "Score AI Overview eligibility",
210
+ description: [
211
+ "Score a page's probability of appearing in Google AI Overviews. Returns an overall 0-100 score plus six factor subscores: semantic completeness, structured data, E-E-A-T signals, entity density, freshness, and technical hygiene.",
212
+ "Read-only. One HTTP GET.",
213
+ "Deterministic, rule-based scoring derived from published 2025-2026 AI-Overview correlation studies. No LLM calls. Same URL returns the same score on repeated runs.",
214
+ "When to use: AI-Overview-specific prioritization. For a multi-dimensional audit that includes this scoring plus everything else, use `audit.page`. For citation-worthiness of a specific text passage (rather than a URL ranking probability), use `score.citation_worthiness`.",
215
+ ].join("\n\n"),
216
+ inputSchema: scoreAiOverviewEligibilityInputSchema.shape,
217
+ outputSchema: scoreAiOverviewOutputShape,
218
+ annotations: {
219
+ title: "Score AI Overview eligibility",
220
+ readOnlyHint: true,
221
+ destructiveHint: false,
222
+ idempotentHint: true,
223
+ openWorldHint: true,
224
+ },
225
+ }, async (input) => wrapHandler(() => scoreAiOverviewEligibility(input)));
226
+ // --- llms_txt.generate ---
227
+ server.registerTool("llms_txt.generate", {
228
+ title: "Generate llms.txt",
229
+ description: [
230
+ "Generate a spec-compliant llms.txt (and optionally llms-full.txt) for a domain by reading its sitemap, sampling up to `max_pages` pages, and synthesizing a grouped, sectioned summary.",
231
+ "Read-only. Issues one HTTP GET for the sitemap then one per sampled page.",
232
+ "Deterministic; no LLM. Output is the file content as a string - this tool does NOT write to disk or upload anywhere. The caller is responsible for hosting the resulting file at `https://<domain>/llms.txt`.",
233
+ "When to use: bootstrapping llms.txt for a site you own. To check an existing llms.txt, use `llms_txt.validate` instead.",
234
+ ].join("\n\n"),
235
+ inputSchema: generateLlmsTxtInputSchema.shape,
236
+ outputSchema: generateLlmsTxtOutputShape,
237
+ annotations: {
238
+ title: "Generate llms.txt",
239
+ readOnlyHint: true,
240
+ destructiveHint: false,
241
+ idempotentHint: true,
242
+ openWorldHint: true,
243
+ },
244
+ }, async (input) => wrapHandler(() => generateLlmsTxtTool(input)));
245
+ // --- llms_txt.validate ---
246
+ server.registerTool("llms_txt.validate", {
247
+ title: "Validate llms.txt",
248
+ description: [
249
+ "Validate an existing llms.txt or llms-full.txt against the spec: structure, section ordering, link format, and (optionally) broken-link detection.",
250
+ "Read-only. One HTTP GET when given `url`; zero network when given `content`. Optional link-check issues HEAD requests against each link if `check_links` is true.",
251
+ "Deterministic; no LLM.",
252
+ "When to use: auditing an llms.txt you already have. To generate one from scratch, use `llms_txt.generate`.",
253
+ "Either `url` or `content` must be provided.",
254
+ ].join("\n\n"),
255
+ inputSchema: {
256
+ url: z
257
+ .string()
258
+ .url()
259
+ .optional()
260
+ .describe("Public URL of an existing llms.txt or llms-full.txt to validate (e.g. `https://example.com/llms.txt`). Either this OR `content` is required."),
261
+ content: z
262
+ .string()
263
+ .optional()
264
+ .describe("Raw llms.txt content as a string. Use this to validate a file offline without fetching. Either this OR `url` is required."),
265
+ check_links: z
266
+ .boolean()
267
+ .optional()
268
+ .default(true)
269
+ .describe("If true (default), HEAD each linked URL to detect broken links. Set false to skip link checks for faster, network-light validation of just the structural rules."),
270
+ },
271
+ outputSchema: validateLlmsTxtOutputShape,
272
+ annotations: {
273
+ title: "Validate llms.txt",
274
+ readOnlyHint: true,
275
+ destructiveHint: false,
276
+ idempotentHint: true,
277
+ openWorldHint: true,
278
+ },
152
279
  }, async (input) => {
153
280
  if (!input.url && !input.content) {
154
281
  return toolError({ type: "invalid_url", message: "One of url or content is required" });
155
282
  }
156
283
  return wrapHandler(() => validateLlmsTxt(input));
157
284
  });
158
- // --- Tool 10: score_citation_worthiness ---
159
- server.tool("score_citation_worthiness", [
160
- "Score how citable a page or text block is for AI engines (ChatGPT, Claude, Perplexity, Google AI Overviews). Evaluates BLUF (bottom-line-up-front) opening, FAQ patterns, statistic density, entity clarity, and answer-shape fit for the optional `target_query`.",
161
- "Read-only when given `url` (one HTTP GET). Zero network when given `text`. No writes.",
162
- "Deterministic, rule-based; no LLM calls. Returns reproducible scores.",
163
- "When to use: pre-publish content QA, or to triage which existing pages are worth optimizing for AI citation first. Distinct from `score_ai_overview_eligibility` which scores Google-AI-Overview ranking probability for a URL; this scores the inherent citability of a text passage regardless of host.",
164
- "Either `url` or `text` must be provided.",
165
- ].join("\n\n"), {
166
- url: z
167
- .string()
168
- .url()
169
- .optional()
170
- .describe("Public URL to fetch and score. Either this OR `text` is required."),
171
- text: z
172
- .string()
173
- .optional()
174
- .describe("Raw text/markdown/HTML to score directly without fetching. Either this OR `url` is required."),
175
- target_query: z
176
- .string()
177
- .optional()
178
- .describe("Optional target search query the content is supposed to answer (e.g. `how to fix CORS errors in Next.js`). When provided, scoring weights answer-shape fit and query-term coverage. Omit if you want a query-agnostic citability score."),
179
- respect_robots: z
180
- .boolean()
181
- .optional()
182
- .default(true)
183
- .describe("If true (default), respect robots.txt when fetching `url`. Ignored when `text` is used."),
285
+ // --- score.citation_worthiness ---
286
+ server.registerTool("score.citation_worthiness", {
287
+ title: "Score AI citation worthiness",
288
+ description: [
289
+ "Score how citable a page or text block is for AI engines (ChatGPT, Claude, Perplexity, Google AI Overviews). Evaluates BLUF (bottom-line-up-front) opening, FAQ patterns, statistic density, entity clarity, and answer-shape fit for the optional `target_query`.",
290
+ "Read-only when given `url` (one HTTP GET). Zero network when given `text`. No writes.",
291
+ "Deterministic, rule-based; no LLM calls. Returns reproducible scores.",
292
+ "When to use: pre-publish content QA, or to triage which existing pages are worth optimizing for AI citation first. Distinct from `score.ai_overview_eligibility` which scores Google-AI-Overview ranking probability for a URL; this scores the inherent citability of a text passage regardless of host.",
293
+ "Either `url` or `text` must be provided.",
294
+ ].join("\n\n"),
295
+ inputSchema: {
296
+ url: z
297
+ .string()
298
+ .url()
299
+ .optional()
300
+ .describe("Public URL to fetch and score. Either this OR `text` is required."),
301
+ text: z
302
+ .string()
303
+ .optional()
304
+ .describe("Raw text/markdown/HTML to score directly without fetching. Either this OR `url` is required."),
305
+ target_query: z
306
+ .string()
307
+ .optional()
308
+ .describe("Optional target search query the content is supposed to answer (e.g. `how to fix CORS errors in Next.js`). When provided, scoring weights answer-shape fit and query-term coverage. Omit if you want a query-agnostic citability score."),
309
+ respect_robots: z
310
+ .boolean()
311
+ .optional()
312
+ .default(true)
313
+ .describe("If true (default), respect robots.txt when fetching `url`. Ignored when `text` is used."),
314
+ },
315
+ outputSchema: scoreCitationOutputShape,
316
+ annotations: {
317
+ title: "Score AI citation worthiness",
318
+ readOnlyHint: true,
319
+ destructiveHint: false,
320
+ idempotentHint: true,
321
+ openWorldHint: true,
322
+ },
184
323
  }, async (input) => {
185
324
  if (!input.url && !input.text) {
186
325
  return toolError({ type: "invalid_url", message: "One of url or text is required" });
187
326
  }
188
327
  return wrapHandler(() => scoreCitationWorthiness(input));
189
328
  });
190
- // --- Tool 11: rewrite_for_aeo ---
191
- server.tool("rewrite_for_aeo", [
192
- "Rewrite a content block for Answer Engine Optimization. Adds a BLUF opening, FAQ structure, schema additions, and concise question-shaped headings tuned for ChatGPT / Perplexity / Google AI Overviews.",
193
- "Read-only when given `url` (one HTTP GET). Zero network when given `text`. The tool does NOT write back to the URL - it only returns the rewritten content as a string. No side effects on the source.",
194
- "This tool delegates the actual rewrite to the calling LLM via MCP sampling - it does not call any external API itself. The MCP host's model produces the rewrite. Same input may produce different output across runs (model-dependent).",
195
- "When to use: optimizing content for direct-answer surfaces (definitions, how-tos, FAQs). For Generative Engine Optimization (entity-rich, comparison-ready synthesis), use `rewrite_for_geo` instead.",
196
- "Either `url` or `text` must be provided. `target_query` is required.",
197
- ].join("\n\n"), {
198
- url: z
199
- .string()
200
- .url()
201
- .optional()
202
- .describe("Public URL whose content should be fetched and rewritten. Either this OR `text` is required."),
203
- text: z
204
- .string()
205
- .optional()
206
- .describe("Raw content (markdown or HTML) to rewrite directly. Either this OR `url` is required."),
207
- target_query: z
208
- .string()
209
- .describe("The user query the rewrite should answer (e.g. `what is RAG`, `how to deploy Ghost to Docker`). Required - drives heading shape and BLUF wording."),
210
- format: z
211
- .enum(["article", "faq", "howto", "comparison"])
212
- .default("article")
213
- .describe("Output shape. `article` for prose-with-headings. `faq` for Q&A list. `howto` for numbered-step procedural content with HowTo schema hints. `comparison` for X-vs-Y tables. Default `article`."),
214
- max_words: z
215
- .number()
216
- .int()
217
- .min(100)
218
- .max(5000)
219
- .optional()
220
- .default(1500)
221
- .describe("Soft word budget for the rewrite. Default 1500. Range 100-5000. The rewrite tries to stay under this; very small budgets may force truncation."),
222
- respect_robots: z
223
- .boolean()
224
- .optional()
225
- .default(true)
226
- .describe("If true (default), respect robots.txt when fetching `url`. Ignored when `text` is used."),
329
+ // --- rewrite.aeo ---
330
+ server.registerTool("rewrite.aeo", {
331
+ title: "Rewrite for Answer Engine Optimization",
332
+ description: [
333
+ "Rewrite a content block for Answer Engine Optimization. Adds a BLUF opening, FAQ structure, schema additions, and concise question-shaped headings tuned for ChatGPT / Perplexity / Google AI Overviews.",
334
+ "Read-only when given `url` (one HTTP GET). Zero network when given `text`. The tool does NOT write back to the URL - it only returns the rewritten content as a string. No side effects on the source.",
335
+ "This tool delegates the actual rewrite to the calling LLM via MCP sampling - it does not call any external API itself. The MCP host's model produces the rewrite. Same input may produce different output across runs (model-dependent).",
336
+ "When to use: optimizing content for direct-answer surfaces (definitions, how-tos, FAQs). For Generative Engine Optimization (entity-rich, comparison-ready synthesis), use `rewrite.geo` instead.",
337
+ "Either `url` or `text` must be provided. `target_query` is required.",
338
+ ].join("\n\n"),
339
+ inputSchema: {
340
+ url: z
341
+ .string()
342
+ .url()
343
+ .optional()
344
+ .describe("Public URL whose content should be fetched and rewritten. Either this OR `text` is required."),
345
+ text: z
346
+ .string()
347
+ .optional()
348
+ .describe("Raw content (markdown or HTML) to rewrite directly. Either this OR `url` is required."),
349
+ target_query: z
350
+ .string()
351
+ .describe("The user query the rewrite should answer (e.g. `what is RAG`, `how to deploy Ghost to Docker`). Required - drives heading shape and BLUF wording."),
352
+ format: z
353
+ .enum(["article", "faq", "howto", "comparison"])
354
+ .default("article")
355
+ .describe("Output shape. `article` for prose-with-headings. `faq` for Q&A list. `howto` for numbered-step procedural content with HowTo schema hints. `comparison` for X-vs-Y tables. Default `article`."),
356
+ max_words: z
357
+ .number()
358
+ .int()
359
+ .min(100)
360
+ .max(5000)
361
+ .optional()
362
+ .default(1500)
363
+ .describe("Soft word budget for the rewrite. Default 1500. Range 100-5000. The rewrite tries to stay under this; very small budgets may force truncation."),
364
+ respect_robots: z
365
+ .boolean()
366
+ .optional()
367
+ .default(true)
368
+ .describe("If true (default), respect robots.txt when fetching `url`. Ignored when `text` is used."),
369
+ },
370
+ outputSchema: rewriteOutputShape,
371
+ annotations: {
372
+ title: "Rewrite for Answer Engine Optimization",
373
+ readOnlyHint: true,
374
+ destructiveHint: false,
375
+ // LLM sampling makes output non-deterministic - same input may produce different output.
376
+ idempotentHint: false,
377
+ openWorldHint: true,
378
+ },
227
379
  }, async (input) => {
228
380
  if (!input.url && !input.text) {
229
381
  return toolError({ type: "invalid_url", message: "One of url or text is required" });
230
382
  }
231
383
  return wrapHandler(() => rewriteForAeo(input, undefined, undefined, server));
232
384
  });
233
- // --- Tool 12: rewrite_for_geo ---
234
- server.tool("rewrite_for_geo", [
235
- "Rewrite a content block for Generative Engine Optimization: entity-rich, comparison-ready, synthesis-friendly. Tuned for surfaces that summarize across sources (Perplexity, Google AI Mode, Claude search).",
236
- "Read-only on input. Does NOT write back to the source URL - returns the rewritten content as a string.",
237
- "This tool delegates the actual rewrite to the calling LLM via MCP sampling - it does not call any external API itself. The MCP host's model produces the rewrite. Output may vary across runs (model-dependent).",
238
- "When to use: optimizing for synthesis-style answers across multiple sources. For direct-answer (BLUF + FAQ) optimization on a single page, use `rewrite_for_aeo` instead.",
239
- "Either `url` or `text` must be provided. `target_query` is required.",
240
- ].join("\n\n"), {
241
- url: z
242
- .string()
243
- .url()
244
- .optional()
245
- .describe("Public URL whose content should be fetched and rewritten. Either this OR `text` is required."),
246
- text: z
247
- .string()
248
- .optional()
249
- .describe("Raw content to rewrite directly. Either this OR `url` is required."),
250
- target_query: z
251
- .string()
252
- .describe("The user query the rewrite should answer. Required - drives entity selection and comparison framing."),
253
- add_comparison_table: z
254
- .boolean()
255
- .optional()
256
- .default(false)
257
- .describe("If true, inject an explicit X-vs-Y comparison table into the rewrite (useful for `X vs Y` queries). Default false."),
258
- max_words: z
259
- .number()
260
- .int()
261
- .min(100)
262
- .max(5000)
263
- .optional()
264
- .default(1500)
265
- .describe("Soft word budget. Default 1500. Range 100-5000."),
266
- respect_robots: z
267
- .boolean()
268
- .optional()
269
- .default(true)
270
- .describe("If true (default), respect robots.txt when fetching `url`. Ignored when `text` is used."),
385
+ // --- rewrite.geo ---
386
+ server.registerTool("rewrite.geo", {
387
+ title: "Rewrite for Generative Engine Optimization",
388
+ description: [
389
+ "Rewrite a content block for Generative Engine Optimization: entity-rich, comparison-ready, synthesis-friendly. Tuned for surfaces that summarize across sources (Perplexity, Google AI Mode, Claude search).",
390
+ "Read-only on input. Does NOT write back to the source URL - returns the rewritten content as a string.",
391
+ "This tool delegates the actual rewrite to the calling LLM via MCP sampling - it does not call any external API itself. The MCP host's model produces the rewrite. Output may vary across runs (model-dependent).",
392
+ "When to use: optimizing for synthesis-style answers across multiple sources. For direct-answer (BLUF + FAQ) optimization on a single page, use `rewrite.aeo` instead.",
393
+ "Either `url` or `text` must be provided. `target_query` is required.",
394
+ ].join("\n\n"),
395
+ inputSchema: {
396
+ url: z
397
+ .string()
398
+ .url()
399
+ .optional()
400
+ .describe("Public URL whose content should be fetched and rewritten. Either this OR `text` is required."),
401
+ text: z
402
+ .string()
403
+ .optional()
404
+ .describe("Raw content to rewrite directly. Either this OR `url` is required."),
405
+ target_query: z
406
+ .string()
407
+ .describe("The user query the rewrite should answer. Required - drives entity selection and comparison framing."),
408
+ add_comparison_table: z
409
+ .boolean()
410
+ .optional()
411
+ .default(false)
412
+ .describe("If true, inject an explicit X-vs-Y comparison table into the rewrite (useful for `X vs Y` queries). Default false."),
413
+ max_words: z
414
+ .number()
415
+ .int()
416
+ .min(100)
417
+ .max(5000)
418
+ .optional()
419
+ .default(1500)
420
+ .describe("Soft word budget. Default 1500. Range 100-5000."),
421
+ respect_robots: z
422
+ .boolean()
423
+ .optional()
424
+ .default(true)
425
+ .describe("If true (default), respect robots.txt when fetching `url`. Ignored when `text` is used."),
426
+ },
427
+ outputSchema: rewriteOutputShape,
428
+ annotations: {
429
+ title: "Rewrite for Generative Engine Optimization",
430
+ readOnlyHint: true,
431
+ destructiveHint: false,
432
+ idempotentHint: false,
433
+ openWorldHint: true,
434
+ },
271
435
  }, async (input) => {
272
436
  if (!input.url && !input.text) {
273
437
  return toolError({ type: "invalid_url", message: "One of url or text is required" });
274
438
  }
275
439
  return wrapHandler(() => rewriteForGeo(input, undefined, undefined, server));
276
440
  });
277
- // --- Tool 13: extract_entities ---
278
- server.tool("extract_entities", [
279
- "Extract named entities, linked concepts, and sameAs graph nodes from a page's content and structured data. Combines body-text NER with JSON-LD `@type` / `sameAs` walking.",
280
- "Read-only when given `url` (one HTTP GET). Zero network when given `text`.",
281
- "Primary path: MCP sampling - the host LLM does the NER and returns typed entities with sameAs URIs. Fallback path: deterministic regex-based extractor when sampling is unavailable. The result includes `mode: \"sampling\" | \"regex_fallback\"` so callers can tell which path ran.",
282
- "When to use: building an entity map for schema generation, or auditing whether a page's entities match its target topic. To validate the JSON-LD itself, use `audit_schema`.",
283
- "Either `url` or `text` must be provided.",
284
- ].join("\n\n"), {
285
- url: z
286
- .string()
287
- .url()
288
- .optional()
289
- .describe("Public URL to fetch and analyze. Either this OR `text` is required."),
290
- text: z
291
- .string()
292
- .optional()
293
- .describe("Raw text/HTML to analyze directly. Either this OR `url` is required."),
294
- respect_robots: z
295
- .boolean()
296
- .optional()
297
- .default(true)
298
- .describe("If true (default), respect robots.txt when fetching `url`. Ignored when `text` is used."),
299
- render: z
300
- .enum(["static", "headless"])
301
- .optional()
302
- .default("static")
303
- .describe("Rendering mode for `url`. `static` (default) reads raw HTML. `headless` runs Playwright Chromium to capture JS-rendered content (adds 3-10s; requires `playwright-core` + `npx playwright install chromium`). Ignored when `text` is used."),
441
+ // --- extract.entities ---
442
+ server.registerTool("extract.entities", {
443
+ title: "Extract named entities and sameAs links",
444
+ description: [
445
+ "Extract named entities, linked concepts, and sameAs graph nodes from a page's content and structured data. Combines body-text NER with JSON-LD `@type` / `sameAs` walking.",
446
+ "Read-only when given `url` (one HTTP GET). Zero network when given `text`.",
447
+ "Primary path: MCP sampling - the host LLM does the NER and returns typed entities with sameAs URIs. Fallback path: deterministic regex-based extractor when sampling is unavailable. The result includes `mode: \"sampling\" | \"regex_fallback\"` so callers can tell which path ran.",
448
+ "When to use: building an entity map for schema generation, or auditing whether a page's entities match its target topic. To validate the JSON-LD itself, use `audit.schema`.",
449
+ "Either `url` or `text` must be provided.",
450
+ ].join("\n\n"),
451
+ inputSchema: {
452
+ url: z
453
+ .string()
454
+ .url()
455
+ .optional()
456
+ .describe("Public URL to fetch and analyze. Either this OR `text` is required."),
457
+ text: z
458
+ .string()
459
+ .optional()
460
+ .describe("Raw text/HTML to analyze directly. Either this OR `url` is required."),
461
+ respect_robots: z
462
+ .boolean()
463
+ .optional()
464
+ .default(true)
465
+ .describe("If true (default), respect robots.txt when fetching `url`. Ignored when `text` is used."),
466
+ render: z
467
+ .enum(["static", "headless"])
468
+ .optional()
469
+ .default("static")
470
+ .describe("Rendering mode for `url`. `static` (default) reads raw HTML. `headless` runs Playwright Chromium to capture JS-rendered content (adds 3-10s; requires `playwright-core` + `npx playwright install chromium`). Ignored when `text` is used."),
471
+ },
472
+ outputSchema: extractEntitiesOutputShape,
473
+ annotations: {
474
+ title: "Extract named entities and sameAs links",
475
+ readOnlyHint: true,
476
+ destructiveHint: false,
477
+ // Sampling path is model-dependent; regex fallback is deterministic. Mark as non-idempotent to be safe.
478
+ idempotentHint: false,
479
+ openWorldHint: true,
480
+ },
304
481
  }, async (input) => {
305
482
  if (!input.url && !input.text) {
306
483
  return toolError({ type: "invalid_url", message: "One of url or text is required" });
307
484
  }
308
485
  return wrapHandler(() => extractEntities(input, undefined, undefined, server));
309
486
  });
310
- // --- Tool 14: test_citation ---
311
- server.tool("test_citation", [
312
- "Simulate `would an AI engine cite this page for this query?`. The host LLM role-plays the chosen engine (chatgpt / claude / perplexity / google_ai_overviews / any), reads the page content, and returns a cite/no-cite verdict with the verbatim excerpt it would surface plus ranked improvements.",
313
- "Read-only when given `url` (one HTTP GET). Zero network when given `text`.",
314
- "Primary path uses MCP sampling. If the host doesn't support sampling, falls back to a deterministic heuristic derived from `score_citation_worthiness` (overall_score + per-engine subscore must both clear thresholds). The result includes `mode: \"sampling\" | \"static_heuristic\"` so callers can tell which path ran.",
315
- "When to use: pre-publish gut-check for a specific query, or auditing whether existing content earns citation surface. Distinct from `score_citation_worthiness` (deterministic 0-100 score) and `audit_page` (whole-page rubric); this returns a binary cite/no-cite verdict tied to one query.",
316
- "Either `url` or `text` must be provided. `target_query` is required.",
317
- ].join("\n\n"), {
318
- url: z
319
- .string()
320
- .url()
321
- .optional()
322
- .describe("Public URL to fetch and test. Either this OR `text` is required."),
323
- text: z
324
- .string()
325
- .optional()
326
- .describe("Raw text/HTML to test directly. Either this OR `url` is required."),
327
- target_query: z
328
- .string()
329
- .min(3)
330
- .describe("The user query the engine is answering. Required. Example: `how to add JSON-LD to a Next.js app`."),
331
- engine: z
332
- .enum(["chatgpt", "claude", "perplexity", "google_ai_overviews", "any"])
333
- .optional()
334
- .default("any")
335
- .describe("Which engine to simulate. `any` (default) uses a generic AI-search persona. Specific engines tune the cite criteria (e.g. perplexity favors statistic-dense excerpts; google_ai_overviews favors schema + freshness)."),
336
- respect_robots: z
337
- .boolean()
338
- .optional()
339
- .default(true)
340
- .describe("If true (default), respect robots.txt when fetching `url`. Ignored when `text` is used."),
487
+ // --- score.test_citation ---
488
+ server.registerTool("score.test_citation", {
489
+ title: "Test whether an AI engine would cite this page",
490
+ description: [
491
+ "Simulate `would an AI engine cite this page for this query?`. The host LLM role-plays the chosen engine (chatgpt / claude / perplexity / google_ai_overviews / any), reads the page content, and returns a cite/no-cite verdict with the verbatim excerpt it would surface plus ranked improvements.",
492
+ "Read-only when given `url` (one HTTP GET). Zero network when given `text`.",
493
+ "Primary path uses MCP sampling. If the host doesn't support sampling, falls back to a deterministic heuristic derived from `score.citation_worthiness` (overall_score + per-engine subscore must both clear thresholds). The result includes `mode: \"sampling\" | \"static_heuristic\"` so callers can tell which path ran.",
494
+ "When to use: pre-publish gut-check for a specific query, or auditing whether existing content earns citation surface. Distinct from `score.citation_worthiness` (deterministic 0-100 score) and `audit.page` (whole-page rubric); this returns a binary cite/no-cite verdict tied to one query.",
495
+ "Either `url` or `text` must be provided. `target_query` is required.",
496
+ ].join("\n\n"),
497
+ inputSchema: {
498
+ url: z
499
+ .string()
500
+ .url()
501
+ .optional()
502
+ .describe("Public URL to fetch and test. Either this OR `text` is required."),
503
+ text: z
504
+ .string()
505
+ .optional()
506
+ .describe("Raw text/HTML to test directly. Either this OR `url` is required."),
507
+ target_query: z
508
+ .string()
509
+ .min(3)
510
+ .describe("The user query the engine is answering. Required. Example: `how to add JSON-LD to a Next.js app`."),
511
+ engine: z
512
+ .enum(["chatgpt", "claude", "perplexity", "google_ai_overviews", "any"])
513
+ .optional()
514
+ .default("any")
515
+ .describe("Which engine to simulate. `any` (default) uses a generic AI-search persona. Specific engines tune the cite criteria (e.g. perplexity favors statistic-dense excerpts; google_ai_overviews favors schema + freshness)."),
516
+ respect_robots: z
517
+ .boolean()
518
+ .optional()
519
+ .default(true)
520
+ .describe("If true (default), respect robots.txt when fetching `url`. Ignored when `text` is used."),
521
+ },
522
+ outputSchema: testCitationOutputShape,
523
+ annotations: {
524
+ title: "Test whether an AI engine would cite this page",
525
+ readOnlyHint: true,
526
+ destructiveHint: false,
527
+ // Sampling path is model-dependent.
528
+ idempotentHint: false,
529
+ openWorldHint: true,
530
+ },
341
531
  }, async (input) => {
342
532
  if (!input.url && !input.text) {
343
533
  return toolError({ type: "invalid_url", message: "One of url or text is required" });
344
534
  }
345
535
  return wrapHandler(() => testCitation(input, undefined, undefined, server));
346
536
  });
347
- // --- Tool 15: diff_pages ---
348
- server.tool("diff_pages", [
349
- "Compare two URLs for AI citation-worthiness and return a structured breakdown of which page is more likely to be cited and why. Typical use: your page (url_a) vs a competitor's page (url_b).",
350
- "Read-only. Runs audit_page on both URLs in parallel (2 HTTP fetches per URL), then diffs dimension_scores and findings. No new fetch logic beyond what audit_page already does.",
351
- "Deterministic, rule-based; no LLM calls. Same two URLs return the same comparison on repeated runs.",
352
- "When to use: competitive gap analysis - understand exactly which dimensions (schema, structure, robots, entity density, freshness, technical, authority, sitemap) put a competitor ahead, and get prioritized fix_recommendations_for_a to close the gap. For a single-URL audit, use audit_page. For overall scoring of one page, use score_citation_worthiness.",
353
- "Capped at 2 URLs per call. Heuristic verdict - does not claim to know what AI assistants actually cite; verdict matches audit_page's existing rubric.",
354
- ].join("\n\n"), diffPagesInputSchema.shape, async (input) => wrapHandler(() => diffPages(input)));
355
- // --- Tool 16: audit_site ---
356
- server.tool("audit_site", "Single-call site sweep: runs audit_page (homepage), check_robots, check_sitemap, and audit_schema in parallel and returns an overall grade plus top-5 fixes.", auditSiteInputSchema.shape, async (input) => wrapHandler(() => auditSite(input)));
357
- // --- Tool 17: audit_sitemap ---
358
- server.tool("audit_sitemap", [
359
- "Site-wide content audit: discovers the sitemap, samples N URLs by deterministic uniform stride, runs audit_page on each, and returns score distribution + worst pages + most-common findings.",
360
- "Read-only. One HTTP GET for sitemap discovery, optionally a few more for sitemap-index children, then `sample_size` × audit_page calls (each one HTTP GET + parsing). Polite throttling is enforced per host.",
361
- "Deterministic — same domain + same sample_size returns the same set of URLs (uniform-stride sampling). Per-page scoring is rule-based; no LLM.",
362
- "When to use: portfolio-level health check across a site (\"how does our content score on average?\"). Distinct from `audit_site` (homepage-only composite) and `check_sitemap` (validates sitemap.xml structure, not page content).",
363
- ].join("\n\n"), auditSitemapInputSchema.shape, async (input) => wrapHandler(() => auditSitemap(input)));
364
- // --- Tool 18: save_audit_report ---
365
- server.tool("save_audit_report", "Render an audit_page or audit_site result as a Markdown report and write it to a file under MCP_WORKSPACE_ROOT (defaults to cwd).", saveAuditReportInputSchema.shape, async (input) => wrapHandler(() => saveAuditReport(input)));
537
+ // --- diff.pages ---
538
+ server.registerTool("diff.pages", {
539
+ title: "Diff two pages for citation-worthiness",
540
+ description: [
541
+ "Compare two URLs for AI citation-worthiness and return a structured breakdown of which page is more likely to be cited and why. Typical use: your page (url_a) vs a competitor's page (url_b).",
542
+ "Read-only. Runs audit.page on both URLs in parallel (2 HTTP fetches per URL), then diffs dimension_scores and findings. No new fetch logic beyond what audit.page already does.",
543
+ "Deterministic, rule-based; no LLM calls. Same two URLs return the same comparison on repeated runs.",
544
+ "When to use: competitive gap analysis - understand exactly which dimensions (schema, structure, robots, entity density, freshness, technical, authority, sitemap) put a competitor ahead, and get prioritized fix_recommendations_for_a to close the gap. For a single-URL audit, use audit.page. For overall scoring of one page, use score.citation_worthiness.",
545
+ "Capped at 2 URLs per call. Heuristic verdict - does not claim to know what AI assistants actually cite; verdict matches audit.page's existing rubric.",
546
+ ].join("\n\n"),
547
+ inputSchema: diffPagesInputSchema.shape,
548
+ outputSchema: diffPagesOutputShape,
549
+ annotations: {
550
+ title: "Diff two pages for citation-worthiness",
551
+ readOnlyHint: true,
552
+ destructiveHint: false,
553
+ idempotentHint: true,
554
+ openWorldHint: true,
555
+ },
556
+ }, async (input) => wrapHandler(() => diffPages(input)));
557
+ // --- audit.site ---
558
+ server.registerTool("audit.site", {
559
+ title: "Audit site (homepage + robots + sitemap + schema)",
560
+ description: "Single-call site sweep: runs audit.page (homepage), check.robots, check.sitemap, and audit.schema in parallel and returns an overall grade plus top-5 fixes.",
561
+ inputSchema: auditSiteInputSchema.shape,
562
+ outputSchema: auditSiteOutputShape,
563
+ annotations: {
564
+ title: "Audit site (homepage + robots + sitemap + schema)",
565
+ readOnlyHint: true,
566
+ destructiveHint: false,
567
+ idempotentHint: true,
568
+ openWorldHint: true,
569
+ },
570
+ }, async (input) => wrapHandler(() => auditSite(input)));
571
+ // --- audit.sitemap ---
572
+ server.registerTool("audit.sitemap", {
573
+ title: "Audit a site's content by sampling its sitemap",
574
+ description: [
575
+ "Site-wide content audit: discovers the sitemap, samples N URLs by deterministic uniform stride, runs audit.page on each, and returns score distribution + worst pages + most-common findings.",
576
+ "Read-only. One HTTP GET for sitemap discovery, optionally a few more for sitemap-index children, then `sample_size` × audit.page calls (each one HTTP GET + parsing). Polite throttling is enforced per host.",
577
+ "Deterministic — same domain + same sample_size returns the same set of URLs (uniform-stride sampling). Per-page scoring is rule-based; no LLM.",
578
+ "When to use: portfolio-level health check across a site (\"how does our content score on average?\"). Distinct from `audit.site` (homepage-only composite) and `check.sitemap` (validates sitemap.xml structure, not page content).",
579
+ ].join("\n\n"),
580
+ inputSchema: auditSitemapInputSchema.shape,
581
+ outputSchema: auditSitemapOutputShape,
582
+ annotations: {
583
+ title: "Audit a site's content by sampling its sitemap",
584
+ readOnlyHint: true,
585
+ destructiveHint: false,
586
+ idempotentHint: true,
587
+ openWorldHint: true,
588
+ },
589
+ }, async (input) => wrapHandler(() => auditSitemap(input)));
590
+ // --- report.save ---
591
+ server.registerTool("report.save", {
592
+ title: "Save audit report to disk",
593
+ description: "Render an audit.page or audit.site result as a Markdown report and write it to a file under MCP_WORKSPACE_ROOT (defaults to cwd).",
594
+ inputSchema: saveAuditReportInputSchema.shape,
595
+ outputSchema: saveReportOutputShape,
596
+ annotations: {
597
+ title: "Save audit report to disk",
598
+ // Writes a file - not read-only.
599
+ readOnlyHint: false,
600
+ // Overwrite=true (default) replaces existing files; the change is recoverable but writes do occur.
601
+ destructiveHint: true,
602
+ // Same input writes the same content to the same path.
603
+ idempotentHint: true,
604
+ // Operates on the local filesystem only.
605
+ openWorldHint: false,
606
+ },
607
+ }, async (input) => wrapHandler(() => saveAuditReport(input)));
366
608
  // --- Prompts: one-click entry points for AI-SEO workflows ---
367
609
  // Surfaced by hosts like Claude Desktop as suggested actions. Lowers activation cost
368
610
  // vs. asking users to pick among the 16-tool catalog.
@@ -372,9 +614,9 @@ server.prompt("audit_my_homepage", "Run a full AI-SEO audit of a site's homepage
372
614
  role: "user",
373
615
  content: {
374
616
  type: "text",
375
- text: `Call the \`audit_site\` tool with domain="${domain}" and respect_robots=true. ` +
617
+ text: `Call the \`audit.site\` tool with domain="${domain}" and respect_robots=true. ` +
376
618
  `When the result returns, summarize the overall_grade, the top_5_fixes (highest-impact first), ` +
377
- `and the content_quality from the underlying audit_page. Recommend the single most leveraged fix first.`,
619
+ `and the content_quality from the underlying audit.page. Recommend the single most leveraged fix first.`,
378
620
  },
379
621
  },
380
622
  ],
@@ -385,7 +627,7 @@ server.prompt("find_citation_blockers", "Audit a URL and surface only the critic
385
627
  role: "user",
386
628
  content: {
387
629
  type: "text",
388
- text: `Call \`audit_page\` with url="${url}" and respect_robots=true. ` +
630
+ text: `Call \`audit.page\` with url="${url}" and respect_robots=true. ` +
389
631
  `From the result, filter findings to severity="critical" only. ` +
390
632
  `Group them by category and present a prioritized fix list. ` +
391
633
  `Ignore warnings and info-level findings for this pass.`,
@@ -399,7 +641,7 @@ server.prompt("generate_llms_txt_for_domain", "Generate a valid llms.txt for a d
399
641
  role: "user",
400
642
  content: {
401
643
  type: "text",
402
- text: `Call \`generate_llms_txt\` with domain="${domain}", max_pages=50, include_full=false. ` +
644
+ text: `Call \`llms_txt.generate\` with domain="${domain}", max_pages=50, include_full=false. ` +
403
645
  `Return the generated llms.txt verbatim in a code block, then summarize how many pages were indexed.`,
404
646
  },
405
647
  },
@@ -411,7 +653,7 @@ server.prompt("check_ai_crawler_access", "Report which AI training and search cr
411
653
  role: "user",
412
654
  content: {
413
655
  type: "text",
414
- text: `Call \`check_robots\` with domain="${domain}". ` +
656
+ text: `Call \`check.robots\` with domain="${domain}". ` +
415
657
  `From the result, build a table grouped by training_crawlers / search_crawlers / user_triggered, ` +
416
658
  `with one row per crawler and an allowed/blocked verdict. ` +
417
659
  `Highlight any AI search crawlers that are blocked - those silently kill citation surface.`,
@@ -428,7 +670,7 @@ server.prompt("score_my_citation_worthiness", "Score how citable a URL is for AI
428
670
  role: "user",
429
671
  content: {
430
672
  type: "text",
431
- text: `Call \`score_citation_worthiness\` with url="${url}", target_query="${target_query}", respect_robots=true. ` +
673
+ text: `Call \`score.citation_worthiness\` with url="${url}", target_query="${target_query}", respect_robots=true. ` +
432
674
  `Present overall_score and per-engine scores (Perplexity, ChatGPT, Google AI Overviews, Claude). ` +
433
675
  `Then suggest the 3 most impactful structural changes (BLUF opening, FAQ blocks, entity density) to lift the lowest score.`,
434
676
  },
@@ -484,7 +726,7 @@ robots.txt allows OAI-SearchBot, PerplexityBot, Claude-SearchBot. Blocking train
484
726
  ## 13. Sitemap freshness
485
727
  XML sitemap present, lastmod >80% coverage, listed in robots.txt.
486
728
 
487
- Use \`audit_page\` to score a URL across all 13 signals at once.
729
+ Use \`audit.page\` to score a URL across all 13 signals at once.
488
730
  `;
489
731
  const CRAWLERS_DOC = `# AI crawlers reference
490
732
 
@@ -538,7 +780,7 @@ Allow: /
538
780
  \`\`\`
539
781
  (Blocks training, allows everything else - including search crawlers.)
540
782
 
541
- Use \`check_robots\` to see your current posture per crawler.
783
+ Use \`check.robots\` to see your current posture per crawler.
542
784
  `;
543
785
  server.resource("ai-citation-signals", "ai-citation://signals", { mimeType: "text/markdown", description: "The 13 signals AI assistants use to decide what to cite, with examples." }, async (uri) => ({
544
786
  contents: [{ uri: uri.href, mimeType: "text/markdown", text: SIGNALS_DOC }],