Skip to main content
Glama
jbenton

guardian-mcp-server

by jbenton

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'],
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it 'retrieves full content' but doesn't mention authentication requirements, rate limits, error handling, or what the output looks like (e.g., format, size). For a read operation with zero annotation coverage, this is a significant gap in transparency about how the tool behaves beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with zero waste—it directly states the tool's purpose without unnecessary words. It's front-loaded and appropriately sized for a straightforward retrieval tool, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is minimally complete. It covers the basic action but lacks details on output format, error cases, or behavioral constraints. With no output schema, the description should ideally hint at return values, but it doesn't, leaving gaps in context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all three parameters (article_id, show_fields, truncate). The description doesn't add any parameter-specific details beyond what's in the schema, such as examples for show_fields beyond the default or implications of truncation. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('retrieve') and resource ('full content of a specific Guardian article'), making the purpose immediately understandable. It doesn't explicitly differentiate from siblings like guardian_search or guardian_browse_section, which would require mentioning it fetches a single article by ID rather than searching or browsing, but the specificity of 'specific Guardian article' implies this distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by specifying 'specific Guardian article', suggesting it's for when you have a known article ID or URL. However, it doesn't explicitly state when to use this tool versus alternatives like guardian_search (for finding articles) or guardian_get_article_tags (for tags of an article), nor does it mention prerequisites or exclusions, leaving some ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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