Skip to main content
Glama

get_assignment_statistics

Analyze bug assignment statistics in Mantis Bug Tracker to track user-specific issue distributions, filter by status, and include unassigned issues for comprehensive insights.

Instructions

獲取 Mantis 問題分派統計數據,分析不同用戶的問題分派情況

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeUnassignedNo是否包含未分派問題
projectIdNo專案 ID
statusFilterNo狀態過濾器,只計算特定狀態的問題

Implementation Reference

  • Handler function that implements the core logic of get_assignment_statistics: fetches issues, filters by status, gathers handler users, computes per-user statistics (total, open, closed issues), handles unassigned issues.
    async (params) => {
      return withMantisConfigured("get_assignment_statistics", async () => {
        // 獲取問題
        const issues = await mantisApi.getIssues({
          projectId: params.projectId,
          pageSize: 1000 // 獲取大量數據用於統計
        });
    
        // 過濾問題
        let filteredIssues = issues;
        if (params.statusFilter?.length) {
          filteredIssues = issues.filter(issue =>
            params.statusFilter?.includes(issue.status.id)
          );
        }
    
        // 建立用戶問題統計
        const userMap = new Map<number, {
          id: number;
          name: string;
          email: string;
          issueCount: number;
          openIssues: number;
          closedIssues: number;
          issues: number[];
        }>();
    
        // 從問題中收集所有處理人ID
        const handlerIds = new Set<number>();
        filteredIssues.forEach(issue => {
          if (issue.handler?.id) {
            handlerIds.add(issue.handler.id);
          }
        });
    
        // 查詢每個處理人的詳細資訊並初始化統計
        for (const handlerId of handlerIds) {
          const user = await mantisApi.getUser(handlerId);
          userMap.set(user.id, {
            id: user.id,
            name: user.name,
            email: user.email || '',
            issueCount: 0,
            openIssues: 0,
            closedIssues: 0,
            issues: []
          });
        }
    
        // 未分派問題統計
        let unassignedCount = 0;
        let unassignedIssues: number[] = [];
    
        // 計算統計
        filteredIssues.forEach(issue => {
          if (issue.handler && issue.handler.id) {
            const userStat = userMap.get(issue.handler.id);
            if (userStat) {
              userStat.issueCount++;
              userStat.issues.push(issue.id);
    
              // 根據狀態判斷是否為關閉狀態
              if (issue.status.name.toLowerCase().includes('closed') ||
                issue.status.name.toLowerCase().includes('resolved')) {
                userStat.closedIssues++;
              } else {
                userStat.openIssues++;
              }
            }
          } else if (params.includeUnassigned) {
            unassignedCount++;
            unassignedIssues.push(issue.id);
          }
        });
    
        // 構建結果
        const statistics = {
          totalIssues: filteredIssues.length,
          assignedIssues: filteredIssues.length - unassignedCount,
          unassignedIssues: unassignedCount,
          userStatistics: Array.from(userMap.values())
            .filter(stat => stat.issueCount > 0)
            .sort((a, b) => b.issueCount - a.issueCount)
        };
    
        if (params.includeUnassigned && unassignedCount > 0) {
          statistics.userStatistics.push({
            id: 0,
            name: "未分派",
            email: "",
            issueCount: unassignedCount,
            openIssues: unassignedCount,
            closedIssues: 0,
            issues: unassignedIssues
          });
        }
    
        return JSON.stringify(statistics, null, 2);
      });
    }
  • Zod schema defining input parameters for the get_assignment_statistics tool.
    {
      projectId: z.number().optional().describe("專案 ID"),
      includeUnassigned: z.boolean().default(true).describe("是否包含未分派問題"),
      statusFilter: z.array(z.number()).optional().describe("狀態過濾器,只計算特定狀態的問題"),
    },
  • src/server.ts:293-401 (registration)
    Registration of the get_assignment_statistics tool on the MCP server.
    server.tool(
      "get_assignment_statistics",
      "獲取 Mantis 問題分派統計數據,分析不同用戶的問題分派情況",
      {
        projectId: z.number().optional().describe("專案 ID"),
        includeUnassigned: z.boolean().default(true).describe("是否包含未分派問題"),
        statusFilter: z.array(z.number()).optional().describe("狀態過濾器,只計算特定狀態的問題"),
      },
      async (params) => {
        return withMantisConfigured("get_assignment_statistics", async () => {
          // 獲取問題
          const issues = await mantisApi.getIssues({
            projectId: params.projectId,
            pageSize: 1000 // 獲取大量數據用於統計
          });
    
          // 過濾問題
          let filteredIssues = issues;
          if (params.statusFilter?.length) {
            filteredIssues = issues.filter(issue =>
              params.statusFilter?.includes(issue.status.id)
            );
          }
    
          // 建立用戶問題統計
          const userMap = new Map<number, {
            id: number;
            name: string;
            email: string;
            issueCount: number;
            openIssues: number;
            closedIssues: number;
            issues: number[];
          }>();
    
          // 從問題中收集所有處理人ID
          const handlerIds = new Set<number>();
          filteredIssues.forEach(issue => {
            if (issue.handler?.id) {
              handlerIds.add(issue.handler.id);
            }
          });
    
          // 查詢每個處理人的詳細資訊並初始化統計
          for (const handlerId of handlerIds) {
            const user = await mantisApi.getUser(handlerId);
            userMap.set(user.id, {
              id: user.id,
              name: user.name,
              email: user.email || '',
              issueCount: 0,
              openIssues: 0,
              closedIssues: 0,
              issues: []
            });
          }
    
          // 未分派問題統計
          let unassignedCount = 0;
          let unassignedIssues: number[] = [];
    
          // 計算統計
          filteredIssues.forEach(issue => {
            if (issue.handler && issue.handler.id) {
              const userStat = userMap.get(issue.handler.id);
              if (userStat) {
                userStat.issueCount++;
                userStat.issues.push(issue.id);
    
                // 根據狀態判斷是否為關閉狀態
                if (issue.status.name.toLowerCase().includes('closed') ||
                  issue.status.name.toLowerCase().includes('resolved')) {
                  userStat.closedIssues++;
                } else {
                  userStat.openIssues++;
                }
              }
            } else if (params.includeUnassigned) {
              unassignedCount++;
              unassignedIssues.push(issue.id);
            }
          });
    
          // 構建結果
          const statistics = {
            totalIssues: filteredIssues.length,
            assignedIssues: filteredIssues.length - unassignedCount,
            unassignedIssues: unassignedCount,
            userStatistics: Array.from(userMap.values())
              .filter(stat => stat.issueCount > 0)
              .sort((a, b) => b.issueCount - a.issueCount)
          };
    
          if (params.includeUnassigned && unassignedCount > 0) {
            statistics.userStatistics.push({
              id: 0,
              name: "未分派",
              email: "",
              issueCount: unassignedCount,
              openIssues: unassignedCount,
              closedIssues: 0,
              issues: unassignedIssues
            });
          }
    
          return JSON.stringify(statistics, null, 2);
        });
      }
    );
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. While it indicates this is a read operation ('獲取' - get), it doesn't describe what the statistics look like, whether there are rate limits, authentication requirements, or what format the analysis takes. For a statistics tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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 concise and efficient - a single sentence that states the tool's purpose clearly. There's no wasted language or unnecessary elaboration. While it could be more comprehensive, what's present is well-structured and front-loaded with the essential 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?

For a statistics tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the statistics output looks like, what metrics are included, or how the 'analysis' mentioned is presented. With three parameters and statistical output expected, more context about the return format and analysis methodology would be needed for proper tool selection and use.

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 description provides no parameter information beyond what's already in the schema. However, with 100% schema description coverage and clear parameter descriptions in Chinese, the schema already documents all three parameters adequately. The baseline score of 3 is appropriate when the schema does the heavy lifting, even though the description adds no additional parameter context.

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 assignment statistics, analyze issue assignment situations for different users). It specifies the verb ('獲取' - get), resource ('Mantis 問題分派統計數據' - Mantis issue assignment statistics), and analysis focus. However, it doesn't explicitly distinguish this tool from sibling tools like 'get_issue_statistics' or 'get_issues', which reduces clarity about when to use this specific tool.

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. With sibling tools like 'get_issue_statistics' and 'get_issues' available, there's no indication of what makes this tool distinct or when it should be preferred over those alternatives. The description mentions analyzing assignment situations, but doesn't specify use cases or exclusions.

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