Skip to content

Commit 3955ccc

Browse files
authored
Make available prompt logic the same as tools (#9267)
Fix bug where non-core prompts would not appear when there are no active features Specifically, the block insideif (!features) was skipped if features = []
1 parent 0fc5903 commit 3955ccc

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/mcp/prompts/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ function namespacePrompts(
4040
/**
4141
* Return available prompts based on the list of registered features.
4242
*/
43-
export function availablePrompts(features?: ServerFeature[]): ServerPrompt[] {
44-
const allPrompts: ServerPrompt[] = namespacePrompts(prompts["core"], "core");
43+
export function availablePrompts(activeFeatures?: ServerFeature[]): ServerPrompt[] {
44+
const allPrompts: ServerPrompt[] = [];
4545

46-
if (!features) {
47-
features = Object.keys(prompts).filter((f) => f !== "core") as ServerFeature[];
46+
if (!activeFeatures?.length) {
47+
activeFeatures = Object.keys(prompts) as ServerFeature[];
4848
}
49-
50-
for (const feature of features) {
51-
if (prompts[feature] && feature !== "core") {
52-
allPrompts.push(...namespacePrompts(prompts[feature], feature));
53-
}
49+
if (!activeFeatures.includes("core")) {
50+
activeFeatures = ["core", ...activeFeatures];
51+
}
52+
for (const feature of activeFeatures) {
53+
allPrompts.push(...namespacePrompts(prompts[feature], feature));
5454
}
5555
return allPrompts;
5656
}

src/mcp/tools/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function availableTools(activeFeatures?: ServerFeature[]): ServerTool[] {
1919
activeFeatures = Object.keys(tools) as ServerFeature[];
2020
}
2121
if (!activeFeatures.includes("core")) {
22-
activeFeatures.unshift("core");
22+
activeFeatures = ["core", ...activeFeatures];
2323
}
2424
for (const key of activeFeatures) {
2525
toolDefs.push(...tools[key]);

0 commit comments

Comments
 (0)