update-blog
Modify Shopify blog details such as title, handle, template suffix, and comment policy using the specified blog GID for targeted updates.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blogId | Yes | The GID of the blog to update (e.g., "gid://shopify/Blog/1234567890") | |
| commentPolicy | No | ||
| handle | No | ||
| templateSuffix | No | ||
| title | No |
Implementation Reference
- src/tools/updateBlog.ts:32-93 (handler)Handler function that executes the GraphQL mutation to update blog details using Shopify Admin API.execute: async (input: UpdateBlogInput) => { try { const { blogId, ...updateData } = input; const mutation = gql` mutation UpdateBlog($id: ID!, $blog: BlogUpdateInput!) { blogUpdate(id: $id, blog: $blog) { blog { id title handle templateSuffix commentPolicy } userErrors { field message } } } `; const variables = { id: blogId, blog: updateData }; const data = await shopifyClient.request(mutation, variables) as { blogUpdate: { blog: { id: string; title: string; handle: string; templateSuffix: string | null; commentPolicy: string; }; userErrors: Array<{ field: string; message: string; }>; }; }; if (data.blogUpdate.userErrors.length > 0) { throw new Error( `Failed to update blog: ${data.blogUpdate.userErrors .map((error) => error.message) .join(", ")}` ); } return { blog: data.blogUpdate.blog }; } catch (error) { console.error("Error updating blog:", error); throw new Error( `Failed to update blog: ${ error instanceof Error ? error.message : String(error) }` ); }
- src/tools/updateBlog.ts:6-12 (schema)Zod input schema defining parameters for updating a blog.const UpdateBlogInputSchema = z.object({ blogId: z.string().min(1).describe("The GID of the blog to update (e.g., \"gid://shopify/Blog/1234567890\")"), title: z.string().optional().describe("The new title for the blog"), handle: z.string().optional().describe("The URL-friendly handle for the blog"), templateSuffix: z.string().optional().describe("The template suffix for the blog"), commentPolicy: z.enum(["MODERATED", "CLOSED"]).optional().describe("The comment policy for the blog") });
- src/index.ts:208-224 (registration)MCP server registration of the 'update-blog' tool, delegating execution to the imported updateBlog.execute.// Add the updateBlog tool server.tool( "update-blog", { blogId: z.string().min(1).describe("The GID of the blog to update (e.g., \"gid://shopify/Blog/1234567890\")"), title: z.string().optional(), handle: z.string().optional(), templateSuffix: z.string().optional(), commentPolicy: z.enum(["MODERATED", "CLOSED"]).optional() }, async (args) => { const result = await updateBlog.execute(args); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } );