π The fast, Pythonic way to build MCP servers and clients.
Add validation test
Jeremiah Lowinc9255f483fc5
diff --git a/tests/cli/test_run.py b/tests/cli/test_run.pyindex 9ea0fde73..6ae06f1eb 100644--- a/tests/cli/test_run.py+++ b/tests/cli/test_run.py@@ -1,7 +1,9 @@import inspect+import jsonfrom pathlib import Pathimport pytest+from pydantic import ValidationErrorfrom fastmcp.cli.run import (create_mcp_config_server,@@ -126,6 +128,18 @@ class TestMCPConfig:tools = await client.list_tools()assert len(tools) == 1+ async def test_validate_mcp_config(self, tmp_path: Path):+ """Test creating a server from an MCPConfig file."""++ mcp_config_path = tmp_path / "mcp_config.json"++ mcp_config = {"mcpServers": {"test_server": dict(x=1, y=2)}}+ with mcp_config_path.open("w") as f:+ json.dump(mcp_config, f)++ with pytest.raises(ValidationError, match="validation errors for MCPConfig"):+ create_mcp_config_server(mcp_config_path)+class TestServerImport:"""Test server import functionality using real files."""