From 29c3825604fdc82b483902bf79f204673e2dfdae Mon Sep 17 00:00:00 2001 From: Ramón Medrano Llamas <45878745+rmedranollamas@users.noreply.github.com> Date: Tue, 5 Aug 2025 23:59:31 +0200 Subject: fix(mcp): clear prompt registry on refresh to prevent duplicates (#5385) Co-authored-by: Jacob Richman Co-authored-by: Sandy Tao --- packages/core/src/prompts/prompt-registry.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'packages/core/src/prompts') diff --git a/packages/core/src/prompts/prompt-registry.ts b/packages/core/src/prompts/prompt-registry.ts index 56699130..a94183ac 100644 --- a/packages/core/src/prompts/prompt-registry.ts +++ b/packages/core/src/prompts/prompt-registry.ts @@ -53,4 +53,22 @@ export class PromptRegistry { } return serverPrompts.sort((a, b) => a.name.localeCompare(b.name)); } + + /** + * Clears all the prompts from the registry. + */ + clear(): void { + this.prompts.clear(); + } + + /** + * Removes all prompts from a specific server. + */ + removePromptsByServer(serverName: string): void { + for (const [name, prompt] of this.prompts.entries()) { + if (prompt.serverName === serverName) { + this.prompts.delete(name); + } + } + } } -- cgit v1.2.3