Skip to content

The agent that grows with you

fix(cron): run a job whose enabled_toolsets MCP server is only reconnecting, instead of blocking it

teknium16924cc66fb7f
diff --git a/cron/scheduler_preflight.py b/cron/scheduler_preflight.py
index df5dd1dd091..5e4f863691f 100644
--- a/cron/scheduler_preflight.py
+++ b/cron/scheduler_preflight.py
@@ -325,19 +325,29 @@ def _empty_requested_mcp_toolsets(job: dict, cfg: dict) -> Optional[str]:
return None
from hermes_cli.tools_config import enabled_mcp_server_names
from toolsets import resolve_toolset
+ from tools.mcp_tool_discovery import mcp_server_reconnecting
missing = [name for name in requested
if name in enabled_mcp_server_names(cfg) and not resolve_toolset(name)]
+ # A server that worked in this process and is parked/self-probing after a network blip
+ # (router reboot, DNS failure) is recovering, not misconfigured: the job runs with the tools
+ # that did resolve rather than losing a whole tick to a minute of downtime (#112871). Only a
+ # server that never connected for this profile is judged below.
+ reconnecting = sorted(name for name in missing if mcp_server_reconnecting(name))
+ if reconnecting:
+ logger.warning(
+ "Job '%s': MCP server(s) %s named in enabled_toolsets are reconnecting — running "
+ "without their tools this tick", job.get("id", "?"), ", ".join(reconnecting))
+ missing = [name for name in missing if name not in reconnecting]
if not missing:
return None
# The reason is what the operator reads in the gateway log and the alert. It must say the
- # block is not sticky: a server that is merely unreachable for a minute (router reboot, DNS
- # blip) is parked and self-probed by the MCP layer, and this check re-runs on every dispatch,
- # so the job resumes on its own — two operators misread the old text as a config error to
- # repair by hand (#112871).
+ # block is not sticky: a server whose first connection failed on a network blip is parked and
+ # self-probed by the MCP layer, and this check re-runs on every dispatch, so the job resumes
+ # on its own — two operators misread the old text as a config error to repair by hand (#112871).
return (
f"MCP server(s) {', '.join(sorted(missing))} named in this job's enabled_toolsets "
- "resolved to zero tools for this profile (not connected, or connected for another "
- "profile only). If the server is only temporarily unreachable this clears by itself — "
+ "resolved to zero tools for this profile (never connected for this profile, or connected "
+ "for another profile only). If the server is only temporarily unreachable this clears by itself — "
"the check re-runs on every dispatch and the job resumes once the server reconnects. "
"If the name is wrong or belongs to another profile, fix the server or remove it from "
"the job's toolsets.")
diff --git a/tests/cron/test_cron_mcp_toolset_empty_block.py b/tests/cron/test_cron_mcp_toolset_empty_block.py
index 40f67c5da77..dac42f6ec10 100644
--- a/tests/cron/test_cron_mcp_toolset_empty_block.py
+++ b/tests/cron/test_cron_mcp_toolset_empty_block.py
@@ -90,3 +90,45 @@ def test_requested_mcp_server_with_tools_runs(tmp_path):
assert agent_built is True
assert success is True and error is None
+
+
+def _park_notion(*, ever_connected: bool):
+ """Install a sessionless ``notion`` run task (tools deregistered, alias still global) the way
+ the MCP layer leaves a degraded/parked server; ``ever_connected`` separates a server that
+ worked in this process and lost its network from one that never came up here."""
+ import tools.mcp_tool as core
+ from tools.registry import registry
+
+ server = core.MCPServerTask("notion")
+ server._ever_connected = ever_connected
+ registry.register_toolset_alias("notion", "mcp-notion")
+ core._servers["notion"] = server
+ return lambda: core._servers.pop("notion", None)
+
+
+def test_requested_mcp_server_reconnecting_runs_without_its_tools(tmp_path):
+ """A server that connected in this process and is parked/self-probing after a network blip
+ is recoverable: the job runs with the tools that did resolve instead of blocking (#112871)."""
+ undo = _park_notion(ever_connected=True)
+ try:
+ (success, _output, _final, error), agent_built = _run(
+ _job(enabled_toolsets=["terminal", "notion"]), tmp_path)
+ finally:
+ undo()
+
+ assert agent_built is True
+ assert success is True and error is None
+
+
+def test_requested_mcp_server_never_connected_still_blocks(tmp_path):
+ """A parked server that never connected here (bad URL, wrong credentials) keeps the block."""
+ undo = _park_notion(ever_connected=False)
+ try:
+ (success, _output, _final, error), agent_built = _run(
+ _job(enabled_toolsets=["terminal", "notion"]), tmp_path)
+ finally:
+ undo()
+
+ assert agent_built is False
+ assert success is False
+ assert error is not None and "[blocked_config]" in error and "notion" in error
diff --git a/tools/mcp_tool_discovery.py b/tools/mcp_tool_discovery.py
index cc6b4b26308..8c52c64b503 100644
--- a/tools/mcp_tool_discovery.py
+++ b/tools/mcp_tool_discovery.py
@@ -611,6 +611,18 @@ def get_mcp_status(configured: Optional[Dict[str, dict]] = None, *, include_runt
return result
+def mcp_server_reconnecting(name: str) -> bool:
+ """True when this profile's connection to *name* connected once in this process and is now
+ between sessions (degraded/parked): the run task is alive and self-probing, so the outage is
+ environmental and heals on its own. A server that never connected here (wrong URL, other
+ profile's credentials, permanent error) is not reconnecting. Reads cached state; never connects."""
+ with _core._lock:
+ server = _core._servers.get(_resolve_server_key(name))
+ if server is None or server.session is not None or not server._ever_connected:
+ return False
+ return server._task is None or not server._task.done()
+
+
def probe_mcp_server_tools() -> Dict[str, List[tuple]]:
"""Connect each enabled server, list ``(tool_name, description)``, disconnect; nothing is
registered and failed servers are omitted."""
diff --git a/website/docs/user-guide/features/cron.md b/website/docs/user-guide/features/cron.md
index b6639dc7a69..cf570a6a634 100644
--- a/website/docs/user-guide/features/cron.md
+++ b/website/docs/user-guide/features/cron.md
@@ -84,7 +84,14 @@ validates that the job's configuration can actually produce a successful run:
- attached skills are ready (no missing required environment variables,
commands, or credential files),
- delivery platform targets are known and have gateway credentials configured
- (`local`/`origin` targets are never checked).
+ (`local`/`origin` targets are never checked),
+- every MCP server the job names in its own `enabled_toolsets` resolved to at
+ least one tool for this profile. A server that connected earlier in this
+ gateway and is only reconnecting after a network blip (router reboot, DNS
+ failure) does **not** block: the job runs with the tools that did resolve and
+ the gateway log notes which servers were skipped. Only a server that never
+ connected for this profile (wrong URL or credentials, or a server another
+ profile owns under a multiplexer) blocks the run.
When validation fails, the job's `last_status` becomes `blocked_config`, ONE
alert is delivered (it is not repeated every tick), and **no LLM call is