Skip to main content
Glama
veithly

RSS MCP Server

by veithly

get_feed

Fetch and parse RSS feeds from any URL, including RSSHub content, using the RSS MCP Server. Supply the feed URL to retrieve structured feed data for processing.

Instructions

Get RSS feed from any URL, including RSSHub feeds.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL of the RSS feed. For RSSHub, you can use "rsshub://" protocol (e.g., "rsshub://bilibili/user/dynamic/208259").

Implementation Reference

  • Main handler function that implements the core logic of fetching, parsing, and processing RSS feeds from given URLs, with fallback to multiple RSSHub instances.
    export async function get_feed(params: { url: string, count?: number }): Promise<RssFeed> {
        try {
            let currentUrl = params.url;
    
            if (typeof currentUrl !== 'string') {
                throw new Error("URL must be a string.");
            }
    
            // Handle JSON string input
            try {
                const parsed = JSON.parse(currentUrl);
                if (parsed && typeof parsed === 'object' && parsed.url) {
                    currentUrl = parsed.url;
                }
            } catch (e) {
                // Not a JSON string, use as is
            }
    
            if (!currentUrl.includes('://')) {
                currentUrl = `rsshub://${currentUrl}`;
            }
    
            const urls = convertRsshubUrl(currentUrl);
    
            const userAgents = [
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/121.0"
            ];
    
            const headers = {
                "User-Agent": userAgents[Math.floor(Math.random() * userAgents.length)],
                "Accept": "application/rss+xml,application/xml;q=0.9,*/*;q=0.8",
                "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
                "Accept-Encoding": "gzip, deflate, br"
            };
    
            let lastError: Error | null = null;
    
            for (const u of urls) {
                try {
                    console.error(`Attempting to fetch from ${u}...`);
                    const response = await axios.get(u, {
                        headers,
                        timeout: 15000, // Reduced timeout to fail faster
                        maxRedirects: 3,
                        validateStatus: (status) => status >= 200 && status < 300,
                        responseType: 'text', // Ensure response is treated as text
                    });
    
                    if (!response.data) {
                        throw new Error("Empty response data");
                    }
    
                    const parser = new Parser({
                        timeout: 10000, // Parser timeout
                        maxRedirects: 3,
                    });
                    const feed = await parser.parseString(response.data);
    
                    if (!feed || !feed.items) {
                        throw new Error("Cannot parse RSS feed, feed or feed.items is undefined.");
                    }
    
                    const feedInfo: RssFeed = {
                        title: feed.title,
                        link: feed.link,
                        description: feed.description,
                        items: []
                    };
    
                    const itemsToProcess = params.count === 0 ? feed.items : feed.items.slice(0, params.count ?? 1);
    
                    for (const item of itemsToProcess) {
                        let description = '';
                        if (item.content) {
                            const $ = cheerio.load(item.content);
                            description = $.text().replace(/\s+/g, ' ').trim();
                        } else if (item.contentSnippet) {
                            description = item.contentSnippet;
                        }
    
                        let pubDate: string | undefined = undefined;
                        if (item.pubDate) {
                            try {
                                pubDate = formatInTimeZone(new Date(item.pubDate), 'UTC', "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
                            } catch (e) {
                                console.error(`Date parse error: ${e}`);
                                pubDate = item.pubDate;
                            }
                        }
    
                        const feedItem: RssItem = {
                            title: item.title,
                            description: description,
                            link: item.link,
                            guid: item.guid || item.link,
                            pubDate: pubDate,
                            author: item.creator,
                            category: item.categories
                        };
                        feedInfo.items.push(feedItem);
                    }
    
                    return feedInfo;
    
                } catch (error) {
                    lastError = error as Error;
                    const errorMsg = error instanceof Error ? error.message : String(error);
                    console.error(`Attempt to access ${u} failed: ${errorMsg}`);
    
                    // Add a small delay between retries to avoid overwhelming servers
                    if (urls.indexOf(u) < urls.length - 1) {
                        await new Promise(resolve => setTimeout(resolve, 100));
                    }
                    continue;
                }
            }
    
            const finalError = lastError?.message || 'Unknown error';
            console.error(`All RSSHub instances failed. Last error: ${finalError}`);
            throw new Error(`All RSSHub instances failed: ${finalError}`);
        } catch (error) {
            const errorMessage = error instanceof Error ? error.message : 'An unknown error occurred';
            console.error(`Unexpected error in get_feed: ${errorMessage}`);
            throw error; // Re-throw the error to be caught by the tool handler
        }
    }
  • src/index.ts:222-251 (registration)
    Registration of the get_feed tool with McpServer, including Zod input schema validation and the execution wrapper.
    // Register the get_feed tool using the modern McpServer API
    server.registerTool(
        "get_feed",
        {
            description: "Get RSS feed from any URL, including RSSHub feeds.",
            inputSchema: {
                url: z.string().describe("URL of the RSS feed. For RSSHub, you can use 'rsshub://' protocol (e.g., 'rsshub://bilibili/user/dynamic/208259')."),
                count: z.number().optional().describe("Number of RSS feed items to retrieve. Defaults to 1. Set to 0 to retrieve all items.")
            }
        },
        async ({ url, count }) => {
            try {
                console.error(`Tool called with URL: ${url} and count: ${count}`);
                const feedResult = await get_feed({ url, count });
                console.error(`Tool completed successfully for URL: ${url}`);
                return {
                    content: [{ type: "text", text: JSON.stringify(feedResult, null, 2) }]
                };
            } catch (error) {
                const errorMessage = error instanceof Error ? error.message : 'An unknown error occurred';
                console.error(`Tool error for URL ${url}: ${errorMessage}`);
    
                // Always return a valid response, never throw
                return {
                    content: [{ type: "text", text: `Error fetching RSS feed: ${errorMessage}` }],
                    isError: true
                };
            }
        }
    );
  • TypeScript interfaces defining the structure of RSS feed and items returned by get_feed.
    interface RssFeed {
        title?: string;
        link?: string;
        description?: string;
        items: RssItem[];
    }
    
    interface RssItem {
        title?: string;
        description?: string;
        link?: string;
        guid?: string;
        pubDate?: string;
        author?: string;
        category?: string[];
    }
  • Helper utility to expand RSSHub 'rsshub://' URLs or existing prefixed URLs into lists of full URLs across multiple RSSHub instances for fallback.
    function convertRsshubUrl(url: string): string[] {
        if (url.startsWith('rsshub://')) {
            const path = url.substring(9);
            return RSSHUB_INSTANCES.map(instance => `${instance}/${path}`);
        }
    
        for (const instance of RSSHUB_INSTANCES) {
            if (url.startsWith(instance)) {
                const path = url.substring(instance.length).replace(/^\//, '');
                return RSSHUB_INSTANCES.map(inst => `${inst}/${path}`);
            }
        }
    
        return [url];
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool does (fetch RSS feeds) but doesn't describe key behaviors like error handling (e.g., invalid URLs, network failures), rate limits, authentication needs, or output format. For a tool with no annotations, this leaves significant gaps in understanding how it operates.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence: 'Get RSS feed from any URL, including RSSHub feeds.' It is front-loaded with the core purpose and includes essential context without unnecessary words. Every part of the sentence earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (fetching external feeds), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., feed data format, error responses) or behavioral aspects like performance or limitations. For a tool with no structured data beyond the input schema, more context is needed to be fully helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'url' parameter well-documented in the schema itself (including RSSHub protocol examples). The description adds minimal value beyond the schema by reiterating support for RSSHub feeds but doesn't provide additional syntax, format details, or constraints. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get RSS feed from any URL, including RSSHub feeds.' It specifies the verb ('Get') and resource ('RSS feed'), and mentions support for RSSHub feeds, which adds specificity. However, since there are no sibling tools, it doesn't need to distinguish from alternatives, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by mentioning 'any URL' and 'including RSSHub feeds,' which suggests it's versatile for fetching RSS feeds broadly. However, it lacks explicit guidance on when to use this tool versus alternatives (e.g., other feed parsers or APIs), and there are no exclusions or prerequisites stated. With no sibling tools, this is adequate but not comprehensive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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