feat(cli): add --connect-timeout flag to hermes mcp add

Persists as the server's connect_timeout in config, which the probe
now honors. CLI-flag portion of PR #54494; the probe-wrapper portion
was superseded by resolving connect_timeout inside _probe_single_server.
This commit is contained in:
Sam Beran 2026-07-05 15:21:00 -07:00 committed by Teknium
parent a348368019
commit d52d2973a1
3 changed files with 28 additions and 0 deletions

View file

@ -397,6 +397,7 @@ def cmd_mcp_add(args):
auth_type = getattr(args, "auth", None)
preset_name = getattr(args, "preset", None)
raw_env = getattr(args, "env", None)
raw_connect_timeout = getattr(args, "connect_timeout", None)
server_config: Dict[str, Any] = {}
try:
@ -442,6 +443,8 @@ def cmd_mcp_add(args):
server_config["args"] = cmd_args
if explicit_env:
server_config["env"] = explicit_env
if raw_connect_timeout is not None:
server_config["connect_timeout"] = raw_connect_timeout
issues = validate_mcp_server_entry(name, server_config)
if issues:

View file

@ -60,6 +60,11 @@ def build_mcp_parser(subparsers, *, cmd_mcp: Callable) -> None:
)
mcp_add_p.add_argument("--auth", choices=["oauth", "header"], help="Auth method")
mcp_add_p.add_argument("--preset", help="Known MCP preset name")
mcp_add_p.add_argument(
"--connect-timeout",
type=float,
help="Timeout in seconds for initial connection and tool discovery",
)
mcp_add_p.add_argument(
"--env",
nargs="*",

View file

@ -41,6 +41,7 @@ def _build_parser():
mcp_add.add_argument("name")
mcp_add.add_argument("--url")
mcp_add.add_argument("--command", dest="mcp_command")
mcp_add.add_argument("--connect-timeout", type=float)
mcp_add.add_argument("--args", nargs=argparse.REMAINDER, default=[])
return parser
@ -87,6 +88,25 @@ class TestMcpAddCommandDest:
assert args.mcp_command is None
assert args.url is None
def test_connect_timeout_flag_sets_probe_timeout(self):
"""`--connect-timeout` exposes the per-server discovery timeout."""
parser = _build_parser()
args = parser.parse_args(
[
"mcp",
"add",
"slow",
"--url",
"https://example.com/mcp",
"--connect-timeout",
"180",
]
)
assert args.command == "mcp"
assert args.mcp_action == "add"
assert args.connect_timeout == 180
def test_args_passthrough_keeps_nested_option_flags(self):
"""`--args` must keep command flags like Docker MCP's --profile."""
parser = _build_parser()