Skip to main content
Glama

generate_daily_report

Generate automated daily reports from Tiny Tiny RSS feeds by summarizing recent articles, grouping them by category and source, with options to filter by time range and view mode.

Instructions

生成日报:汇总近期文章,按分类和订阅源分组输出。默认获取未读文章,可指定时间范围。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hoursNo获取最近 N 小时内的文章,默认 24
limitNo最多获取的文章数量
view_modeNo过滤模式all_articles
include_contentNo是否包含文章摘要

Implementation Reference

  • The handler function for the `generate_daily_report` tool, which fetches headlines, filters them, and formats a report.
    async (params) => {
      try {
        const cutoffTime = Math.floor(Date.now() / 1000) - params.hours * 3600;
    
        const headlines = await client.getHeadlines({
          feed_id: -4,
          limit: params.limit,
          view_mode: params.view_mode,
          show_excerpt: params.include_content,
          order_by: "feed_dates",
        });
    
        const filtered = headlines.filter((h) => h.updated >= cutoffTime);
    
        if (filtered.length === 0) {
          return {
            content: [{
              type: "text" as const,
              text: `过去 ${params.hours} 小时内没有${params.view_mode === "unread" ? "未读" : ""}文章。`,
            }],
          };
        }
    
        const grouped = groupByFeed(filtered);
        const report = formatReport(grouped, params.hours, params.include_content);
        return { content: [{ type: "text" as const, text: report }] };
      } catch (e: unknown) {
        return {
          content: [{ type: "text" as const, text: `生成日报失败: ${(e as Error).message}` }],
          isError: true,
        };
      }
    },
  • Registration of the `generate_daily_report` tool using `server.tool`.
    server.tool(
      "generate_daily_report",
      "生成日报:汇总近期文章,按分类和订阅源分组输出。默认获取未读文章,可指定时间范围。",
      {
        hours: z.number().default(24).describe("获取最近 N 小时内的文章,默认 24"),
        limit: z.number().default(200).describe("最多获取的文章数量"),
        view_mode: z
          .enum(["all_articles", "unread", "adaptive", "marked", "updated"])
          .default("all_articles")
          .describe("过滤模式"),
        include_content: z.boolean().default(false).describe("是否包含文章摘要"),
      },
      async (params) => {
        try {
          const cutoffTime = Math.floor(Date.now() / 1000) - params.hours * 3600;
    
          const headlines = await client.getHeadlines({
            feed_id: -4,
            limit: params.limit,
            view_mode: params.view_mode,
            show_excerpt: params.include_content,
            order_by: "feed_dates",
          });
    
          const filtered = headlines.filter((h) => h.updated >= cutoffTime);
    
          if (filtered.length === 0) {
            return {
              content: [{
                type: "text" as const,
                text: `过去 ${params.hours} 小时内没有${params.view_mode === "unread" ? "未读" : ""}文章。`,
              }],
            };
          }
    
          const grouped = groupByFeed(filtered);
          const report = formatReport(grouped, params.hours, params.include_content);
          return { content: [{ type: "text" as const, text: report }] };
        } catch (e: unknown) {
          return {
            content: [{ type: "text" as const, text: `生成日报失败: ${(e as Error).message}` }],
            isError: true,
          };
        }
      },
    );
  • Zod schema definition for the `generate_daily_report` tool inputs.
    {
      hours: z.number().default(24).describe("获取最近 N 小时内的文章,默认 24"),
      limit: z.number().default(200).describe("最多获取的文章数量"),
      view_mode: z
        .enum(["all_articles", "unread", "adaptive", "marked", "updated"])
        .default("all_articles")
        .describe("过滤模式"),
      include_content: z.boolean().default(false).describe("是否包含文章摘要"),
    },
  • Helper functions for grouping articles and formatting the final report string.
    interface GroupedArticles {
      [feedTitle: string]: TtrssHeadline[];
    }
    
    function groupByFeed(headlines: TtrssHeadline[]): GroupedArticles {
      const groups: GroupedArticles = {};
      for (const h of headlines) {
        const key = h.feed_title || "未知来源";
        if (!groups[key]) groups[key] = [];
        groups[key].push(h);
      }
      return groups;
    }
    
    function formatReport(
      grouped: GroupedArticles,
      hours: number,
      includeContent: boolean,
    ): string {
      const totalArticles = Object.values(grouped).reduce(
        (sum, arr) => sum + arr.length,
        0,
      );
      const feedCount = Object.keys(grouped).length;
    
      const lines: string[] = [
        `# 日报 (过去 ${hours} 小时)`,
        "",
        `共 ${totalArticles} 篇文章,来自 ${feedCount} 个订阅源。`,
        "",
      ];
    
      const sortedFeeds = Object.entries(grouped).sort(
        ([, a], [, b]) => b.length - a.length,
      );
    
      for (const [feedTitle, articles] of sortedFeeds) {
        lines.push(`## ${feedTitle} (${articles.length} 篇)`);
        lines.push("");
    
        const sorted = articles.sort((a, b) => b.updated - a.updated);
    
        for (const article of sorted) {
          const time = new Date(article.updated * 1000).toLocaleString("zh-CN", {
            timeZone: "Asia/Shanghai",
            month: "2-digit",
            day: "2-digit",
            hour: "2-digit",
            minute: "2-digit",
          });
          const flags = [
            article.unread ? "未读" : "",
            article.marked ? "⭐" : "",
          ]
            .filter(Boolean)
            .join(" ");
    
          lines.push(
            `- [${article.title}](${article.link}) | ${time}${flags ? " | " + flags : ""}`,
          );
    
          if (includeContent && article.excerpt) {
            lines.push(`  > ${article.excerpt.slice(0, 150).replace(/\n/g, " ")}`);
          }
        }
        lines.push("");
      }
    
      return lines.join("\n");
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the default behavior (fetches unread articles) and that time range can be specified, but doesn't describe important traits like whether this is a read-only operation, what the output format looks like (grouped by category/feed), potential rate limits, or any side effects. For a tool with 4 parameters and no annotations, this leaves significant gaps in understanding how it behaves.

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

Conciseness4/5

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

The description is appropriately concise with two sentences that efficiently convey the core functionality. The first sentence states the main purpose, the second adds key behavioral details. No wasted words or redundant information. However, it could be slightly more front-loaded with the most critical information.

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 (4 parameters, no annotations, no output schema), the description is insufficiently complete. It doesn't explain the output format (how articles are grouped by category/feed), doesn't mention whether this is a read-only operation, and provides minimal guidance on when to use it versus sibling tools. For a report generation tool with multiple parameters, more contextual information would be helpful for an AI agent.

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?

Schema description coverage is 100%, so the schema already documents all 4 parameters thoroughly. The description adds minimal value beyond the schema: it implies time range filtering ('可指定时间范围' - time range can be specified) which relates to the 'hours' parameter, and mentions default unread article fetching which relates to 'view_mode'. However, it doesn't provide additional semantic context beyond what's already in the parameter descriptions.

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: '生成日报:汇总近期文章,按分类和订阅源分组输出' (Generate daily report: summarize recent articles, grouped by category and feed). It specifies the verb ('生成' - generate) and resource ('日报' - daily report) with details about grouping. However, it doesn't explicitly distinguish this from sibling tools like 'search_articles' or 'get_headlines' which might also retrieve articles.

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

Usage Guidelines2/5

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

The description provides minimal usage guidance: '默认获取未读文章,可指定时间范围' (By default fetches unread articles, time range can be specified). It mentions the default behavior but doesn't explain when to use this tool versus alternatives like 'search_articles' for specific queries or 'get_headlines' for simpler listings. No explicit when-not-to-use guidance or comparison with siblings is provided.

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

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/aooiuu/ttrss-mcp'

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