Skip to main content
Glama

guardian_browse_section

Retrieve recent articles from a specific Guardian section by specifying the section ID, days back, and page size. Access full-text archives dating back to 1999 for comprehensive research or news tracking.

Instructions

Browse recent articles from a specific Guardian section

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
days_backNoHow many days back to search (default: 7)
page_sizeNoNumber of results, max 200 (default: 20)
sectionYesSection ID (use guardian_get_sections to find valid IDs)

Implementation Reference

  • The core handler function that implements the guardian_browse_section tool. It validates input args using BrowseSectionParamsSchema, computes the from-date based on days_back, constructs Guardian API search parameters filtered by section and recency, fetches articles, and returns a formatted response with truncated content for performance.
    export async function guardianBrowseSection(client: GuardianClient, args: any): Promise<string> { const params = BrowseSectionParamsSchema.parse(args); const daysBack = params.days_back || 7; const fromDate = calculateDateFromDaysBack(daysBack); const searchParams: Record<string, any> = { section: params.section, 'from-date': fromDate, 'order-by': 'newest', 'page-size': params.page_size || 20, 'show-fields': 'headline,standfirst,byline,publication,firstPublicationDate' }; 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 input validation schema used by the handler to parse and validate arguments for the guardian_browse_section tool.
    export const BrowseSectionParamsSchema = z.object({ section: z.string(), days_back: z.number().min(1).max(365).optional(), page_size: z.number().min(1).max(200).optional(), });
  • Registers the guardian_browse_section handler function in the central tools registry returned by registerTools(client).
    guardian_browse_section: (args) => guardianBrowseSection(client, args),
  • MCP protocol input schema definition for the guardian_browse_section tool, provided in the ListTools response for client validation.
    name: 'guardian_browse_section', description: 'Browse recent articles from a specific Guardian section', inputSchema: { type: 'object', properties: { section: { type: 'string', description: 'Section ID (use guardian_get_sections to find valid IDs)', }, days_back: { type: 'integer', description: 'How many days back to search (default: 7)', minimum: 1, maximum: 365, }, page_size: { type: 'integer', description: 'Number of results, max 200 (default: 20)', minimum: 1, maximum: 200, }, }, required: ['section'], }, },
  • src/index.ts:576-584 (registration)
    The handleToolCall method that dynamically retrieves and executes the registered tool handler (including guardian_browse_section) based on the tool name from CallTool requests.
    const tools = registerTools(this.guardianClient); const tool = tools[toolName]; if (!tool) { throw new Error(`Unknown tool: ${toolName}`); } return await tool(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