Skip to content

feat(api-server): let agents manage their own schedules via MCP#254

Open
xjacka wants to merge 1 commit intomainfrom
feat/agent-schedules
Open

feat(api-server): let agents manage their own schedules via MCP#254
xjacka wants to merge 1 commit intomainfrom
feat/agent-schedules

Conversation

@xjacka
Copy link
Copy Markdown
Contributor

@xjacka xjacka commented Apr 21, 2026

Agents can now create, list, toggle, and delete the schedules attached to their own instance by calling MCP tools on the existing harness /api/instances/:id/mcp endpoint — no human UI step required. Schedules are scoped to the calling instance by construction (session.instanceId from the URL + existing bearer-token auth), so one agent cannot touch another's schedules.

  • ScheduleSpec: new createdBy: "user" | "agent" (default "user") persisted in the ConfigMap and surfaced via the schedule view
  • New label humr.ai/created-by for quick filtering in K8s
  • MCP tools: list/create/toggle/delete with assertive descriptions that explicitly steer Claude Code away from its in-process scheduled-tasks tool toward these persistent, platform-level schedules
  • UI: amber "agent" badge on schedules the agent scheduled itself
  • Claude Code agent image: CLAUDE.md at workspace root nudges the model to prefer humr-outbound schedule tools

Summary

Related issue(s)

(Optional) Testing Instructions

Fixes #236

Closes #236. Agents can now create, list, toggle, and delete the
schedules attached to their own instance by calling MCP tools on the
existing harness `/api/instances/:id/mcp` endpoint — no human UI step
required. Schedules are scoped to the calling instance by construction
(session.instanceId from the URL + existing bearer-token auth), so one
agent cannot touch another's schedules.

- ScheduleSpec: new `createdBy: "user" | "agent"` (default `"user"`)
  persisted in the ConfigMap and surfaced via the schedule view
- New label `humr.ai/created-by` for quick filtering in K8s
- MCP tools: list/create/toggle/delete with assertive descriptions that
  explicitly steer Claude Code away from its in-process scheduled-tasks
  tool toward these persistent, platform-level schedules
- UI: amber "agent" badge on schedules the agent scheduled itself
- Claude Code agent image: CLAUDE.md at workspace root nudges the model
  to prefer humr-outbound schedule tools

Signed-off-by: Lukáš Janeček <xjacka@gmail.com>
@xjacka
Copy link
Copy Markdown
Contributor Author

xjacka commented Apr 27, 2026

🛡️ Humr — Code Review

PR #254: feat(api-server): let agents manage their own schedules via MCP

Author: xjacka | Branch: feat/agent-schedules → main | Changes: +176 −22 (12 files)

Summary

Exposes persistent cron schedule management as MCP tools (create_schedule, list_schedules, toggle_schedule, delete_schedule) in the harness API server, scoped to the calling agent's own instance. Adds createdBy: "agent" label and UI badge for agent-created schedules.

Findings

  • 🟡 Warning: toggle_schedule handler does schedules.get(id) then schedules.toggle(id) — TOCTOU race: a concurrent deletion between the two calls can bypass the ownership check with a misleading "not found" error rather than a clear access denial. (packages/api-server/src/apps/harness-api-server/mcp-endpoint.ts)
  • 🟢 Suggestion: Tool description hardcodes "CronCreate" as the in-process alternative to prefer over — will become stale if Claude Code renames the tool.
  • Looks good: Ownership verification (existing.instanceId !== instanceId) correctly scopes each agent's view to its own schedules.
  • Looks good: CLAUDE.md in the claude-code workspace explaining when to use Humr schedules vs in-process tools is an excellent model-guidance addition.
  • Looks good: verifyAgentToken now returns AgentAuth | null instead of boolean, cleanly threading the owner through to the schedule service.

Verdict

APPROVE — clean, well-scoped feature; the TOCTOU is low-impact in practice.


Review by Humr · automated code guardian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Allow agents to create scheduled tasks

5 participants