|
| 1 | +--- |
| 2 | +title: Claude Code |
| 3 | +description: "Setup guide for Claude Code with Container Use" |
| 4 | +icon: robot |
| 5 | +--- |
| 6 | + |
| 7 | +## Install Claude Code |
| 8 | + |
| 9 | +```sh |
| 10 | +npm install -g @anthropic-ai/claude-code |
| 11 | +``` |
| 12 | + |
| 13 | +## Add MCP Configuration |
| 14 | + |
| 15 | +```sh |
| 16 | +cd /path/to/repository |
| 17 | +claude mcp add container-use -- <full path to cu command> stdio |
| 18 | +``` |
| 19 | + |
| 20 | +## Add Agent Rules (Optional) |
| 21 | + |
| 22 | +Save the CLAUDE.md file at the root of your repository: |
| 23 | + |
| 24 | +```sh |
| 25 | +curl https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md >> CLAUDE.md |
| 26 | +``` |
| 27 | + |
| 28 | +## Trust Only Container Use Tools (Optional) |
| 29 | + |
| 30 | +For maximum security, restrict Claude Code to only use Container Use tools: |
| 31 | + |
| 32 | +```sh |
| 33 | +claude --allowedTools mcp__container-use__environment_checkpoint,mcp__container-use__environment_create,mcp__container-use__environment_add_service,mcp__container-use__environment_file_delete,mcp__container-use__environment_file_list,mcp__container-use__environment_file_read,mcp__container-use__environment_file_write,mcp__container-use__environment_open,mcp__container-use__environment_run_cmd,mcp__container-use__environment_update |
| 34 | +``` |
| 35 | + |
| 36 | +<Info> |
| 37 | + Learn more: [Claude Code MCP |
| 38 | + Documentation](https://docs.anthropic.com/en/docs/claude-code/tutorials#set-up-model-context-protocol-mcp) |
| 39 | +</Info> |
| 40 | + |
| 41 | +## Verification |
| 42 | + |
| 43 | +After setting up Claude Code, verify Container Use is working: |
| 44 | + |
| 45 | +1. **Check MCP Connection**: Claude Code should recognize Container Use tools |
| 46 | +2. **Test Environment Creation**: Ask Claude Code to create a new environment |
| 47 | +3. **Verify Isolation**: Multiple environments should work independently |
| 48 | + |
| 49 | +## Troubleshooting |
| 50 | + |
| 51 | +<AccordionGroup> |
| 52 | + <Accordion title="Claude Code doesn't recognize Container Use"> |
| 53 | + - Verify the `cu` command is in your PATH: `which cu` |
| 54 | + - Check MCP configuration syntax |
| 55 | + - Restart Claude Code after configuration changes |
| 56 | + </Accordion> |
| 57 | + |
| 58 | + <Accordion title="Permission errors"> |
| 59 | + - Ensure Docker is running and accessible |
| 60 | + - Check file permissions for configuration files |
| 61 | + - Verify `cu stdio` command works: `echo '{}' | cu stdio` |
| 62 | + </Accordion> |
| 63 | + |
| 64 | + <Accordion title="Tools not appearing"> |
| 65 | + - Check your Claude Code MCP server logs |
| 66 | + - Verify Container Use tools are enabled in settings |
| 67 | + </Accordion> |
| 68 | +</AccordionGroup> |
| 69 | + |
| 70 | +## Next Steps |
| 71 | + |
| 72 | +<CardGroup cols={2}> |
| 73 | + <Card title="Back to Quickstart" icon="rocket" href="/quickstart"> |
| 74 | + Return to the quickstart guide to create your first environment |
| 75 | + </Card> |
| 76 | + <Card |
| 77 | + title="Join Community" |
| 78 | + icon="discord" |
| 79 | + href="https://discord.gg/YXbtwRQv" |
| 80 | + > |
| 81 | + Get help and share experiences in #container-use |
| 82 | + </Card> |
| 83 | +</CardGroup> |
0 commit comments