Skip to main content
Glama

guardian_get_article

Retrieve full Guardian article content by providing article ID or URL, with options to customize displayed fields and truncate length.

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 validates input with Zod schema, parses Guardian article ID or URL, fetches the full article content using GuardianClient.getArticle, formats the response with optional truncation, and returns formatted article or 'Article not found.'
    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 used for runtime validation of input parameters in the handler (article_id required, show_fields and truncate optional).
    export const GetArticleParamsSchema = z.object({ article_id: z.string(), show_fields: z.string().optional(), truncate: z.boolean().optional(), });
  • Registration of all tools including guardian_get_article mapped to the guardianGetArticle handler function, exported for use in the main server.
    export function registerTools(client: GuardianClient): Record<string, ToolHandler> { return { guardian_search: (args) => guardianSearch(client, args), guardian_get_article: (args) => guardianGetArticle(client, args), guardian_longread: (args) => guardianLongread(client, args), guardian_lookback: (args) => guardianLookback(client, args), guardian_browse_section: (args) => guardianBrowseSection(client, args), guardian_get_sections: (args) => guardianGetSections(client, args), guardian_search_tags: (args) => guardianSearchTags(client, args), guardian_search_by_length: (args) => guardianSearchByLength(client, args), guardian_search_by_author: (args) => guardianSearchByAuthor(client, args), guardian_find_related: (args) => guardianFindRelated(client, args), guardian_get_article_tags: (args) => guardianGetArticleTags(client, args), guardian_content_timeline: (args) => guardianContentTimeline(client, args), guardian_author_profile: (args) => guardianAuthorProfile(client, args), guardian_topic_trends: (args) => guardianTopicTrends(client, args), guardian_top_stories_by_date: (args) => guardianTopStoriesByDate(client, args), guardian_recommend_longreads: (args) => guardianRecommendLongreads(client, args), };
  • src/index.ts:120-140 (registration)
    MCP protocol registration of the tool in ListTools response, including name, description, and input schema definition.
    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'], }, },

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