Skip to main content
Glama

get-bbc-news

Fetch BBC News articles across categories like global, UK, business, politics, health, and tech. Access tailored editions for UK, US, or worldwide news updates.

Instructions

获取 BBC 新闻,提供全球新闻、英国新闻、商业、政治、健康、教育、科技、娱乐等资讯

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNo
editionNo版本,仅对 `category` 为空有效

Implementation Reference

  • src/tools/bbc.ts:47-55 (registration)
    Registers the 'get-bbc-news' tool with defineToolConfig, specifying name, description, input schema, and a handler that constructs RSS URL and calls getRssItems.
    export default defineToolConfig({ name: 'get-bbc-news', description: '获取 BBC 新闻,提供全球新闻、英国新闻、商业、政治、健康、教育、科技、娱乐等资讯', zodSchema: bbcRequestSchema, func: async (args) => { const { url } = bbcRequestSchema.parse(args); return getRssItems(url); }, });
  • Zod schema defining optional 'category' and 'edition' parameters for BBC news, transforming them into a BBC RSS feed URL.
    const bbcRequestSchema = z .object({ category: z .union([ z.literal('').describe('热门新闻'), z.literal('world').describe('国际'), z.literal('uk').describe('英国'), z.literal('business').describe('商业'), z.literal('politics').describe('政治'), z.literal('health').describe('健康'), z.literal('education').describe('教育'), z.literal('science_and_environment').describe('科学与环境'), z.literal('technology').describe('科技'), z.literal('entertainment_and_arts').describe('娱乐与艺术'), ]) .optional() .default(''), edition: z .union([ z.literal(''), z.literal('uk').describe('UK'), z.literal('us').describe('US & Canada'), z.literal('int').describe('Rest of the world'), ]) .optional() .default('') .describe('版本,仅对 `category` 为空有效'), }) .transform((values) => { let url = 'https://feeds.bbci.co.uk/news/'; if (values.category) { url += `${values.category}/`; } url += 'rss.xml'; if (values.edition) { url += `?edition=${values.edition}`; } return { ...values, url, }; });
  • Tool handler function that parses input args to extract URL and delegates to getRssItems helper.
    func: async (args) => { const { url } = bbcRequestSchema.parse(args); return getRssItems(url); },
  • Core helper function to fetch RSS feed from URL, parse XML items, and extract structured news data (title, description, category, author, publish_time, link).
    export const getRssItems = async (url: string) => { const data = await getRss(url); if (!Array.isArray(data.rss?.channel?.item)) { return []; } return (data.rss.channel.item as any[]).map((item) => { let category = ''; if (typeof item.category === 'string') { category = item.category; } if (Array.isArray(item.category)) { category = item.category.join(', '); } return { title: item.title, description: item.description, category, author: item.author || item['dc:creator'], publish_time: item.pubDate, link: item.link, }; }); };

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/baranwang/mcp-trends-hub'

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