Skip to main content
Glama

fetch_rss_feed

Fetch and parse RSS feeds to extract structured data, including feed information and items. Input the URL and optionally use description as content for streamlined feed management.

Instructions

Fetches and parses an RSS feed, returning structured data with feed info and items

Input Schema

NameRequiredDescriptionDefault
urlYesThe URL of the RSS feed to fetch
useDescriptionAsContentNoIf 'true', use description field as content instead of content field

Input Schema (JSON Schema)

{ "additionalProperties": false, "properties": { "url": { "description": "The URL of the RSS feed to fetch", "type": "string" }, "useDescriptionAsContent": { "description": "If 'true', use description field as content instead of content field", "type": "string" } }, "required": [ "url" ], "type": "object" }

Implementation Reference

  • Execute handler for fetch_rss_feed tool: handles caching, calls rssReader.fetchFeed, and returns structured JSON.
    execute: async (args, context) => { try { logger.info(`Fetching RSS feed: ${args.url}`); // Check cache first const cached = feedCache.get(args.url); if (cached) { logger.debug(`Returning cached feed: ${args.url}`); return JSON.stringify(cached, null, 2); } // Get cache metadata for conditional requests const cacheMeta = feedCache.getMetadata(args.url); // Fetch feed const result = await rssReader.fetchFeed(args.url, { useDescriptionAsContent: args.useDescriptionAsContent === 'true', etag: cacheMeta?.etag, lastModified: cacheMeta?.lastModified, }); // Cache the result feedCache.set(args.url, result); logger.info( `Successfully fetched feed: ${args.url}, ${result.items.length} items` ); return JSON.stringify(result, null, 2); } catch (error: any) { if (error.message === "NOT_MODIFIED" && feedCache.has(args.url)) { // Return cached version if not modified const cached = feedCache.get(args.url); if (cached) { logger.debug(`Feed not modified, returning cache: ${args.url}`); return JSON.stringify(cached, null, 2); } } logger.error(`Failed to fetch RSS feed ${args.url}: ${error.message}`); throw new UserError(`Failed to fetch RSS feed: ${error.message}`); } },
  • Zod schema defining input parameters for fetch_rss_feed tool.
    const FetchRssFeedSchema = z.object({ url: z.string().describe("The URL of the RSS feed to fetch"), useDescriptionAsContent: z .string() .optional() .describe( "If 'true', use description field as content instead of content field" ), });
  • src/index.ts:27-74 (registration)
    Registration of the fetch_rss_feed tool with FastMCP server, including name, description, schema, and execute handler.
    server.addTool({ name: "fetch_rss_feed", description: "Fetches and parses an RSS feed, returning structured data with feed info and items", parameters: FetchRssFeedSchema, execute: async (args, context) => { try { logger.info(`Fetching RSS feed: ${args.url}`); // Check cache first const cached = feedCache.get(args.url); if (cached) { logger.debug(`Returning cached feed: ${args.url}`); return JSON.stringify(cached, null, 2); } // Get cache metadata for conditional requests const cacheMeta = feedCache.getMetadata(args.url); // Fetch feed const result = await rssReader.fetchFeed(args.url, { useDescriptionAsContent: args.useDescriptionAsContent === 'true', etag: cacheMeta?.etag, lastModified: cacheMeta?.lastModified, }); // Cache the result feedCache.set(args.url, result); logger.info( `Successfully fetched feed: ${args.url}, ${result.items.length} items` ); return JSON.stringify(result, null, 2); } catch (error: any) { if (error.message === "NOT_MODIFIED" && feedCache.has(args.url)) { // Return cached version if not modified const cached = feedCache.get(args.url); if (cached) { logger.debug(`Feed not modified, returning cache: ${args.url}`); return JSON.stringify(cached, null, 2); } } logger.error(`Failed to fetch RSS feed ${args.url}: ${error.message}`); throw new UserError(`Failed to fetch RSS feed: ${error.message}`); } }, });
  • Core RSS feed fetching logic in RSSReader class: fetches raw XML, parses it, formats into structured FeedResult.
    async fetchFeed( url: string, options?: { useDescriptionAsContent?: boolean; etag?: string; lastModified?: string; } ): Promise<FeedResult> { // Fetch raw feed const { data, etag, lastModified, notModified } = await this.fetchRawFeed( url, options?.etag, options?.lastModified ); if (notModified) { throw new Error('NOT_MODIFIED'); } // Parse feed const parsed = await this.parseFeed(data); if (!parsed) { throw new Error('Failed to parse feed XML'); } // Format feed const result = this.formatFeed(parsed, url, options?.useDescriptionAsContent); // Add cache headers if available if (etag) result.etag = etag; if (lastModified) result.lastModified = lastModified; return result; }
  • TypeScript interface matching the input parameters for fetch_rss_feed.
    export interface FetchRssFeedParams { url: string; useDescriptionAsContent?: 'true' | 'false'; }

Other Tools

Related Tools

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/MissionSquad/mcp-rss'

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