guardian_get_sections
Retrieve all available sections from The Guardian newspaper archives, enabling organized access to its extensive content since 1999.
Instructions
Get all available Guardian sections
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/guardian-get-sections.ts:4-9 (handler)The main handler function that fetches Guardian sections using the client and formats them for output.export async function guardianGetSections(client: GuardianClient, args: any): Promise<string> { const response = await client.getSections(); const sections = response.response.results; return formatSectionsResponse(sections); }
- src/index.ts:228-234 (schema)Input schema definition for the tool in the MCP ListTools response (no parameters required).name: 'guardian_get_sections', description: 'Get all available Guardian sections', inputSchema: { type: 'object', properties: {}, }, },
- src/tools/index.ts:21-40 (registration)Registration of the guardian_get_sections tool handler within the registerTools function that creates the tools map.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/utils/formatters.ts:98-112 (helper)Utility function used by the handler to format the sections list into a markdown response string.export function formatSectionsResponse(sections: GuardianSection[]): string { if (!sections || sections.length === 0) { return 'No sections found.'; } let result = 'Available Guardian sections:\n\n'; sections.forEach((section) => { result += `**${section.webTitle || 'Unknown'}**\n`; result += `ID: ${section.id || 'N/A'}\n`; result += `URL: ${section.webUrl || 'N/A'}\n\n`; }); return result; }