Skip to main content
Glama
jbenton

guardian-mcp-server

by jbenton

guardian_lookback

Retrieve top Guardian news stories from specific dates or date ranges to research historical events and track coverage over time.

Instructions

Find top stories from a specific date or date range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYesSpecific date (YYYY-MM-DD) or start of range
end_dateNoEnd date for range (YYYY-MM-DD)
sectionNoFilter by section
page_sizeNoNumber of results (default: 20)

Implementation Reference

  • The core handler function that implements the guardian_lookback tool logic: validates params, constructs search query for a date range ordered by newest, fetches from Guardian API, and formats the response.
    export async function guardianLookback(client: GuardianClient, args: any): Promise<string> {
      const params = LookbackParamsSchema.parse(args);
    
      const fromDate = validateDate(params.date);
      if (!fromDate) {
        throw new Error(`Invalid date format: ${params.date}. Use YYYY-MM-DD format.`);
      }
    
      const searchParams: Record<string, any> = {
        'from-date': fromDate,
        'order-by': 'newest',
        'page-size': params.page_size || 20,
        'show-fields': 'headline,standfirst,byline,publication,firstPublicationDate'
      };
    
      if (params.end_date) {
        const toDate = validateDate(params.end_date);
        if (!toDate) {
          throw new Error(`Invalid end_date format: ${params.end_date}. Use YYYY-MM-DD format.`);
        }
        searchParams['to-date'] = toDate;
      } else {
        // If no end date, use the same date
        searchParams['to-date'] = fromDate;
      }
    
      if (params.section) {
        searchParams.section = params.section;
      }
    
      const response = await client.search(searchParams);
      const articles = response.response.results;
      const pagination = response.response;
    
      // For search results, default to truncated content for performance
      const formatOptions = { truncate: true, maxLength: 500 };
      return formatArticleResponse(articles, pagination, formatOptions);
    }
  • Zod schema for validating input parameters to the guardian_lookback tool.
    export const LookbackParamsSchema = z.object({
      date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
      end_date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
      section: z.string().optional(),
      page_size: z.number().min(1).max(200).optional(),
    });
  • Registers all tools including guardian_lookback, mapping the tool name to the handler function with the Guardian client.
    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:174-200 (registration)
    MCP protocol registration of the guardian_lookback tool, including its name, description, and input schema for the ListTools handler.
      name: 'guardian_lookback',
      description: 'Find top stories from a specific date or date range',
      inputSchema: {
        type: 'object',
        properties: {
          date: {
            type: 'string',
            description: 'Specific date (YYYY-MM-DD) or start of range',
          },
          end_date: {
            type: 'string',
            description: 'End date for range (YYYY-MM-DD)',
          },
          section: {
            type: 'string',
            description: 'Filter by section',
          },
          page_size: {
            type: 'integer',
            description: 'Number of results (default: 20)',
            minimum: 1,
            maximum: 200,
          },
        },
        required: ['date'],
      },
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't describe important behavioral aspects: what 'top stories' means (ranking criteria, source), whether results are paginated beyond page_size, rate limits, authentication requirements, or what the output format looks like. The description is minimal and lacks operational context.

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, efficient sentence that states the core functionality without unnecessary words. It's appropriately sized for a tool with clear parameters documented in the schema, though it could benefit from additional context about usage and behavior.

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

Completeness2/5

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

For a tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what 'top stories' means, how results are ranked/selected, what the output format is, or when to use this versus similar tools like guardian_top_stories_by_date. The description provides basic purpose but lacks the context needed for effective tool selection and invocation.

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 already fully documents all parameters. The description adds no additional parameter semantics beyond what's in the schema - it mentions date/date range filtering which aligns with the date and end_date parameters, but provides no extra context about format, constraints, or usage patterns.

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 ('Find') and resource ('top stories'), specifying the scope as 'from a specific date or date range'. It distinguishes from some siblings like guardian_get_article (single article) or guardian_search (general search), but doesn't explicitly differentiate from guardian_top_stories_by_date which appears similar.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like guardian_top_stories_by_date (which appears to serve a similar function) or guardian_search (which might also find stories by date). No context about prerequisites, limitations, or typical use cases is provided.

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