Skip to content

Cron jobs cannot use skills, plugins, and MCP servers #4219

@xiehongyu777

Description

@xiehongyu777

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:

  1. MCP not initialized: No call to discover_mcp_tools() before creating the AIAgent
  2. 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
  3. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/cronCron scheduler and job managementcomp/pluginsPlugin system and bundled pluginstool/mcpMCP client and OAuthtype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions