Skip to main content
Glama

get_issue_statistics

Analyze Mantis bug tracking data by grouping issues based on status, priority, severity, handler, or reporter. Use project ID and time range filters for detailed insights.

Instructions

獲取 Mantis 問題統計數據,根據不同維度進行分析

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
groupByYes分組依據
periodNo時間範圍<all-全部, today-今天, week-本週, month-本月>all
projectIdNo專案 ID

Implementation Reference

  • src/server.ts:200-291 (registration)
    Registration of the 'get_issue_statistics' tool using server.tool(), including schema and inline handler implementation.
    server.tool(
      "get_issue_statistics",
      "獲取 Mantis 問題統計數據,根據不同維度進行分析",
      {
        projectId: z.number().optional().describe("專案 ID"),
        groupBy: z.enum(['status', 'priority', 'severity', 'handler', 'reporter']).describe("分組依據"),
        period: z.enum(['all', 'today', 'week', 'month']).default('all').describe("時間範圍<all-全部, today-今天, week-本週, month-本月>"),
      },
      async (params) => {
        return withMantisConfigured("get_issue_statistics", async () => {
          // 從 Mantis API 獲取問題並處理統計
          const issues = await mantisApi.getIssues({
            projectId: params.projectId,
            pageSize: 1000 // 獲取大量數據用於統計
          });
    
          // 建立統計結果
          const statistics = {
            total: issues.length,
            groupedBy: params.groupBy,
            period: params.period,
            data: {} as Record<string, number>
          };
    
          // 根據時間範圍過濾
          let filteredIssues = issues;
          log.debug("根據時間範圍過濾issues", { issues, params });
          
          const now = new Date();
          const startOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate());
          const startOfWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - now.getDay());
          const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
    
          switch (params.period) {
            case 'today':
              filteredIssues = issues.filter(issue => {
                const createdAt = new Date(issue.created_at);
                return createdAt >= startOfDay;
              });
              break;
            case 'week':
              filteredIssues = issues.filter(issue => {
                const createdAt = new Date(issue.created_at);
                return createdAt >= startOfWeek;
              });
              break;
            case 'month':
              filteredIssues = issues.filter(issue => {
                const createdAt = new Date(issue.created_at);
                return createdAt >= startOfMonth;
              });
              break;
            case 'all':
            default:
              // 保持原有的issues不變
              break;
          }
    
          if (!filteredIssues || filteredIssues.length === 0) {
            return { error: "沒有查詢到任何Issue" };
          }
    
          // 根據分組依據進行統計
          filteredIssues.forEach(issue => {
            let key = '';
    
            switch (params.groupBy) {
              case 'status':
                key = issue.status?.name || 'unknown';
                break;
              case 'priority':
                key = issue.priority?.name || 'unknown';
                break;
              case 'severity':
                key = issue.severity?.name || 'unknown';
                break;
              case 'handler':
                key = issue.handler?.name || 'unassigned';
                break;
              case 'reporter':
                key = issue.reporter?.name || 'unknown';
                break;
            }
    
            statistics.data[key] = (statistics.data[key] || 0) + 1;
          });
    
          return JSON.stringify(statistics, null, 2);
        });
      }
    );
  • Handler function that fetches issues using mantisApi.getIssues, filters by period, groups by specified field (status, priority, etc.), and returns JSON statistics.
      async (params) => {
        return withMantisConfigured("get_issue_statistics", async () => {
          // 從 Mantis API 獲取問題並處理統計
          const issues = await mantisApi.getIssues({
            projectId: params.projectId,
            pageSize: 1000 // 獲取大量數據用於統計
          });
    
          // 建立統計結果
          const statistics = {
            total: issues.length,
            groupedBy: params.groupBy,
            period: params.period,
            data: {} as Record<string, number>
          };
    
          // 根據時間範圍過濾
          let filteredIssues = issues;
          log.debug("根據時間範圍過濾issues", { issues, params });
          
          const now = new Date();
          const startOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate());
          const startOfWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - now.getDay());
          const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
    
          switch (params.period) {
            case 'today':
              filteredIssues = issues.filter(issue => {
                const createdAt = new Date(issue.created_at);
                return createdAt >= startOfDay;
              });
              break;
            case 'week':
              filteredIssues = issues.filter(issue => {
                const createdAt = new Date(issue.created_at);
                return createdAt >= startOfWeek;
              });
              break;
            case 'month':
              filteredIssues = issues.filter(issue => {
                const createdAt = new Date(issue.created_at);
                return createdAt >= startOfMonth;
              });
              break;
            case 'all':
            default:
              // 保持原有的issues不變
              break;
          }
    
          if (!filteredIssues || filteredIssues.length === 0) {
            return { error: "沒有查詢到任何Issue" };
          }
    
          // 根據分組依據進行統計
          filteredIssues.forEach(issue => {
            let key = '';
    
            switch (params.groupBy) {
              case 'status':
                key = issue.status?.name || 'unknown';
                break;
              case 'priority':
                key = issue.priority?.name || 'unknown';
                break;
              case 'severity':
                key = issue.severity?.name || 'unknown';
                break;
              case 'handler':
                key = issue.handler?.name || 'unassigned';
                break;
              case 'reporter':
                key = issue.reporter?.name || 'unknown';
                break;
            }
    
            statistics.data[key] = (statistics.data[key] || 0) + 1;
          });
    
          return JSON.stringify(statistics, null, 2);
        });
      }
    );
  • Zod input schema defining parameters for projectId (optional), groupBy (status/priority/etc.), period (all/today/week/month).
    {
      projectId: z.number().optional().describe("專案 ID"),
      groupBy: z.enum(['status', 'priority', 'severity', 'handler', 'reporter']).describe("分組依據"),
      period: z.enum(['all', 'today', 'week', 'month']).default('all').describe("時間範圍<all-全部, today-今天, week-本週, month-本月>"),
    },
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 the tool retrieves and analyzes statistics, implying a read-only operation, but doesn't clarify critical aspects like whether it requires authentication, handles pagination, returns aggregated data formats, or has rate limits. For a statistical tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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: '獲取 Mantis 問題統計數據,根據不同維度進行分析'. It is front-loaded with the core purpose and avoids redundancy. Every word contributes to understanding the tool's function, making it appropriately sized with zero waste.

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 (statistical analysis with 3 parameters) and lack of annotations and output schema, the description is incomplete. It doesn't explain what the output looks like (e.g., aggregated counts, charts), behavioral traits like error handling, or integration with sibling tools. For a tool that performs analysis, more context is needed to use it effectively.

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 schema description coverage is 100%, with all parameters well-documented in the input schema (e.g., 'groupBy' with enum values, 'period' with time ranges, 'projectId' as numeric). The description adds minimal value beyond the schema by mentioning '不同維度' (different dimensions), which loosely relates to 'groupBy', but doesn't provide additional syntax or format details. This meets the baseline for high schema coverage.

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: '獲取 Mantis 問題統計數據,根據不同維度進行分析' (Get Mantis issue statistics, analyze according to different dimensions). It specifies the verb ('獲取' - get) and resource ('Mantis 問題統計數據' - Mantis issue statistics), and mentions analysis by dimensions. However, it doesn't explicitly differentiate from sibling tools like 'get_assignment_statistics' or 'get_issues', which prevents a perfect score.

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 no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_assignment_statistics' for assignment-related stats or 'get_issues' for raw issue lists, nor does it specify prerequisites such as needing a project context. Usage is implied by the mention of '不同維度' (different dimensions), but this is too vague for effective tool selection.

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/kfnzero/mantis-mcp-server'

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