guardian_get_sections
Retrieve all available Guardian newspaper sections to browse and access content categories from the complete archives.
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 core handler function that executes the guardian_get_sections tool: calls client.getSections() and formats the results.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:227-234 (schema)The input schema definition (empty properties since no parameters needed) for the tool as registered in the MCP server.{ name: 'guardian_get_sections', description: 'Get all available Guardian sections', inputSchema: { type: 'object', properties: {}, }, },
- src/tools/index.ts:28-28 (registration)The registration mapping of the tool name to its handler function within the registerTools utility.guardian_get_sections: (args) => guardianGetSections(client, args),
- src/utils/formatters.ts:98-112 (helper)Supporting utility function that formats the raw sections data into a user-readable markdown list.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; }