fix: allow MCP prompts with spaces in name (#12910)

Co-authored-by: Abhi <43648792+abhipatel12@users.noreply.github.com>
This commit is contained in:
Jack Wotherspoon
2025-11-19 09:44:30 -05:00
committed by GitHub
parent 11149ae3e4
commit 7e7f4f9bbe
2 changed files with 36 additions and 1 deletions
+2 -1
View File
@@ -38,7 +38,8 @@ export class McpPromptLoader implements ICommandLoader {
for (const serverName in mcpServers) {
const prompts = getMCPServerPrompts(this.config, serverName) || [];
for (const prompt of prompts) {
const commandName = `${prompt.name}`;
// Sanitize prompt names to ensure they are valid slash commands (e.g. "Prompt Name" -> "Prompt-Name")
const commandName = `${prompt.name}`.trim().replace(/\s+/g, '-');
const newPromptCommand: SlashCommand = {
name: commandName,
description: prompt.description || `Invoke prompt ${prompt.name}`,