publish
Publish an extension to Chrome Web Store with options for immediate or staged rollout, deploy percentage, and skip-review.
Instructions
Publish an extension to Chrome Web Store. Supports immediate publish, staged publish, initial deploy percentage, and skip-review.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| itemId | No | Extension item ID (defaults to CWS_ITEM_ID env var) | |
| publisherId | No | Publisher ID (defaults to CWS_PUBLISHER_ID env var or 'me') | |
| publishType | No | DEFAULT_PUBLISH: publishes immediately after approval. STAGED_PUBLISH: stages for manual publishing after approval. Defaults to DEFAULT_PUBLISH. | |
| deployPercentage | No | Initial deploy percentage for staged rollout (0-100). Only used with STAGED_PUBLISH or DEFAULT_PUBLISH. | |
| skipReview | No | Attempt to skip review if the extension qualifies. Defaults to false. |
Implementation Reference
- src/index.ts:309-342 (handler)Handler function for the 'publish' tool. Calls the Chrome Web Store v2 API to publish an extension, supporting immediate publish, staged publish, deploy percentage, and skip-review options.
async ({ itemId, publisherId, publishType, deployPercentage, skipReview }) => { try { const id = resolveItemId(itemId); const pub = resolvePublisherId(publisherId); const url = `${API_BASE}/v2/publishers/${pub}/items/${id}:publish`; const body: Record<string, unknown> = {}; if (publishType) body.publishType = publishType; if (deployPercentage !== undefined) { body.deployInfos = [{ deployPercentage }]; } if (skipReview !== undefined) body.skipReview = skipReview; const hasBody = Object.keys(body).length > 0; const result = await apiCall(url, { method: "POST", ...(hasBody ? { headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), } : {}), }); return formatResponse(result); } catch (e: any) { return { content: [{ type: "text" as const, text: `Error: ${e.message}` }], isError: true, }; } }, - src/index.ts:282-308 (schema)Zod schema definitions for the 'publish' tool parameters: itemId, publisherId, publishType (DEFAULT_PUBLISH|STAGED_PUBLISH), deployPercentage (0-100), and skipReview (boolean).
{ itemId: z .string() .optional() .describe("Extension item ID (defaults to CWS_ITEM_ID env var)"), publisherId: z .string() .optional() .describe("Publisher ID (defaults to CWS_PUBLISHER_ID env var or 'me')"), publishType: z .enum(["DEFAULT_PUBLISH", "STAGED_PUBLISH"]) .optional() .describe( "DEFAULT_PUBLISH: publishes immediately after approval. STAGED_PUBLISH: stages for manual publishing after approval. Defaults to DEFAULT_PUBLISH." ), deployPercentage: z .number() .int() .min(0) .max(100) .optional() .describe("Initial deploy percentage for staged rollout (0-100). Only used with STAGED_PUBLISH or DEFAULT_PUBLISH."), skipReview: z .boolean() .optional() .describe("Attempt to skip review if the extension qualifies. Defaults to false."), }, - src/index.ts:278-343 (registration)Registration of the 'publish' tool via server.tool() with name 'publish', description, schema, and handler.
// ── publish ── server.tool( "publish", "Publish an extension to Chrome Web Store. Supports immediate publish, staged publish, initial deploy percentage, and skip-review.", { itemId: z .string() .optional() .describe("Extension item ID (defaults to CWS_ITEM_ID env var)"), publisherId: z .string() .optional() .describe("Publisher ID (defaults to CWS_PUBLISHER_ID env var or 'me')"), publishType: z .enum(["DEFAULT_PUBLISH", "STAGED_PUBLISH"]) .optional() .describe( "DEFAULT_PUBLISH: publishes immediately after approval. STAGED_PUBLISH: stages for manual publishing after approval. Defaults to DEFAULT_PUBLISH." ), deployPercentage: z .number() .int() .min(0) .max(100) .optional() .describe("Initial deploy percentage for staged rollout (0-100). Only used with STAGED_PUBLISH or DEFAULT_PUBLISH."), skipReview: z .boolean() .optional() .describe("Attempt to skip review if the extension qualifies. Defaults to false."), }, async ({ itemId, publisherId, publishType, deployPercentage, skipReview }) => { try { const id = resolveItemId(itemId); const pub = resolvePublisherId(publisherId); const url = `${API_BASE}/v2/publishers/${pub}/items/${id}:publish`; const body: Record<string, unknown> = {}; if (publishType) body.publishType = publishType; if (deployPercentage !== undefined) { body.deployInfos = [{ deployPercentage }]; } if (skipReview !== undefined) body.skipReview = skipReview; const hasBody = Object.keys(body).length > 0; const result = await apiCall(url, { method: "POST", ...(hasBody ? { headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), } : {}), }); return formatResponse(result); } catch (e: any) { return { content: [{ type: "text" as const, text: `Error: ${e.message}` }], isError: true, }; } }, ); - src/index.ts:88-90 (helper)resolvePublisherId helper used by the publish handler to resolve the publisher ID from argument or environment variable.
function resolvePublisherId(publisherId?: string): string { return publisherId || PUBLISHER_ID; } - src/index.ts:78-86 (helper)resolveItemId helper used by the publish handler to resolve the item ID from argument or environment variable.
function resolveItemId(itemId?: string): string { const id = itemId || DEFAULT_ITEM_ID; if (!id) { throw new Error( "No item ID provided. Pass itemId parameter or set CWS_ITEM_ID env var.", ); } return id; }