Private
Public Access
0
0
Files
manual_slop/tests/test_external_mcp.py
T
ed 6a3c142bfa test: migrate src.models bare imports + PROVIDERS/Metadata sub-imports to direct subsystems
Removed 18 unused 'from src import models' imports. Migrated the
explicit sub-imports:
- 'from src.models import PROVIDERS' -> 'from src.ai_client import PROVIDERS'
  (test_minimax_provider x2, test_deepseek_infra)
- 'from src.models import Metadata' -> 'from src.type_aliases import Metadata'
  (test_project_manager_tracks, test_track_state_persistence, test_track_state_schema)

Kept the 2 'import src.models as models' in test_provider_curation +
test_providers_source_of_truth (they verify the backward-compat shim
still re-exports PROVIDERS) and the 2 self-tests
(test_models_no_top_level_pydantic + test_models_no_top_level_tomli_w)
that exercise the shim's no-leak invariants.
2026-07-05 20:12:17 -04:00

56 lines
1.5 KiB
Python

import asyncio
import json
import sys
import pytest
from src import mcp_client
from src.mcp_client import MCPServerConfig
@pytest.mark.asyncio
async def test_external_mcp_real_process():
manager = mcp_client.ExternalMCPManager()
# Use our mock script
mock_script = "scripts/mock_mcp_server.py"
config = MCPServerConfig(
name="real-mock",
command="python",
args=[mock_script]
)
await manager.add_server(config)
try:
tools = manager.get_all_tools()
assert "echo" in tools
assert tools["echo"]["server"] == "real-mock"
result = await manager.async_dispatch("echo", {"hello": "world"})
assert "ECHO: {'hello': 'world'}" in result
finally:
await manager.stop_all()
@pytest.mark.asyncio
async def test_get_tool_schemas_includes_external():
manager = mcp_client.get_external_mcp_manager()
# Reset manager
await manager.stop_all()
mock_script = "scripts/mock_mcp_server.py"
config = MCPServerConfig(
name="test-server",
command="python",
args=[mock_script]
)
await manager.add_server(config)
try:
schemas = mcp_client.get_tool_schemas()
echo_schema = next((s for s in schemas if s["name"] == "echo"), None)
assert echo_schema is not None
assert echo_schema["description"] == "Echo input"
assert echo_schema["parameters"] == {"type": "object"}
finally:
await manager.stop_all()