Skip to main content
Glama

get-articles

Retrieve articles from a Shopify blog using the blog's GID. Search by title and set a limit for the number of results returned. Access blog content via the Shopify MCP Server's GraphQL API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blogIdYesThe GID of the blog to get articles from (e.g., "gid://shopify/Blog/1234567890")
limitNo
searchTitleNo

Implementation Reference

  • The main handler function 'execute' that performs the GraphQL query to fetch articles from a Shopify blog, processes the response, and returns formatted article data.
    execute: async (input: GetArticlesInput) => { try { const { blogId, searchTitle, limit } = input; const query = gql` query GetArticles($blogId: ID!, $first: Int!) { blog(id: $blogId) { id title articles(first: $first) { edges { node { id title handle author { name } publishedAt tags image { id url altText } comments(first: 0) { pageInfo { hasNextPage hasPreviousPage } } } } pageInfo { hasNextPage hasPreviousPage startCursor endCursor } } } } `; const variables = { blogId, first: limit }; const data = await shopifyClient.request(query, variables) as { blog: { id: string; title: string; articles: { edges: Array<{ node: { id: string; title: string; handle: string; author: { name: string; } | null; publishedAt: string; tags: string[]; image: { id: string; url: string; altText: string | null; } | null; comments: { pageInfo: { hasNextPage: boolean; hasPreviousPage: boolean; }; }; }; }>; pageInfo: { hasNextPage: boolean; hasPreviousPage: boolean; startCursor: string; endCursor: string; }; }; }; }; return { blogId: data.blog.id, blogTitle: data.blog.title, articles: data.blog.articles.edges.map(edge => ({ id: edge.node.id, title: edge.node.title, handle: edge.node.handle, author: edge.node.author, publishedAt: edge.node.publishedAt, tags: edge.node.tags, image: edge.node.image, hasComments: edge.node.comments.pageInfo.hasNextPage || edge.node.comments.pageInfo.hasPreviousPage })), pageInfo: data.blog.articles.pageInfo }; } catch (error) { console.error("Error fetching articles:", error); throw new Error( `Failed to fetch articles: ${ error instanceof Error ? error.message : String(error) }` ); } }
  • Zod input schema defining parameters for the get-articles tool: blogId (required), searchTitle (optional), limit (default 10).
    const GetArticlesInputSchema = z.object({ blogId: z.string().min(1).describe("The GID of the blog to get articles from (e.g., \"gid://shopify/Blog/1234567890\")"), searchTitle: z.string().optional().describe("Optional search term to filter articles by title"), limit: z.number().default(10).describe("Maximum number of articles to return (default: 10)") });
  • src/index.ts:227-239 (registration)
    MCP server tool registration for 'get-articles', including inline schema and handler that delegates to getArticles.execute.
    server.tool( "get-articles", { blogId: z.string().min(1).describe("The GID of the blog to get articles from (e.g., \"gid://shopify/Blog/1234567890\")"), searchTitle: z.string().optional(), limit: z.number().default(10) }, async (args) => { const result = await getArticles.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