Skip to content

Commit f7e1ab8

Browse files
hieutrtrtoreleon
andauthored
Enhance config params (#34)
* Enhance error handling in MCPServersParams class - Raise ServerConfigNotFoundError if no configuration file path is provided. - Validate server configuration to ensure 'command' and 'args' are not None, raising a ValueError if they are invalid. * update version 0.1.10 * Update to 0.1.11 --------- Co-authored-by: Thang Le <[email protected]>
1 parent cdd4f29 commit f7e1ab8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "mcphub"
7-
version = "0.1.9"
7+
version = "0.1.11"
88
description = "A Python package for managing and integrating Model Context Protocol (MCP) servers with AI frameworks like OpenAI Agents, LangChain, and Autogen"
99
readme = "README.md"
1010
authors = [

src/mcphub/mcp_servers/params.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _load_user_config(self) -> Dict:
4747
"""Load user configuration from JSON file."""
4848
# If no config path is provided, return empty dict
4949
if not self.config_path:
50-
return {}
50+
raise ServerConfigNotFoundError("No configuration file path provided")
5151

5252
try:
5353
with open(self.config_path, "r") as f:
@@ -188,8 +188,15 @@ def _load_servers_params(self) -> Dict[str, MCPServerConfig]:
188188
)
189189

190190
# Get command and args with defaults
191-
command = server_config.get("command", "npx")
192-
args = server_config.get("args", ["-y", package_name])
191+
command = server_config.get("command", None)
192+
args = server_config.get("args", None)
193+
194+
# Skip if command or args is None
195+
if command is None or args is None:
196+
raise ValueError(
197+
f"Invalid server '{mcp_name}' configuration: command or args is None. "
198+
f"Command: {command}, Args: {args}"
199+
)
193200

194201
servers[mcp_name] = MCPServerConfig(
195202
package_name=package_name,

0 commit comments

Comments
 (0)