core_list_projects
List Azure DevOps projects by state, name, or pagination parameters using PAT authentication. Customize results with filters for project name, state, and pagination.
Instructions
Retrieve a list of projects in your Azure DevOps organization.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| continuationToken | No | Continuation token for pagination. Used to fetch the next set of results if available. | |
| projectNameFilter | No | Filter projects by name. Supports partial matches. | |
| skip | No | The number of projects to skip for pagination. Defaults to 0. | |
| stateFilter | No | Filter projects by their state. Defaults to 'wellFormed'. | wellFormed |
| top | No | The maximum number of projects to return. Defaults to 100. |
Implementation Reference
- src/tools/core.ts:68-91 (handler)Handler function that fetches projects from the Azure DevOps organization using the Core API, applies optional filtering and pagination, and returns the results as JSON or an error message.async ({ stateFilter, top, skip, continuationToken, projectNameFilter }) => { try { const connection = await connectionProvider(); const coreApi = await connection.getCoreApi(); const projects = await coreApi.getProjects(stateFilter, top, skip, continuationToken, false); if (!projects) { return { content: [{ type: "text", text: "No projects found" }], isError: true }; } const filteredProject = projectNameFilter ? filterProjectsByName(projects, projectNameFilter) : projects; return { content: [{ type: "text", text: JSON.stringify(filteredProject, null, 2) }], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [{ type: "text", text: `Error fetching projects: ${errorMessage}` }], isError: true, }; } }
- src/tools/core.ts:62-67 (schema)Zod schema defining the input parameters for the core_list_projects tool.stateFilter: z.enum(["all", "wellFormed", "createPending", "deleted"]).default("wellFormed").describe("Filter projects by their state. Defaults to 'wellFormed'."), top: z.number().optional().describe("The maximum number of projects to return. Defaults to 100."), skip: z.number().optional().describe("The number of projects to skip for pagination. Defaults to 0."), continuationToken: z.number().optional().describe("Continuation token for pagination. Used to fetch the next set of results if available."), projectNameFilter: z.string().optional().describe("Filter projects by name. Supports partial matches."), },
- src/tools/core.ts:59-92 (registration)Registration of the core_list_projects MCP tool on the server using server.tool(), including schema and handler.CORE_TOOLS.list_projects, "Retrieve a list of projects in your Azure DevOps organization.", { stateFilter: z.enum(["all", "wellFormed", "createPending", "deleted"]).default("wellFormed").describe("Filter projects by their state. Defaults to 'wellFormed'."), top: z.number().optional().describe("The maximum number of projects to return. Defaults to 100."), skip: z.number().optional().describe("The number of projects to skip for pagination. Defaults to 0."), continuationToken: z.number().optional().describe("Continuation token for pagination. Used to fetch the next set of results if available."), projectNameFilter: z.string().optional().describe("Filter projects by name. Supports partial matches."), }, async ({ stateFilter, top, skip, continuationToken, projectNameFilter }) => { try { const connection = await connectionProvider(); const coreApi = await connection.getCoreApi(); const projects = await coreApi.getProjects(stateFilter, top, skip, continuationToken, false); if (!projects) { return { content: [{ type: "text", text: "No projects found" }], isError: true }; } const filteredProject = projectNameFilter ? filterProjectsByName(projects, projectNameFilter) : projects; return { content: [{ type: "text", text: JSON.stringify(filteredProject, null, 2) }], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [{ type: "text", text: `Error fetching projects: ${errorMessage}` }], isError: true, }; } } );
- src/tools/core.ts:19-22 (helper)Helper function used by the handler to filter projects by name.function filterProjectsByName(projects: ProjectInfo[], projectNameFilter: string): ProjectInfo[] { const lowerCaseFilter = projectNameFilter.toLowerCase(); return projects.filter((project) => project.name?.toLowerCase().includes(lowerCaseFilter)); }
- src/tools.ts:20-20 (registration)Invocation of configureCoreTools which registers core tools including core_list_projects.configureCoreTools(server, tokenProvider, connectionProvider, userAgentProvider);