list_projects
Retrieve all accessible PingCode projects with identifiers and names to manage work items, releases, bugs, and requirements through AI assistants.
Instructions
列出用户可访问的所有项目。返回项目标识和名称列表。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/work-items.ts:662-700 (handler)The core handler function for the 'list_projects' tool. It fetches all accessible projects via pingcodeClient.getProjects(), formats them into a markdown bullet list with project identifiers and names, and returns structured success/data/error.export async function listProjects(): Promise<{ success: boolean; data?: string; error?: string; }> { try { const projects = await pingcodeClient.getProjects(); if (projects.length === 0) { return { success: true, data: '没有可访问的项目', }; } const lines: string[] = [ '# 项目列表', '', `共 ${projects.length} 个项目`, '', ]; projects.forEach((project: any) => { const identifier = project.identifier || project._id; const name = project.name || '未命名'; lines.push(`- **${identifier}** - ${name}`); }); return { success: true, data: lines.join('\n'), }; } catch (error: any) { return { success: false, error: error.message, }; } }
- src/index.ts:129-137 (registration)Tool registration in the MCP ListTools response. Defines the tool name, description, and input schema (no parameters required).{ name: 'list_projects', description: '列出用户可访问的所有项目。返回项目标识和名称列表。', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/index.ts:285-296 (handler)Dispatch handler in the MCP CallToolRequest handler that invokes the listProjects function and formats the response as MCP content.case 'list_projects': { const result = await listProjects(); return { content: [ { type: 'text', text: result.success ? result.data! : `错误: ${result.error}`, }, ], isError: !result.success, }; }
- src/index.ts:132-136 (schema)Input schema definition for the list_projects tool (empty object, no required parameters).inputSchema: { type: 'object', properties: {}, required: [], },