loop-task

MCP Server

Connect AI agents and coding tools to loop-task via the Model Context Protocol (MCP).

loop-task exposes an MCP (Model Context Protocol) server alongside the daemon, allowing MCP-compatible tools like OpenCode, Claude Code, Cursor, and others to discover and call loop-task operations as first-class tools.

Overview

When the daemon starts (loop-task start or loop-task new), the MCP server initializes alongside the existing HTTP and IPC servers. No separate command or entry point is needed, the MCP server runs inside the daemon process.

An MCP client connecting to loop-task receives a list of tools that map directly to the HTTP API surface. The agent simply asks "what tools are available?" and gets back list_loops, create_loop, trigger_loop, etc.

Configuration

VariableDescriptionDefault
LOOP_CLI_MCP_ENABLEDEnable/disable MCP servertrue
LOOP_CLI_MCP_TRANSPORTTransport: sse or stdiosse
LOOP_CLI_MCP_PORTPort for SSE transport8846

To disable MCP at startup:

LOOP_CLI_MCP_ENABLED=false loop-task start

To use SSE transport:

LOOP_CLI_MCP_TRANSPORT=sse loop-task start

Toggle at runtime

Use the command palette (Ctrl+P) and select "Toggle MCP server on/off" to enable or disable MCP without restarting the daemon. You can also use the HTTP API settings endpoint:

curl -X PATCH http://127.0.0.1:8845/api/settings -d '{"mcpApiEnabled": true}'

Connecting to your tool

loop-task's MCP server uses SSE transport so any tool on your network can connect to the running daemon. Just start the daemon normally:

loop-task start

Then pick your tool below and add the config, replacing <host> with the IP address of the machine running the daemon (e.g. 192.168.1.50, or 127.0.0.1 if it's the same machine).

Claude Code

Add to ~/.claude/mcp.json (global) or .claude/mcp.json (project):

{
  "mcpServers": {
    "loop-task": {
      "type": "sse",
      "url": "http://<host>:8846/sse"
    }
  }
}

GitHub Copilot (VS Code)

Create .vscode/mcp.json in your workspace:

{
  "servers": {
    "loop-task": {
      "type": "sse",
      "url": "http://<host>:8846/sse"
    }
  }
}

Then open the Copilot Chat panel, click the Tools icon, and enable loop-task.

OpenCode

Add to opencode.json (or .opencode/opencode.json) under the mcp key:

{
  "mcp": {
    "loop-task": {
      "type": "remote",
      "url": "http://<host>:8846/sse"
    }
  }
}

Cursor

Add to .cursor/mcp.json in your project root:

{
  "mcpServers": {
    "loop-task": {
      "type": "sse",
      "url": "http://<host>:8846/sse"
    }
  }
}

Other SSE clients

Point any SSE-capable MCP client at:

http://<host>:8846/sse

Note: The SSE transport requires the daemon to already be running before an MCP client can connect.

Transports

SSE (default)

SSE is the default transport. The daemon exposes an HTTP endpoint that any MCP client on the network can reach. Just start the daemon and point your client at http://<host>:8846/sse.

stdio

Available Tools

Loops

ToolDescription
list_loopsList all loops
get_loopGet loop status by ID
create_loopCreate a new loop
update_loopUpdate an existing loop
delete_loopDelete a loop
pause_loopPause a loop
resume_loopResume a paused loop
trigger_loopTrigger a loop to run immediately
stop_loopStop a running loop
stop_all_loopsStop all running loops

Tasks

ToolDescription
list_tasksList all tasks
get_taskGet a task by ID
create_taskCreate a new task
update_taskUpdate an existing task
delete_taskDelete a task

Projects

ToolDescription
list_projectsList all projects
get_projectGet a project by ID
create_projectCreate a new project
update_projectUpdate an existing project
delete_projectDelete a project

Logs

ToolDescription
get_loop_logsFetch loop log snapshot (last N lines)
get_run_logGet run-specific log for a loop

Tool Schemas

Each MCP tool's input schema corresponds to the same fields accepted by the HTTP API. For example:

create_loop

{
  "command": "npm test",
  "intervalHuman": "5m",
  "description": "Run tests every 5 minutes",
  "projectId": "my-project",
  "maxRuns": 10
}

create_task

{
  "name": "Build",
  "command": "npm",
  "commandArgs": ["run", "build"]
}

create_project

{
  "name": "My Project",
  "color": "#4ade80",
  "directory": "/home/user/my-project"
}

Response Format

All tool responses follow the same envelope as the HTTP API:

Success:

{ "ok": true, "data": { "id": "abc12345" } }

Error:

{ "ok": false, "error": { "message": "Loop not found: abc12345" } }

Graceful Degradation

If MCP initialization fails, the daemon continues with IPC + HTTP only, the same graceful degradation pattern as the HTTP API's EADDRINUSE handling. No functionality is lost.

Architecture

The MCP server module lives under src/daemon/mcp/ (alongside http/, server/, managers/). It follows the same dependency injection pattern as HttpApiServer, it receives LoopManager, TaskManager, and ProjectManager instances and calls their methods directly. The src/core/ layer remains runtime-agnostic and does not import MCP code.