list_projects
Retrieve all projects in an Azure DevOps organization with flexible filtering options, including state, pagination, and maximum results, to manage and organize project data efficiently.
Instructions
List all projects in an organization
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| continuationToken | No | Gets the projects after the continuation token provided | |
| skip | No | Number of projects to skip | |
| stateFilter | No | Filter on team project state (0: all, 1: well-formed, 2: creating, 3: deleting, 4: new) | |
| top | No | Maximum number of projects to return |
Implementation Reference
- The core handler function that lists Azure DevOps projects using the Core API's getProjects method.export async function listProjects( connection: WebApi, options: ListProjectsOptions = {}, ): Promise<TeamProject[]> { try { const coreApi = await connection.getCoreApi(); const projects = await coreApi.getProjects( options.stateFilter, options.top, options.skip, options.continuationToken, ); return projects; } catch (error) { if (error instanceof AzureDevOpsError) { throw error; } throw new Error( `Failed to list projects: ${error instanceof Error ? error.message : String(error)}`, ); } }
- Zod schema defining the input parameters for the list_projects tool.export const ListProjectsSchema = z.object({ organizationId: z .string() .optional() .describe(`The ID or name of the organization (Default: ${defaultOrg})`), stateFilter: z .number() .optional() .describe( 'Filter on team project state (0: all, 1: well-formed, 2: creating, 3: deleting, 4: new)', ), top: z.number().optional().describe('Maximum number of projects to return'), skip: z.number().optional().describe('Number of projects to skip'), continuationToken: z .number() .optional() .describe('Gets the projects after the continuation token provided'), });
- src/features/projects/tool-definitions.ts:14-17 (registration)Tool definition registration including name, description, and input schema reference.name: 'list_projects', description: 'List all projects in an organization', inputSchema: zodToJsonSchema(ListProjectsSchema), },
- src/features/projects/index.ts:50-61 (registration)Request handler dispatcher that parses arguments and invokes the listProjects handler.case 'list_projects': { const args = ListProjectsSchema.parse(request.params.arguments); const result = await listProjects(connection, { stateFilter: args.stateFilter, top: args.top, skip: args.skip, continuationToken: args.continuationToken, }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }