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
| Variable | Description | Default |
|---|---|---|
LOOP_CLI_MCP_ENABLED | Enable/disable MCP server | true |
LOOP_CLI_MCP_TRANSPORT | Transport: sse or stdio | sse |
LOOP_CLI_MCP_PORT | Port for SSE transport | 8846 |
To disable MCP at startup:
LOOP_CLI_MCP_ENABLED=false loop-task startTo use SSE transport:
LOOP_CLI_MCP_TRANSPORT=sse loop-task startToggle 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 startThen 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/sseNote: 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
| Tool | Description |
|---|---|
list_loops | List all loops |
get_loop | Get loop status by ID |
create_loop | Create a new loop |
update_loop | Update an existing loop |
delete_loop | Delete a loop |
pause_loop | Pause a loop |
resume_loop | Resume a paused loop |
trigger_loop | Trigger a loop to run immediately |
stop_loop | Stop a running loop |
stop_all_loops | Stop all running loops |
Tasks
| Tool | Description |
|---|---|
list_tasks | List all tasks |
get_task | Get a task by ID |
create_task | Create a new task |
update_task | Update an existing task |
delete_task | Delete a task |
Projects
| Tool | Description |
|---|---|
list_projects | List all projects |
get_project | Get a project by ID |
create_project | Create a new project |
update_project | Update an existing project |
delete_project | Delete a project |
Logs
| Tool | Description |
|---|---|
get_loop_logs | Fetch loop log snapshot (last N lines) |
get_run_log | Get 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.