Skip to content

Commit f38b1c5

Browse files
committed
List projects with name filter
1 parent 7f738d4 commit f38b1c5

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/tools/core.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ function configureCoreTools(
6363
stateFilter: z.enum(["all", "wellFormed", "createPending", "deleted"]).default("wellFormed").describe("Filter projects by their state. Defaults to 'wellFormed'."),
6464
top: z.number().optional().describe("The maximum number of projects to return. Defaults to 100."),
6565
skip: z.number().optional().describe("The number of projects to skip for pagination. Defaults to 0."),
66-
continuationToken: z.number().optional().describe("Continuation token for pagination. Used to fetch the next set of results if available."),
66+
continuationToken: z.number().optional().describe("Continuation token for pagination. Used to fetch the next set of results if available."),
67+
projectNameFilter: z.string().optional().describe("Filter projects by name. Supports partial matches."),
6768
},
68-
async ({ stateFilter, top, skip, continuationToken }) => {
69+
async ({ stateFilter, top, skip, continuationToken, projectNameFilter }) => {
6970
try {
7071
const connection = await connectionProvider();
7172
const coreApi = await connection.getCoreApi();
@@ -81,6 +82,19 @@ function configureCoreTools(
8182
return { content: [{ type: "text", text: "No projects found" }], isError: true };
8283
}
8384

85+
// If projectNameFilter is provided, filter the projects
86+
if (projectNameFilter) {
87+
const filteredProjects = projects.filter(project =>
88+
project.name?.toLowerCase().includes(projectNameFilter.toLowerCase())
89+
);
90+
if (filteredProjects.length === 0) {
91+
return { content: [{ type: "text", text: "No projects found matching the filter" }], isError: true };
92+
}
93+
return {
94+
content: [{ type: "text", text: JSON.stringify(filteredProjects, null, 2) }],
95+
};
96+
}
97+
8498
return {
8599
content: [{ type: "text", text: JSON.stringify(projects, null, 2) }],
86100
};

0 commit comments

Comments
 (0)