url_inspection_inspect
Inspect a URL in Google's index to check indexing status, crawl info, rich results, AMP status, and mobile usability. Identify issues affecting search visibility.
Instructions
Inspect a URL in Google's index. Returns indexing status, crawl info, rich results, AMP status, and mobile usability for a specific URL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inspectionUrl | Yes | The fully-qualified URL to inspect (must be under the site) | |
| siteUrl | Yes | The site URL (property) the inspected URL belongs to | |
| languageCode | No | Optional BCP-47 language code for localized results (e.g. 'en-US', 'ko') |
Implementation Reference
- src/index.ts:512-530 (handler)The async handler function that executes the tool logic: takes inspectionUrl, siteUrl, and optional languageCode; posts to the Google Search Console URL Inspection API endpoint; returns results via toolResult helper.
async ({ inspectionUrl, siteUrl, languageCode }) => { try { const body: Record<string, string> = { inspectionUrl, siteUrl }; if (languageCode) body.languageCode = languageCode; const result = await apiCall( `${INSPECTION_BASE}/urlInspection/index:inspect`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), }, ); return toolResult(result); } catch (e) { return errorResult(e); } }, ); - src/index.ts:496-511 (schema)Input schema definition: inspectionUrl (required string), siteUrl (required string), languageCode (optional string with BCP-47 format description).
{ inspectionUrl: z .string() .describe("The fully-qualified URL to inspect (must be under the site)"), siteUrl: z .string() .describe( "The site URL (property) the inspected URL belongs to", ), languageCode: z .string() .optional() .describe( "Optional BCP-47 language code for localized results (e.g. 'en-US', 'ko')", ), }, - src/index.ts:493-530 (registration)Tool registration on the MCP server with name 'url_inspection_inspect' and description 'Inspect a URL in Google's index...'
server.tool( "url_inspection_inspect", "Inspect a URL in Google's index. Returns indexing status, crawl info, rich results, AMP status, and mobile usability for a specific URL.", { inspectionUrl: z .string() .describe("The fully-qualified URL to inspect (must be under the site)"), siteUrl: z .string() .describe( "The site URL (property) the inspected URL belongs to", ), languageCode: z .string() .optional() .describe( "Optional BCP-47 language code for localized results (e.g. 'en-US', 'ko')", ), }, async ({ inspectionUrl, siteUrl, languageCode }) => { try { const body: Record<string, string> = { inspectionUrl, siteUrl }; if (languageCode) body.languageCode = languageCode; const result = await apiCall( `${INSPECTION_BASE}/urlInspection/index:inspect`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), }, ); return toolResult(result); } catch (e) { return errorResult(e); } }, ); - src/index.ts:109-122 (helper)toolResult helper: formats the API response as MCP content text, setting isError based on HTTP ok status.
function toolResult(result: { ok: boolean; body: string }) { return { content: [{ type: "text" as const, text: result.body }], isError: !result.ok, }; } function errorResult(e: unknown) { const message = e instanceof Error ? e.message : String(e); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; } - src/index.ts:116-122 (helper)errorResult helper: catches exceptions and returns error content with isError: true.
function errorResult(e: unknown) { const message = e instanceof Error ? e.message : String(e); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; }