Skip to main content
Glama

create-article

Create and publish articles to Shopify blogs using HTML content, author details, tags, and publication settings.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blogIdYesThe GID of the blog to create the article in (e.g., "gid://shopify/Blog/1234567890")
titleYesThe title of the article
contentYesThe content of the article in HTML format
authorYes
publishedNoWhether to publish the article immediately
tagsNoTags to categorize the article

Implementation Reference

  • The main handler function that executes the tool by sending a GraphQL mutation to create an article in the specified Shopify blog.
    execute: async (args: z.infer<typeof schema>) => { if (!createArticle.client) { throw new Error("GraphQL client not initialized"); } const variables = { article: { blogId: args.blogId, title: args.title, body: args.content, author: args.author, isPublished: args.published, tags: args.tags } }; try { const response = await createArticle.client.request<{ articleCreate: { article: { id: string; title: string; handle: string; body: string; summary: string | null; tags: string[]; author: { name: string; }; image: { altText: string | null; originalSrc: string; } | null; }; userErrors: Array<{ field: string; message: string; }>; }; }>(CREATE_ARTICLE_MUTATION, variables); if (response.articleCreate.userErrors.length > 0) { throw new Error( `Failed to create article: ${response.articleCreate.userErrors .map((error) => `${error.field}: ${error.message}`) .join(", ")}` ); } return response.articleCreate.article; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to create article: ${error.message}`); } throw error; } }
  • Zod schema defining the input parameters and validation for the create-article tool.
    export const schema = z.object({ blogId: z.string().min(1).describe("The GID of the blog to create the article in (e.g., \"gid://shopify/Blog/1234567890\")"), title: z.string().min(1).describe("The title of the article"), content: z.string().min(1).describe("The content of the article in HTML format"), author: z.object({ name: z.string().min(1).describe("The name of the article's author") }), published: z.boolean().optional().describe("Whether to publish the article immediately"), tags: z.array(z.string()).optional().describe("Tags to categorize the article") });
  • src/index.ts:297-306 (registration)
    Registers the create-article tool with the MCP server, delegating execution to createArticle.execute.
    server.tool( "create-article", createArticle.schema.shape, async (args: z.infer<typeof createArticle.schema>) => { const result = await createArticle.execute(args); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } );
  • GraphQL mutation used by the handler to create the article in Shopify.
    const CREATE_ARTICLE_MUTATION = gql` mutation CreateArticle($article: ArticleCreateInput!) { articleCreate(article: $article) { article { id title handle body summary tags author { name } image { altText originalSrc } } userErrors { field message } } } `;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/luckyfarnon/Shopify-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server