Skip to main content
Glama

guardian_get_article

Retrieve the full content and metadata of specific Guardian articles using their ID or URL, customizable with fields like headline, body, and publication date.

Instructions

Retrieve full content of a specific Guardian article

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
article_idYesThe Guardian article ID or full URL (e.g., "politics/2024/dec/01/example" or "https://www.theguardian.com/politics/2024/dec/01/example")
show_fieldsNoFields to include (default: headline,standfirst,body,byline,publication,firstPublicationDate)
truncateNoWhether to truncate content to preview length (default: false for full content)

Implementation Reference

  • The main handler function that executes the tool logic: parses input, fetches article from Guardian API, formats and returns the content.
    export async function guardianGetArticle(client: GuardianClient, args: any): Promise<string> { const params = GetArticleParamsSchema.parse(args); // Parse URL if provided instead of article ID const articleId = parseGuardianUrl(params.article_id); const showFields = params.show_fields || 'headline,standfirst,body,byline,publication,firstPublicationDate'; const response = await client.getArticle(articleId, { 'show-fields': showFields, 'show-tags': 'all' }); const content = response.response.content; if (content) { // For v2.0: Default to full content, allow truncation if explicitly requested const formatOptions = { truncate: params.truncate ?? false, maxLength: 500, showTags: true }; return formatArticleResponse([content], undefined, formatOptions); } else { return 'Article not found.'; } }
  • Zod schema for input validation used within the handler.
    export const GetArticleParamsSchema = z.object({ article_id: z.string(), show_fields: z.string().optional(), truncate: z.boolean().optional(), });
  • Public JSON schema for the tool input as defined in the MCP server ListTools response.
    { name: 'guardian_get_article', description: 'Retrieve full content of a specific Guardian article', inputSchema: { type: 'object', properties: { article_id: { type: 'string', description: 'The Guardian article ID or full URL (e.g., "politics/2024/dec/01/example" or "https://www.theguardian.com/politics/2024/dec/01/example")', }, show_fields: { type: 'string', description: 'Fields to include (default: headline,standfirst,body,byline,publication,firstPublicationDate)', }, truncate: { type: 'boolean', description: 'Whether to truncate content to preview length (default: false for full content)', }, }, required: ['article_id'], }, },
  • Registration of the handler function in the tools map returned by registerTools.
    guardian_get_article: (args) => guardianGetArticle(client, args),

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/jbenton/guardian-mcp-server'

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