Skip to main content
Glama

get-article-by-id

Fetch a specific article from a Shopify store using its unique GID identifier to retrieve blog content for display or analysis.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
articleIdYesThe GID of the article to fetch (e.g., "gid://shopify/Article/1234567890")

Implementation Reference

  • The execute handler function that queries Shopify GraphQL API for the specific article by its GID and returns its details including title, author, blog, body, published date, and tags.
    async execute(input: GetArticleByIdInput) { try { const query = gql` query GetArticleById($id: ID!) { article(id: $id) { id title handle author { name } blog { id title } body publishedAt tags } } `; const data = await shopifyClient.request(query, { id: input.articleId }) as { article: { id: string; title: string; handle: string; author: { name: string; } | null; blog: { id: string; title: string; }; body: string; publishedAt: string; tags: string[]; }; }; return { article: data.article }; } catch (error) { console.error("Error fetching article by ID:", error); throw new Error( `Failed to fetch article: ${error instanceof Error ? error.message : String(error)}` ); } }
  • Zod input schema defining the required articleId parameter.
    const GetArticleByIdInputSchema = z.object({ articleId: z.string().min(1).describe("The GID of the article to fetch (e.g., \"gid://shopify/Article/1234567890\")") });
  • src/index.ts:275-284 (registration)
    MCP server registration of the 'get-article-by-id' tool, using the schema from the tool module and delegating execution to its execute method.
    server.tool( "get-article-by-id", getArticleById.schema.shape, async (args: z.infer<typeof getArticleById.schema>) => { const result = await getArticleById.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