Skip to main content
Glama

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
NameRequiredDescriptionDefault
productIdYesProduct ID (required)
activeOnlyNoIf true, only active count is returned

Implementation Reference

  • 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),
          },
        ],
      };
    }
  • 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,
      },
    },
  • 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,
    },
  • 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 };
    }

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/Valiant-Cat/zentao-mcp-server'

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