1+ import json
2+ from pathlib import Path
3+
14import pytest
2- from unittest .mock import patch , Mock
35
46from modules .mcp_tools .client import MCPToolManager
57from modules .config import ConfigManager
@@ -14,19 +16,18 @@ async def test_selected_mcp_prompt_overrides_system_prompt(monkeypatch):
1416 """
1517 # Ensure MCP clients and prompts are ready
1618 # Set up MCP manager directly (avoid importing app_factory/litellm).
17- # Patch config_manager so MCPToolManager sees a "prompts" server
18- # without depending on actual file-based config.
19- with patch ("modules.mcp_tools.client.config_manager" ) as mock_cm :
20- mock_cm .mcp_config .servers = {
21- "prompts" : Mock (name = "prompts_server_config" )
22- }
23- mock_cm .mcp_config .servers ["prompts" ].model_dump .return_value = {
24- "command" : ["python" , "mcp/prompts/main.py" ],
25- "cwd" : "backend" ,
26- "groups" : ["users" ],
27- }
28-
29- mcp : MCPToolManager = MCPToolManager ()
19+ # Use the example prompts MCP config file so this test uses
20+ # the same JSON configuration as other prompts tests.
21+ # tests run with cwd=backend/, so resolve from backend root
22+ backend_root = Path (__file__ ).parent .parent
23+ project_root = backend_root .parent
24+ config_path = project_root / "config" / "mcp-example-configs" / "mcp-prompts.json"
25+ assert config_path .exists (), f"Missing example prompts config: { config_path } "
26+
27+ data = json .loads (config_path .read_text ())
28+ assert "prompts" in data , "prompts server not defined in example config"
29+
30+ mcp : MCPToolManager = MCPToolManager (config_path = str (config_path ))
3031 await mcp .initialize_clients ()
3132 await mcp .discover_prompts ()
3233 assert "prompts" in mcp .available_prompts , "prompts server not discovered"
0 commit comments