Skip to content

Commit f9d48d6

Browse files
committed
Allow config_path: Path | str
1 parent 8b3593c commit f9d48d6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/mcp/client/config/mcp_servers_config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,18 @@ def infer_server_types(cls, servers_data: dict[str, Any]) -> dict[str, Any]:
9898
return servers_data
9999

100100
@classmethod
101-
def from_file(cls, config_path: Path, use_pyyaml: bool = False) -> "MCPServersConfig":
101+
def from_file(cls, config_path: Path | str, use_pyyaml: bool = False) -> "MCPServersConfig":
102102
"""Load configuration from a JSON or YAML file.
103103
104104
Args:
105105
config_path: Path to the configuration file
106106
use_pyyaml: If True, force use of PyYAML parser. Defaults to False.
107107
Also automatically used for .yaml/.yml files.
108108
"""
109+
110+
if isinstance(config_path, str):
111+
config_path = Path(config_path)
112+
109113
with open(config_path) as config_file:
110114
# Check if YAML parsing is requested
111115
should_use_yaml = use_pyyaml or config_path.suffix.lower() in (".yaml", ".yml")

0 commit comments

Comments
 (0)