get_feed_headlines
Extract and format RSS feed headlines, including titles, summaries, and URLs, in markdown, text, HTML, or JSON. Simplify content retrieval for analysis or integration.
Instructions
Gets a list of headlines from a feed, including title, summary, and URL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Output format for the headlines | json |
| url | Yes | The RSS feed URL to get headlines from |
Input Schema (JSON Schema)
{
"additionalProperties": false,
"properties": {
"format": {
"default": "json",
"description": "Output format for the headlines",
"enum": [
"markdown",
"text",
"html",
"json"
],
"type": "string"
},
"url": {
"description": "The RSS feed URL to get headlines from",
"type": "string"
}
},
"required": [
"url"
],
"type": "object"
}
Implementation Reference
- src/index.ts:457-502 (handler)The execute handler function for the 'get_feed_headlines' tool. It fetches the RSS feed (using cache or rssReader), extracts and formats headlines based on the specified format (markdown, html, text, or json), and returns a structured JSON output with feed metadata and list of headlines.execute: async (args, context) => { logger.info(`Getting headlines from: ${args.url}`); // Fetch feed let feed: FeedResult | null = feedCache.get(args.url); if (!feed) { feed = await rssReader.fetchFeed(args.url); feedCache.set(args.url, feed); } // Format headlines const formatHeadline = (item: FeedItem) => { const headline = { title: item.title, summary: item.description || item.content, url: item.url, published: item.published, author: item.author, }; switch (args.format) { case "markdown": return `### [${headline.title}](${headline.url})\n${headline.summary}`; case "html": return `<h3><a href="${headline.url}">${headline.title}</a></h3><p>${headline.summary}</p>`; case "text": return `${headline.title}\n${headline.summary}\n${headline.url}`; case "json": default: return headline; } }; const headlines = feed.items.map(formatHeadline); const output = { feedTitle: feed.info.title, feedUrl: args.url, itemCount: feed.items.length, format: args.format, headlines, }; logger.info(`Got ${headlines.length} headlines from ${args.url}`); return JSON.stringify(output, null, 2); },
- src/index.ts:443-450 (schema)Zod schema defining the input parameters for the 'get_feed_headlines' tool: required 'url' for the RSS feed and optional 'format' (default 'json') for output formatting.const GetFeedHeadlinesSchema = z.object({ url: z.string().describe("The RSS feed URL to get headlines from"), format: z .enum(["markdown", "text", "html", "json"]) .optional() .default("json") .describe("Output format for the headlines"), });
- src/index.ts:452-503 (registration)Registration of the 'get_feed_headlines' tool with the FastMCP server, specifying name, description, input schema, and inline execute handler.server.addTool({ name: "get_feed_headlines", description: "Gets a list of headlines from a feed, including title, summary, and URL.", parameters: GetFeedHeadlinesSchema, execute: async (args, context) => { logger.info(`Getting headlines from: ${args.url}`); // Fetch feed let feed: FeedResult | null = feedCache.get(args.url); if (!feed) { feed = await rssReader.fetchFeed(args.url); feedCache.set(args.url, feed); } // Format headlines const formatHeadline = (item: FeedItem) => { const headline = { title: item.title, summary: item.description || item.content, url: item.url, published: item.published, author: item.author, }; switch (args.format) { case "markdown": return `### [${headline.title}](${headline.url})\n${headline.summary}`; case "html": return `<h3><a href="${headline.url}">${headline.title}</a></h3><p>${headline.summary}</p>`; case "text": return `${headline.title}\n${headline.summary}\n${headline.url}`; case "json": default: return headline; } }; const headlines = feed.items.map(formatHeadline); const output = { feedTitle: feed.info.title, feedUrl: args.url, itemCount: feed.items.length, format: args.format, headlines, }; logger.info(`Got ${headlines.length} headlines from ${args.url}`); return JSON.stringify(output, null, 2); }, });