indexing_batch_publish
Batch notify Google about multiple URL updates or removals via the Indexing API. Combines up to 100 notifications into a single HTTP request for efficiency.
Instructions
Batch notify Google about multiple URL updates or removals via the Indexing API. Combines up to 100 notifications into a single HTTP request for efficiency.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| notifications | Yes | Array of URL notifications (1-100 items). Each item has a url and type. |
Implementation Reference
- src/index.ts:585-654 (handler)The handler implementation for the `indexing_batch_publish` tool. It takes an array of URL notifications, constructs a multipart/mixed HTTP request, and sends it to the Google Indexing API batch endpoint.
// ── indexing_batch_publish ── server.tool( "indexing_batch_publish", "Batch notify Google about multiple URL updates or removals via the Indexing API. Combines up to 100 notifications into a single HTTP request for efficiency.", { notifications: z .array( z.object({ url: z.string().describe("The fully-qualified URL"), type: z .enum(["URL_UPDATED", "URL_DELETED"]) .describe("Notification type: URL_UPDATED or URL_DELETED"), }), ) .min(1) .max(100) .describe( "Array of URL notifications (1-100 items). Each item has a url and type.", ), }, async ({ notifications }) => { try { const token = await getAccessToken(); const boundary = `batch_gsc_mcp_${Date.now()}`; const parts = notifications.map((n, i) => { const body = JSON.stringify({ url: n.url, type: n.type }); return [ `--${boundary}`, "Content-Type: application/http", "Content-Transfer-Encoding: binary", `Content-ID: <item-${i + 1}>`, "", "POST /v3/urlNotifications:publish HTTP/1.1", "Content-Type: application/json", "accept: application/json", `content-length: ${Buffer.byteLength(body)}`, "", body, ].join("\r\n"); }); const batchBody = parts.join("\r\n") + `\r\n--${boundary}--`; const res = await fetch("https://indexing.googleapis.com/batch", { method: "POST", headers: { Authorization: `Bearer ${token}`, "Content-Type": `multipart/mixed; boundary=${boundary}`, }, body: batchBody, }); const responseText = await res.text(); return { content: [ { type: "text" as const, text: res.ok ? `Batch published ${notifications.length} URL(s) successfully.\n\n${responseText}` : `Batch request failed (${res.status}):\n${responseText}`, }, ], isError: !res.ok, }; } catch (e) { return errorResult(e); } }, );