getBugStats
Retrieve bug statistics for a specific product in ZenTao, showing total and active bug counts assigned to you.
Instructions
Get counts of bugs assigned to me under a product (total and active).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| productId | Yes | Product ID (required) | |
| activeOnly | No | If true, only active count is returned |
Implementation Reference
- src/zentao-mcp-server.js:700-718 (handler)Main execution logic for the getBugStats tool: fetches bugs via helper, computes total and active counts, returns structured JSON.if (name === "getBugStats") { const { productId, activeOnly = false } = args; const { bugs } = await fetchBugsByProduct({ productId, allStatuses: !activeOnly, limit: 200, }); const total = bugs.length; const active = bugs.filter((b) => (b.status || b.state || "").toLowerCase() === "active") .length; return { content: [ { type: "text", text: JSON.stringify({ productId, total, active }, null, 2), }, ], }; }
- src/zentao-mcp-server.js:496-513 (registration)Tool registration in the MCP server's ListTools response, defining name, description, and input schema.{ name: "getBugStats", description: "Get counts of bugs assigned to me under a product (total and active).", inputSchema: { type: "object", properties: { productId: { type: "number", description: "Product ID (required)" }, activeOnly: { type: "boolean", description: "If true, only active count is returned", default: false, }, }, required: ["productId"], additionalProperties: false, }, },
- src/zentao-mcp-server.js:500-512 (schema)Input schema for validating getBugStats tool arguments: requires productId, optional activeOnly boolean.inputSchema: { type: "object", properties: { productId: { type: "number", description: "Product ID (required)" }, activeOnly: { type: "boolean", description: "If true, only active count is returned", default: false, }, }, required: ["productId"], additionalProperties: false, },
- src/zentao-mcp-server.js:235-280 (helper)Core helper function to fetch and filter bugs by product, assignee (current account), keyword, and status. Critical for getBugStats implementation.async function fetchBugsByProduct({ productId, keyword, allStatuses = false, status, limit = 20, page = 1, }) { const res = await callZenTao({ // Use /bugs with product filter; works better for assignedTo filtering. path: "bugs", query: { page, limit, product: productId, keywords: keyword, }, }); const bugs = extractArray(res.data, ["bugs"]); const accountLower = (account || "").trim().toLowerCase(); const statusLower = status ? String(status).trim().toLowerCase() : null; const filtered = bugs.filter((bug) => { const assignedCandidates = [ ...normalizeAccount(bug.assignedTo), ...normalizeAccount(bug.assignedToName), ...normalizeAccount(bug.assignedToRealname), ]; const matchAssignee = accountLower ? assignedCandidates.includes(accountLower) : true; const matchKeyword = keyword ? `${bug.title || bug.name || ""}` .toLowerCase() .includes(keyword.toLowerCase()) : true; const matchStatus = allStatuses ? true : statusLower ? String(bug.status || bug.state || "") .trim() .toLowerCase() === statusLower : true; return matchAssignee && matchKeyword && matchStatus; }); return { bugs: filtered, raw: res.data }; }