list_projects
Retrieve all Azure DevOps projects in an organization with filtering options for state, pagination, and continuation tokens to manage large project lists.
Instructions
List all projects in an organization
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organizationId | No | The ID or name of the organization (Default: mycompany) | |
| 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 | |
| skip | No | Number of projects to skip | |
| continuationToken | No | Gets the projects after the continuation token provided |
Implementation Reference
- The core handler function that lists Azure DevOps projects using the Core API, handling options and errors.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 for validating input parameters to 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 for the list_projects tool.name: 'list_projects', description: 'List all projects in an organization', inputSchema: zodToJsonSchema(ListProjectsSchema), },
- src/features/projects/index.ts:50-61 (registration)Request handler dispatch case that parses arguments with schema and calls 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) }], }; }