Skip to main content
Glama

get-blog-by-id

Retrieve specific blog details from a Shopify store using its unique GID via the GraphQL API, enabling targeted data access for store management.

Input Schema

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

Implementation Reference

  • The 'execute' function that implements the core logic of fetching a blog by its ID using Shopify's GraphQL API.
    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 input schema defining the required 'blogId' parameter.
    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)
    MCP server registration of the 'get-blog-by-id' tool, using the schema and execute method from the imported tool module.
    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) }] }; } );

Other Tools

Related Tools

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