OpenHands
Load the Loop microagent and configure MCP for autonomous development with OpenHands.
OpenHands
OpenHands is an open-source autonomous coding agent. This guide walks through connecting OpenHands to Loop so it can pull work from the dispatch queue, execute tasks, and report results back.
OpenHands integrates with Loop through two surfaces:
- Microagent -- a keyword-triggered markdown file that teaches OpenHands how to use the Loop API.
- MCP Server (optional) -- provides tool-based access to Loop for richer agent interactions.
The microagent approach is the recommended starting point. It gives OpenHands contextual knowledge about Loop's API without requiring any infrastructure changes.
Prerequisites
- A running Loop API instance (local or hosted)
- A valid
LOOP_API_KEY(authentication docs) - OpenHands installed and configured (OpenHands docs)
Microagent Setup
OpenHands supports microagents -- small markdown files that are loaded into the agent's context when specific keywords appear in the conversation. Loop provides a pre-built microagent that teaches OpenHands the full Loop API.
Create the microagent directory
If your repository does not already have a .openhands/microagents/ directory, create it:
mkdir -p .openhands/microagentsInstall the microagent file
Copy the Loop microagent into your repository. You can either install it from the npm package or create it manually.
The @dork-labs/loop-skill package includes the microagent template:
npx @dork-labs/loop-skill init --openhandsThis copies the microagent file to .openhands/microagents/loop.md.
Create .openhands/microagents/loop.md with the following frontmatter and content. The frontmatter tells OpenHands when to activate the microagent:
---
name: loop
agent: CodeActAgent
trigger_type: keyword
triggers:
- loop
- looped
- looped.me
- loop api
- loop issue
- ingest signal
---Below the frontmatter, include the Loop API reference. See the full microagent template on GitHub for the complete content.
Set the API key
Ensure LOOP_API_KEY is available in the OpenHands environment. Add it to your .env file or pass it as an environment variable when starting OpenHands:
export LOOP_API_KEY=loop_your_api_key_hereVerify the microagent loads
Start an OpenHands session and mention "loop" in your prompt. The microagent should activate automatically, giving the agent knowledge of Loop's API endpoints, authentication, and workflow.
Try a simple test:
Check the Loop API health endpoint and list any issues in triage status.The agent should make HTTP calls to your Loop instance and return results.
Microagent Content
The Loop microagent provides OpenHands with:
- API base URL and authentication pattern (
Authorization: Bearer $LOOP_API_KEY) - Key endpoints -- issues, signals, projects, goals, dashboard, and dispatch
- Code examples for creating issues and ingesting signals
- Links to full documentation and the machine-readable
llms.txtindex
When the microagent is active, OpenHands can create issues, ingest signals, check the dispatch queue, and report results without any additional configuration.
Adding MCP Support
For richer tool-based interaction, you can also configure the Loop MCP server. This gives OpenHands named tools like loop_get_next_task and loop_create_issue instead of relying on raw HTTP calls.
MCP support in OpenHands depends on your OpenHands version and configuration. Check the OpenHands MCP documentation for current support status.
If your OpenHands setup supports MCP, add the Loop server to your MCP configuration:
{
"mcpServers": {
"loop": {
"command": "npx",
"args": ["-y", "@dork-labs/loop-mcp"],
"env": {
"LOOP_API_KEY": "<your-api-key>",
"LOOP_API_URL": "http://localhost:5667"
}
}
}
}See the MCP Server docs for the full list of available tools and configuration options.
Autonomous Polling Pattern
To run OpenHands in a continuous loop -- pulling work from Loop, executing it, and reporting back -- use this pattern in your OpenHands prompt or automation script:
- Poll for work -- call
GET /api/dispatch/nextto claim the highest-priority unblocked issue. - Execute the task -- use the returned
promptfield as instructions. Ifpromptisnull, use the issue title and description. - Report results -- add a comment to the issue with
POST /api/issues/:id/commentsdescribing what was done. - Update status -- mark the issue as
donewithPATCH /api/issues/:idand setstatus: "done". - Repeat -- poll for the next issue.
# Example: poll for work and show what's next
curl -s http://localhost:5667/api/dispatch/next \
-H "Authorization: Bearer $LOOP_API_KEY" | jq .The dispatch endpoint uses FOR UPDATE SKIP LOCKED to ensure that concurrent agents never claim the same issue. See the dispatch docs for details on priority scoring and concurrency.
Next Steps
- Dispatch -- understand how Loop selects and scores work items.
- Signals -- learn how to feed external data into the Loop triage queue.
- Agent Skill -- explore the full skill package for additional agent context.
- MCP Server -- browse the complete list of MCP tools.