list_projects
Retrieve a list of projects from CODING DevOps based on user permissions, optionally filtered by project name, using the MCP interface to manage and organize resources efficiently.
Instructions
查询当前用户在 CODING DevOps 中的项目列表
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectName | No | 项目名称,支持模糊匹配 |
Implementation Reference
- src/tools/project/list.ts:6-36 (handler)The core handler function for the 'list_projects' tool. It initializes the CodingConnection, retrieves projects (optionally filtered by name), formats them into a markdown list, and returns as MCP content. Handles errors appropriately.export async function listProjects(args: Record<string, unknown> | undefined, config: CodingDevOpsConfig) { CodingConnection.initialize(config); const connection = CodingConnection.getInstance(); try { const projectName = args?.projectName as string | undefined; const projects = await connection.listProjects(projectName); return { content: [ { type: 'text', text: `**Projects**\n${ projects.map(project => `- **${project.Name}** (${project.DisplayName || 'No display name'}) - ID: ${project.Id || 'N/A'} - Description: ${project.Description || 'No description provided'}\n` ).join('\n') }`, }, ], }; } catch (error: unknown) { if (error instanceof McpError) throw error; const errorMessage = error instanceof Error ? error.message : 'Unknown error'; throw new McpError( ErrorCode.InternalError, `Failed to list projects: ${errorMessage}` ); } }
- src/tools/project/index.ts:22-35 (schema)The tool definition object in the definitions array, specifying the name, description, and input schema (optional projectName string) for 'list_projects'.{ name: 'list_projects', description: '查询当前用户在 CODING DevOps 中的项目列表', inputSchema: { type: 'object', properties: { projectName: { type: 'string', description: '项目名称,支持模糊匹配' } }, required: [], } },
- src/tools/project/index.ts:70-73 (schema)TypeScript interface defining the input arguments for listProjects, with optional projectName.export interface ListProjectsArgs { projectName?: string; [key: string]: unknown; }
- src/tools/project/index.ts:87-95 (registration)The projectTools export providing an initialize function that binds the listProjects handler (imported from ./list.js) with config, and exposes the tool definitions for registration.export const projectTools = { initialize: (config: CodingDevOpsConfig) => ({ listProjects: (args: ListProjectsArgs) => listProjects(args, config), createProject: (args: CreateProjectArgs) => createProject(args, config), deleteProject: (args: DeleteProjectArgs) => deleteProject(args, config), definitions, }), definitions, };
- src/index.ts:108-110 (registration)In the main MCP server tool dispatch switch statement, the case for 'list_projects' that invokes the bound project.listProjects handler.case 'list_projects': result = await tools.project.listProjects(request.params.arguments); break;