From 7e92618e43678a27db2f2ab703e47004ca6e37e7 Mon Sep 17 00:00:00 2001 From: Daniel Riccio Date: Tue, 5 Aug 2025 17:35:34 -0500 Subject: [PATCH] fix: update mock MCP server configuration in tests - Add status: 'connected' to mock MCP server - Add proper config object with transport details - Update test snapshots to reflect connected MCP server state - Fixes failing tests after MCP server filtering implementation --- .../mcp-server-creation-enabled.snap | 2 +- .../system-prompt/with-mcp-hub-provided.snap | 2 +- .../__tests__/add-custom-instructions.spec.ts | 31 ++++++++++++++++++- .../prompts/__tests__/system-prompt.spec.ts | 31 ++++++++++++++++++- 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap index 7ca32b80a1..9f4d34f54a 100644 --- a/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap +++ b/src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap @@ -519,7 +519,7 @@ The Model Context Protocol (MCP) enables communication between the system and MC When a server is connected, you can use the server's tools via the `use_mcp_tool` tool, and access the server's resources via the `access_mcp_resource` tool. - +## test-server (`test-command`) ## Creating an MCP Server The user may ask you something along the lines of "add a tool" that does some function, in other words to create an MCP server that provides tools and resources that may connect to external APIs for example. If they do, you should obtain detailed instructions on this topic using the fetch_instructions tool, like this: diff --git a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap index 7ca32b80a1..9f4d34f54a 100644 --- a/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap +++ b/src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap @@ -519,7 +519,7 @@ The Model Context Protocol (MCP) enables communication between the system and MC When a server is connected, you can use the server's tools via the `use_mcp_tool` tool, and access the server's resources via the `access_mcp_resource` tool. - +## test-server (`test-command`) ## Creating an MCP Server The user may ask you something along the lines of "add a tool" that does some function, in other words to create an MCP server that provides tools and resources that may connect to external APIs for example. If they do, you should obtain detailed instructions on this topic using the fetch_instructions tool, like this: diff --git a/src/core/prompts/__tests__/add-custom-instructions.spec.ts b/src/core/prompts/__tests__/add-custom-instructions.spec.ts index 5097685e3b..c2365925cf 100644 --- a/src/core/prompts/__tests__/add-custom-instructions.spec.ts +++ b/src/core/prompts/__tests__/add-custom-instructions.spec.ts @@ -170,7 +170,36 @@ const mockContext = { // Instead of extending McpHub, create a mock that implements just what we need const createMockMcpHub = (withServers: boolean = false): McpHub => ({ - getServers: () => (withServers ? [{ name: "test-server", disabled: false }] : []), + getServers: () => + withServers + ? [ + { + name: "test-server", + disabled: false, + status: "connected", + config: JSON.stringify({ command: "test-command" }), + tools: [], + resourceTemplates: [], + resources: [], + instructions: undefined, + }, + ] + : [], + getAllServers: () => + withServers + ? [ + { + name: "test-server", + disabled: false, + status: "connected", + config: JSON.stringify({ command: "test-command" }), + tools: [], + resourceTemplates: [], + resources: [], + instructions: undefined, + }, + ] + : [], getMcpServersPath: async () => "/mock/mcp/path", getMcpSettingsFilePath: async () => "/mock/settings/path", dispose: async () => {}, diff --git a/src/core/prompts/__tests__/system-prompt.spec.ts b/src/core/prompts/__tests__/system-prompt.spec.ts index 4d5579408c..a417158e99 100644 --- a/src/core/prompts/__tests__/system-prompt.spec.ts +++ b/src/core/prompts/__tests__/system-prompt.spec.ts @@ -170,7 +170,36 @@ const mockContext = { // Instead of extending McpHub, create a mock that implements just what we need const createMockMcpHub = (withServers: boolean = false): McpHub => ({ - getServers: () => (withServers ? [{ name: "test-server", disabled: false }] : []), + getServers: () => + withServers + ? [ + { + name: "test-server", + disabled: false, + status: "connected", + config: JSON.stringify({ command: "test-command" }), + tools: [], + resourceTemplates: [], + resources: [], + instructions: undefined, + }, + ] + : [], + getAllServers: () => + withServers + ? [ + { + name: "test-server", + disabled: false, + status: "connected", + config: JSON.stringify({ command: "test-command" }), + tools: [], + resourceTemplates: [], + resources: [], + instructions: undefined, + }, + ] + : [], getMcpServersPath: async () => "/mock/mcp/path", getMcpSettingsFilePath: async () => "/mock/settings/path", dispose: async () => {},