William Easton commited on
Commit
8e64604
·
unverified ·
1 Parent(s): f27287f

update for windows?

Browse files
Files changed (1) hide show
  1. tests/cli/test_run.py +11 -13
tests/cli/test_run.py CHANGED
@@ -1,4 +1,5 @@
1
  import inspect
 
2
 
3
  import pytest
4
 
@@ -10,6 +11,7 @@ from fastmcp.cli.run import (
10
  )
11
  from fastmcp.client.client import Client
12
  from fastmcp.client.transports import FastMCPTransport
 
13
  from fastmcp.server.server import FastMCP
14
 
15
 
@@ -89,7 +91,7 @@ class TestFilePathParsing:
89
  class TestMCPConfig:
90
  """Test MCPConfig functionality."""
91
 
92
- async def test_run_mcp_config(self, tmp_path):
93
  """Test creating a server from an MCPConfig file."""
94
  server_script = inspect.cleandoc("""
95
  from fastmcp import FastMCP
@@ -104,21 +106,17 @@ class TestMCPConfig:
104
  mcp.run()
105
  """)
106
 
107
- script_path = tmp_path / "test.py"
108
  script_path.write_text(server_script)
109
 
110
  mcp_config_path = tmp_path / "mcp_config.json"
111
- mcp_config_str = f"""
112
- {{
113
- "mcpServers": {{
114
- "test_server": {{
115
- "command": "python",
116
- "args": ["{str(script_path)}"]
117
- }}
118
- }}
119
- }}
120
- """
121
- mcp_config_path.write_text(mcp_config_str)
122
 
123
  server: FastMCP[None] = create_mcp_config_server(mcp_config_path)
124
 
 
1
  import inspect
2
+ from pathlib import Path
3
 
4
  import pytest
5
 
 
11
  )
12
  from fastmcp.client.client import Client
13
  from fastmcp.client.transports import FastMCPTransport
14
+ from fastmcp.mcp_config import MCPConfig, StdioMCPServer
15
  from fastmcp.server.server import FastMCP
16
 
17
 
 
91
  class TestMCPConfig:
92
  """Test MCPConfig functionality."""
93
 
94
+ async def test_run_mcp_config(self, tmp_path: Path):
95
  """Test creating a server from an MCPConfig file."""
96
  server_script = inspect.cleandoc("""
97
  from fastmcp import FastMCP
 
106
  mcp.run()
107
  """)
108
 
109
+ script_path: Path = tmp_path / "test.py"
110
  script_path.write_text(server_script)
111
 
112
  mcp_config_path = tmp_path / "mcp_config.json"
113
+
114
+ mcp_config = MCPConfig(
115
+ mcpServers={
116
+ "test_server": StdioMCPServer(command="python", args=[str(script_path)])
117
+ }
118
+ )
119
+ mcp_config.write_to_file(mcp_config_path)
 
 
 
 
120
 
121
  server: FastMCP[None] = create_mcp_config_server(mcp_config_path)
122