getMyBug
Retrieve your first active bug assigned in a ZenTao product to address issues promptly. Filter by product name, keyword, or status for targeted bug management.
Instructions
Get the first active bug assigned to me in a product (by productName). Returns full bug detail.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| productName | Yes | Product name to match (required) | |
| keyword | No | Keyword filter on bug title | |
| status | No | Status filter (e.g., active) | |
| allStatuses | No | Include non-active bugs |
Implementation Reference
- src/zentao-mcp-server.js:603-644 (handler)Handler function for the 'getMyBug' tool. Finds a product by name, retrieves the first active bug assigned to the current account in that product, fetches detailed bug information including extracted image URLs from steps HTML, and returns JSON with product and bug details.if (name === "getMyBug") { const { productName, keyword, status, allStatuses = false } = args; const { product, matches } = await findProductByName(productName); if (!product) { const names = matches.map((p) => `${p.id}:${p.name}`).join(", "); throw new Error( matches.length === 0 ? `No product matched "${productName}"` : `Multiple products matched "${productName}", please specify one of: ${names}` ); } const { bugs } = await fetchBugsByProduct({ productId: product.id, keyword, status, allStatuses, limit: 1, }); if (!bugs.length) { return { content: [ { type: "text", text: `No active bugs assigned to ${account || "me"} in product "${product.name}"`, }, ], }; } const bugDetail = await getBugWithImages(bugs[0].id || bugs[0].bugId); return { content: [ { type: "text", text: JSON.stringify( { product: { id: product.id, name: product.name }, bug: bugDetail }, null, 2 ), }, ], }; }
- src/zentao-mcp-server.js:440-459 (schema)Schema definition for the 'getMyBug' tool, including input schema with required 'productName' and optional parameters for filtering bugs.{ name: "getMyBug", description: "Get the first active bug assigned to me in a product (by productName). Returns full bug detail.", inputSchema: { type: "object", properties: { productName: { type: "string", description: "Product name to match (required)" }, keyword: { type: "string", description: "Keyword filter on bug title" }, status: { type: "string", description: "Status filter (e.g., active)" }, allStatuses: { type: "boolean", description: "Include non-active bugs", default: false, }, }, required: ["productName"], additionalProperties: false, }, },
- src/zentao-mcp-server.js:375-541 (registration)Registration of the 'getMyBug' tool in the list of available tools returned by ListToolsRequestSchema handler.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: "get_token", description: "Fetch a token via POST /tokens using env ZENTAO_ACCOUNT/PASSWORD. Caches in-memory.", inputSchema: { type: "object", properties: { forceRefresh: { type: "boolean", description: "Ignore cached token" }, }, required: [], additionalProperties: false, }, }, { name: "call", description: "Call any ZenTao RESTful API endpoint (api.php/v1). Automatically injects Token header. Paths accept leading slash or relative.", inputSchema: { type: "object", properties: { path: { type: "string", description: "Relative path, e.g. /projects or projects/1" }, method: { type: "string", description: "HTTP verb", enum: ["GET", "POST", "PUT", "PATCH", "DELETE"], default: "GET", }, query: { type: "object", description: "Query params object", additionalProperties: true }, body: { type: "object", description: "JSON body", additionalProperties: true }, forceTokenRefresh: { type: "boolean", description: "Refresh token before request", }, }, required: ["path"], additionalProperties: false, }, }, { name: "listMyProjects", description: "List projects related to the current account (PM/PO/QD/RD/assigned/team).", inputSchema: { type: "object", properties: { keyword: { type: "string", description: "Filter by project name keyword" }, limit: { type: "number", description: "Max items", default: 50 }, }, required: [], additionalProperties: false, }, }, { name: "searchProducts", description: "Search products by keyword; returns a short list of products.", inputSchema: { type: "object", properties: { keyword: { type: "string", description: "Keyword to match product name" }, limit: { type: "number", description: "Max items", default: 20 }, }, required: [], additionalProperties: false, }, }, { name: "getMyBug", description: "Get the first active bug assigned to me in a product (by productName). Returns full bug detail.", inputSchema: { type: "object", properties: { productName: { type: "string", description: "Product name to match (required)" }, keyword: { type: "string", description: "Keyword filter on bug title" }, status: { type: "string", description: "Status filter (e.g., active)" }, allStatuses: { type: "boolean", description: "Include non-active bugs", default: false, }, }, required: ["productName"], additionalProperties: false, }, }, { name: "getMyBugs", description: "List bugs assigned to me under a product. Defaults to active bugs only.", inputSchema: { type: "object", properties: { productId: { type: "number", description: "Product ID (required)" }, keyword: { type: "string", description: "Keyword filter on bug title" }, status: { type: "string", description: "Status filter (e.g., active)" }, allStatuses: { type: "boolean", description: "Include non-active bugs", default: false, }, limit: { type: "number", description: "Max items", default: 20 }, }, required: ["productId"], additionalProperties: false, }, }, { name: "getNextBug", description: "Get the next active bug assigned to me under a product (first match).", inputSchema: { type: "object", properties: { productId: { type: "number", description: "Product ID (required)" }, keyword: { type: "string", description: "Keyword filter on bug title" }, status: { type: "string", description: "Status filter (e.g., active)" }, }, required: ["productId"], additionalProperties: false, }, }, { 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, }, }, { name: "getBugDetail", description: "Get bug detail by ID; also extracts image URLs from steps HTML into stepsImages.", inputSchema: { type: "object", properties: { bugId: { type: "number", description: "Bug ID (required)" }, }, required: ["bugId"], additionalProperties: false, }, }, { name: "markBugResolved", description: "Mark a bug as resolved (resolution=fixed).", inputSchema: { type: "object", properties: { bugId: { type: "number", description: "Bug ID (required)" }, comment: { type: "string", description: "Resolution comment" }, }, required: ["bugId"], additionalProperties: false, }, }, ], }));
- src/zentao-mcp-server.js:282-288 (helper)Helper function to fetch bug details and extract image URLs from steps HTML, used in getMyBug handler.async function getBugWithImages(bugId) { const res = await callZenTao({ path: `bugs/${bugId}` }); const bug = res.data || {}; const stepsHtml = bug.steps || bug.stepsHtml || ""; const stepsImages = parseImageSources(stepsHtml); return { ...bug, stepsHtml, stepsImages }; }
- src/zentao-mcp-server.js:235-280 (helper)Core helper to fetch and filter bugs assigned to the current account in a product, used by getMyBug.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 }; }