feat: ✨ MCP Prompts now display when inserted

This commit is contained in:
chezsmithy 2025-08-01 17:38:28 -07:00
parent 33fa558969
commit f33df88ae5
2 changed files with 41 additions and 9 deletions

View file

@ -18,6 +18,7 @@ import {
SlashCommandDescWithSource,
Tool,
} from "../../";
import { stringifyMcpPrompt } from "../../commands/slash/mcpSlashCommand";
import { MCPManagerSingleton } from "../../context/mcp/MCPManagerSingleton";
import CurrentFileContextProvider from "../../context/providers/CurrentFileContextProvider";
import MCPContextProvider from "../../context/providers/MCPContextProvider";
@ -216,15 +217,39 @@ export default async function doLoadConfig(options: {
}));
newConfig.tools.push(...serverTools);
// Fetch MCP prompt content during config load
const serverSlashCommands: SlashCommandDescWithSource[] =
server.prompts.map((prompt) => ({
name: prompt.name,
description: prompt.description ?? "MCP Prompt",
source: "mcp-prompt",
isLegacy: false,
mcpServerName: server.name, // Used in client to retrieve prompt
mcpArgs: prompt.arguments,
}));
await Promise.all(
server.prompts.map(async (prompt) => {
let promptContent: string | undefined;
try {
// Fetch the actual prompt content from the MCP server
const mcpPromptResponse = await mcpManager.getPrompt(
server.name,
prompt.name,
{}, // Empty args for now - TODO: handle prompt arguments
);
promptContent = stringifyMcpPrompt(mcpPromptResponse);
} catch (error) {
console.warn(
`Failed to fetch MCP prompt content for ${prompt.name} from server ${server.name}:`,
error,
);
// Keep promptContent as undefined so the UI can show a fallback
}
return {
name: prompt.name,
description: prompt.description ?? "MCP Prompt",
source: "mcp-prompt",
isLegacy: false,
prompt: promptContent, // Store the actual prompt content
mcpServerName: server.name, // Used in client to retrieve prompt
mcpArgs: prompt.arguments,
};
}),
);
newConfig.slashCommands.push(...serverSlashCommands);
const submenuItems = server.resources

View file

@ -10,11 +10,18 @@ export const selectSlashCommandComboBoxInputs = createSelector(
(slashCommands) => {
return (
slashCommands?.map((cmd) => {
let content = cmd.prompt;
// For MCP prompts without content, show that it failed to load
if (cmd.source === "mcp-prompt" && !content) {
content = "[MCP Prompt - failed to load content during startup]";
}
return {
title: cmd.name,
description: cmd.description,
type: "slashCommand" as ComboBoxItemType,
content: cmd.prompt,
content: content,
} as ComboBoxItem;
}) || []
);