google_indexing_status
Check when a URL was last submitted to Google for indexing using the Google Indexing API. Verify indexing notification status with an access token.
Instructions
Check the indexing notification status of a URL via Google Indexing API. Shows when the URL was last submitted.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to check indexing status for | |
| access_token | Yes | Google OAuth2 access token |
Implementation Reference
- src/index.ts:283-304 (handler)The registration of the 'google_indexing_status' tool and its handler logic.
server.tool( "google_indexing_status", "Check the indexing notification status of a URL via Google Indexing API. Shows when the URL was last submitted.", { url: z.string().url().describe("URL to check indexing status for"), access_token: z.string().describe("Google OAuth2 access token"), }, async ({ url, access_token }) => { const result = await checkIndexStatus(url, access_token); let output = `## Indexing Status\n\n`; output += `**URL:** ${result.url}\n`; if (result.error) { output += `**Error:** ${result.error}\n`; } else { output += `**Last Notification:** ${result.lastCrawled || "Never"}\n`; output += `**Type:** ${result.type || "Unknown"}\n`; } return { content: [{ type: "text" as const, text: output }] }; } ); - src/index.ts:147-175 (helper)The helper function 'checkIndexStatus' which performs the API call to the Google Indexing API.
async function checkIndexStatus( url: string, accessToken: string ): Promise<{ url: string; lastCrawled?: string; type?: string; error?: string }> { try { const response = await fetch( `https://indexing.googleapis.com/v3/urlNotifications/metadata?url=${encodeURIComponent(url)}`, { headers: { Authorization: `Bearer ${accessToken}` }, signal: AbortSignal.timeout(15000), } ); if (!response.ok) { const data = await response.json(); return { url, error: data.error?.message || `HTTP ${response.status}` }; } const data = await response.json(); return { url, lastCrawled: data.latestUpdate?.notifyTime || data.latestRemove?.notifyTime, type: data.latestUpdate ? "URL_UPDATED" : data.latestRemove ? "URL_DELETED" : "UNKNOWN", }; } catch (error) { return { url, error: error instanceof Error ? error.message : "Unknown error", };