google_indexing_submit
Submit URLs to Google for fast crawling and indexing using the Indexing API. Specify URL_UPDATED for new/changed content or URL_DELETED for removed pages.
Instructions
Submit URLs to Google Indexing API for fast crawling and indexing. Requires a Google service account access token with Indexing API permissions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| urls | Yes | List of URLs to submit | |
| access_token | Yes | Google OAuth2 access token with Indexing API scope | |
| type | No | Notification type: URL_UPDATED (new/changed) or URL_DELETED (removed). Default: URL_UPDATED |
Implementation Reference
- src/index.ts:252-283 (handler)Tool registration and handler for google_indexing_submit.
server.tool( "google_indexing_submit", "Submit URLs to Google Indexing API for fast crawling and indexing. Requires a Google service account access token with Indexing API permissions.", { urls: z.array(z.string().url()).describe("List of URLs to submit"), access_token: z.string().describe("Google OAuth2 access token with Indexing API scope"), type: z .enum(["URL_UPDATED", "URL_DELETED"]) .optional() .describe("Notification type: URL_UPDATED (new/changed) or URL_DELETED (removed). Default: URL_UPDATED"), }, async ({ urls, access_token, type }) => { const results = await submitToGoogleIndexing(urls, access_token, type || "URL_UPDATED"); const successful = results.filter((r) => r.success).length; let output = `## Google Indexing API Results\n\n`; output += `**URLs submitted:** ${urls.length}\n`; output += `**Successful:** ${successful}/${urls.length}\n`; output += `**Type:** ${type || "URL_UPDATED"}\n\n`; output += `| URL | Status | Result |\n|-----|--------|--------|\n`; for (const r of results) { const shortUrl = r.url.length > 60 ? r.url.substring(0, 57) + "..." : r.url; output += `| ${shortUrl} | ${r.status} | ${r.message} |\n`; } return { content: [{ type: "text" as const, text: output }] }; } ); // Tool: Check indexing status via Google Indexing API server.tool( - src/index.ts:102-137 (helper)Helper function that performs the actual network request to the Google Indexing API.
async function submitToGoogleIndexing( urls: string[], accessToken: string, type: "URL_UPDATED" | "URL_DELETED" = "URL_UPDATED" ): Promise<GoogleIndexResult[]> { const results: GoogleIndexResult[] = []; for (const url of urls) { try { const response = await fetch(GOOGLE_INDEXING_API_URL, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${accessToken}`, }, body: JSON.stringify({ url, type, }), signal: AbortSignal.timeout(15000), }); const data = await response.json(); results.push({ url, success: response.status >= 200 && response.status < 300, status: response.status, message: response.ok ? `Submitted (${type})` : data.error?.message || `HTTP ${response.status}`, }); } catch (error) { results.push({ url, success: false,