Problem
When creating a cron job that uses skills or relies on MCP servers, the job fails because the cron scheduler runs in a separate Python environment that does not share the MCP/plugin configuration loaded by the main CLI process.
Root Cause
In cron/scheduler.py, the run_job() function creates an AIAgent without initializing MCP servers. The MCP connections are established in cli.py when the main process starts, but cron jobs execute in a context where discover_mcp_tools() has never been called.
Key issues in cron/scheduler.py:
- MCP not initialized: No call to
discover_mcp_tools() before creating the AIAgent
- Skills work differently: Skills are loaded via
_build_job_prompt() which reads skill files directly - this works, but the skill execution (e.g., using skill tools) may still fail if the skill toolset is not properly initialized
- Plugins: Similarly, plugin configuration is not propagated to cron job runs
Expected Behavior
Cron jobs should be able to use:
- Skills (defined via
skill: or skills: in the job)
- MCP servers (defined in
config.yaml under mcp_servers)
- Any plugins configured in the main hermes config
Environment
- Hermes version: latest
- Python environment: separate cron process
- MCP servers: configured in
~/.hermes/config.yaml
Possible Solution
In run_job(), after loading config.yaml, initialize MCP before creating the AIAgent:
# Initialize MCP servers for this cron job run
try:
from tools.mcp_tool import discover_mcp_tools, _ensure_mcp_loop
_ensure_mcp_loop()
mcp_tools = discover_mcp_tools()
logger.info("Job '%s': discovered %d MCP tools", job_id, len(mcp_tools))
except Exception as e:
logger.warning("Job '%s': failed to initialize MCP: %s", job_id, e)
Problem
When creating a cron job that uses skills or relies on MCP servers, the job fails because the cron scheduler runs in a separate Python environment that does not share the MCP/plugin configuration loaded by the main CLI process.
Root Cause
In
cron/scheduler.py, therun_job()function creates anAIAgentwithout initializing MCP servers. The MCP connections are established incli.pywhen the main process starts, but cron jobs execute in a context wherediscover_mcp_tools()has never been called.Key issues in
cron/scheduler.py:discover_mcp_tools()before creating theAIAgent_build_job_prompt()which reads skill files directly - this works, but the skill execution (e.g., using skill tools) may still fail if the skill toolset is not properly initializedExpected Behavior
Cron jobs should be able to use:
skill:orskills:in the job)config.yamlundermcp_servers)Environment
~/.hermes/config.yamlPossible Solution
In
run_job(), after loadingconfig.yaml, initialize MCP before creating theAIAgent: