listMyProjects
Retrieve projects from ZenTao where you're involved as PM, PO, QD, RD, or team member. Filter by name keyword and set item limits.
Instructions
List projects related to the current account (PM/PO/QD/RD/assigned/team).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keyword | No | Filter by project name keyword | |
| limit | No | Max items |
Implementation Reference
- src/zentao-mcp-server.js:415-426 (registration)Registration of the 'listMyProjects' tool in the ListToolsRequestSchema response, including name, description, and input schema.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, }, },
- src/zentao-mcp-server.js:577-588 (handler)Tool handler in CallToolRequestSchema: extracts arguments, calls listProjectsForAccount, and returns JSON response.if (name === "listMyProjects") { const { keyword, limit } = args; const projects = await listProjectsForAccount({ keyword, limit }); return { content: [ { type: "text", text: JSON.stringify({ projects }, null, 2), }, ], }; }
- src/zentao-mcp-server.js:180-208 (handler)Main implementation logic: fetches projects via API, filters by keyword and current account involvement (roles/team), limits results.async function listProjectsForAccount({ keyword, limit = 50 } = {}) { const res = await callZenTao({ path: "projects", query: { page: 1, limit }, }); const projects = extractArray(res.data, ["projects"]); const accountLower = (account || "").trim().toLowerCase(); const filtered = projects.filter((p) => { const name = `${p.name || ""}`.toLowerCase(); const matchKeyword = keyword ? name.includes(keyword.toLowerCase()) : true; if (!accountLower) return matchKeyword; const fields = [ p.PM, p.PO, p.QD, p.RD, p.openedBy, p.lastEditedBy, p.assignedTo, ] .filter(Boolean) .map((v) => `${v}`.toLowerCase()); const team = Array.isArray(p.teamMembers) ? p.teamMembers : []; const teamMatch = team.some((m) => `${m.account || m.name || ""}`.toLowerCase() === accountLower); const fieldMatch = fields.includes(accountLower); return matchKeyword && (teamMatch || fieldMatch); }); return filtered.slice(0, limit); }
- src/zentao-mcp-server.js:79-111 (helper)Helper function used by listProjectsForAccount to make authenticated API calls to ZenTao.async function callZenTao({ path, method = "GET", query, body, headers = {}, forceTokenRefresh = false, }) { assertConfig(); const token = await fetchToken(forceTokenRefresh); const url = buildUrl(path, query); const res = await fetch(url, { method, headers: { "Content-Type": "application/json", Token: token, ...headers, }, body: body ? JSON.stringify(body) : undefined, }); const text = await res.text(); const data = safeJson(text); if (!res.ok) { throw new Error( `Request failed ${res.status}: ${text || res.statusText || "unknown"}` ); } return { status: res.status, headers: Object.fromEntries(res.headers.entries()), data: data ?? text, }; }
- src/zentao-mcp-server.js:134-142 (helper)Helper to extract array from API response (handles various nesting). Used in listProjectsForAccount.function extractArray(payload, keys = []) { if (Array.isArray(payload)) return payload; for (const key of keys) { if (Array.isArray(payload?.[key])) return payload[key]; } if (Array.isArray(payload?.data)) return payload.data; return []; }