Skip to content

Commit 8ecbe0e

Browse files
Update src/client.ts
Co-authored-by: Khaled Osman <[email protected]>
1 parent c79af6b commit 8ecbe0e

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/client.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -406,22 +406,18 @@ export class McpdClient {
406406
);
407407

408408
// Process results and transform prompt names.
409-
const allPrompts: Prompt[] = [];
410-
for (const result of results) {
411-
if (result.status === "fulfilled") {
412-
const { serverName, prompts } = result.value;
413-
// Transform prompt names to serverName__promptName format.
414-
for (const prompt of prompts) {
415-
allPrompts.push({
416-
...prompt,
417-
name: `${serverName}__${prompt.name}`,
418-
});
419-
}
420-
} else {
421-
// If we can't get prompts for a server, skip it with a warning.
422-
console.warn(`Failed to get prompts for server:`, result.reason);
423-
}
424-
}
409+
const allPrompts: Prompt[] = results.flatMap(result => {
410+
if (result.status === "fulfilled") {
411+
const { serverName, prompts } = result.value;
412+
return prompts.map(prompt => ({
413+
...prompt,
414+
name: `${serverName}__${prompt.name}`,
415+
}));
416+
} else {
417+
console.warn(`Failed to get prompts for server:`, result.reason);
418+
return []; // Return an empty array for rejected promises
419+
}
420+
});
425421

426422
return allPrompts;
427423
}

0 commit comments

Comments
 (0)