Skip to content

Commit d4ed9a4

Browse files
authored
Merge pull request #6932 from chezsmithy/feat-mcp-prompt
feat: ✨ MCP Prompts now display when inserted
2 parents 5c4f38b + f33df88 commit d4ed9a4

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

core/config/profile/doLoadConfig.ts

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
SlashCommandDescWithSource,
1919
Tool,
2020
} from "../../";
21+
import { stringifyMcpPrompt } from "../../commands/slash/mcpSlashCommand";
2122
import { MCPManagerSingleton } from "../../context/mcp/MCPManagerSingleton";
2223
import CurrentFileContextProvider from "../../context/providers/CurrentFileContextProvider";
2324
import MCPContextProvider from "../../context/providers/MCPContextProvider";
@@ -216,15 +217,39 @@ export default async function doLoadConfig(options: {
216217
}));
217218
newConfig.tools.push(...serverTools);
218219

220+
// Fetch MCP prompt content during config load
219221
const serverSlashCommands: SlashCommandDescWithSource[] =
220-
server.prompts.map((prompt) => ({
221-
name: prompt.name,
222-
description: prompt.description ?? "MCP Prompt",
223-
source: "mcp-prompt",
224-
isLegacy: false,
225-
mcpServerName: server.name, // Used in client to retrieve prompt
226-
mcpArgs: prompt.arguments,
227-
}));
222+
await Promise.all(
223+
server.prompts.map(async (prompt) => {
224+
let promptContent: string | undefined;
225+
226+
try {
227+
// Fetch the actual prompt content from the MCP server
228+
const mcpPromptResponse = await mcpManager.getPrompt(
229+
server.name,
230+
prompt.name,
231+
{}, // Empty args for now - TODO: handle prompt arguments
232+
);
233+
promptContent = stringifyMcpPrompt(mcpPromptResponse);
234+
} catch (error) {
235+
console.warn(
236+
`Failed to fetch MCP prompt content for ${prompt.name} from server ${server.name}:`,
237+
error,
238+
);
239+
// Keep promptContent as undefined so the UI can show a fallback
240+
}
241+
242+
return {
243+
name: prompt.name,
244+
description: prompt.description ?? "MCP Prompt",
245+
source: "mcp-prompt",
246+
isLegacy: false,
247+
prompt: promptContent, // Store the actual prompt content
248+
mcpServerName: server.name, // Used in client to retrieve prompt
249+
mcpArgs: prompt.arguments,
250+
};
251+
}),
252+
);
228253
newConfig.slashCommands.push(...serverSlashCommands);
229254

230255
const submenuItems = server.resources

gui/src/redux/selectors/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ export const selectSlashCommandComboBoxInputs = createSelector(
1010
(slashCommands) => {
1111
return (
1212
slashCommands?.map((cmd) => {
13+
let content = cmd.prompt;
14+
15+
// For MCP prompts without content, show that it failed to load
16+
if (cmd.source === "mcp-prompt" && !content) {
17+
content = "[MCP Prompt - failed to load content during startup]";
18+
}
19+
1320
return {
1421
title: cmd.name,
1522
description: cmd.description,
1623
type: "slashCommand" as ComboBoxItemType,
17-
content: cmd.prompt,
24+
content: content,
1825
} as ComboBoxItem;
1926
}) || []
2027
);

0 commit comments

Comments
 (0)