Skip to main content
Glama

get-blog-by-id

Retrieve a specific blog from a Shopify store using its unique GraphQL ID to access blog content and metadata for management or display purposes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blogIdYesThe GID of the blog to fetch (e.g., "gid://shopify/Blog/1234567890")

Implementation Reference

  • The `execute` function that runs the GraphQL query to retrieve a specific blog by its ID using the Shopify GraphQL client.
    async execute(input: GetBlogByIdInput) { try { const query = gql` query GetBlogById($id: ID!) { blog(id: $id) { id title handle templateSuffix commentPolicy createdAt updatedAt articles(first: 5) { nodes { id title handle publishedAt author { name } tags } } } } `; const data = await shopifyClient.request(query, { id: input.blogId }) as { blog: { id: string; title: string; handle: string; templateSuffix: string | null; commentPolicy: string; createdAt: string; updatedAt: string; articles: { nodes: Array<{ id: string; title: string; handle: string; publishedAt: string; author: { name: string; } | null; tags: string[]; }>; }; }; }; return { blog: data.blog }; } catch (error) { console.error("Error fetching blog by ID:", error); throw new Error( `Failed to fetch blog: ${error instanceof Error ? error.message : String(error)}` ); } }
  • Zod schema defining the input: `blogId` as a required string.
    const GetBlogByIdInputSchema = z.object({ blogId: z.string().min(1).describe("The GID of the blog to fetch (e.g., \"gid://shopify/Blog/1234567890\")") });
  • src/index.ts:264-273 (registration)
    Registers the `get-blog-by-id` tool with the MCP server, using the schema from the tool module and delegating execution to the tool's `execute` method.
    server.tool( "get-blog-by-id", getBlogById.schema.shape, async (args: z.infer<typeof getBlogById.schema>) => { const result = await getBlogById.execute(args); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } );

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