Container Use 扩展
🎥Plug & Play
Watch the demo
本教程介绍如何将 Container Use MCP 服务器 添加为 goose 扩展,让 goose 在隔离环境中工作。
快速安装
- goose Desktop
- goose CLI
命令
container-use stdio
配置
- 远程 MCP
- 本地 MCP
- goose Desktop
- goose CLI
- Launch the installer
- Click
Yesto confirm the installation - Click the button in the top-left to open the sidebar
- Navigate to the chat
- Run the
configurecommand:
goose configure
- Choose to add a
Command-line Extension.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◆ What type of extension would you like to add?
│ ○ Built-in Extension
│ ● Command-line Extension (Run a local command or script)
│ ○ Remote Extension (Streamable HTTP)
└
- Give your extension a name.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◆ What would you like to call this extension?
│ Container Use
└
- Enter the command to run when this extension is used.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◇ What would you like to call this extension?
│ Container Use
│
◆ What command should be run?
│ npx -y mcp-remote https://container-use.com/mcp
└
- Enter the number of seconds goose should wait for actions to complete before timing out. Default is
300seconds.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◇ What would you like to call this extension?
│ Container Use
│
◇ What command should be run?
│ npx -y mcp-remote https://container-use.com/mcp
│
◆ Please set the timeout for this tool (in secs):
│ 300
└
- Enter a description for this extension.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◇ What would you like to call this extension?
│ Container Use
│
◇ What command should be run?
│ npx -y mcp-remote https://container-use.com/mcp
│
◇ Please set the timeout for this tool (in secs):
│ 300
│
◆ Enter a description for this extension:
│ 使用 container-use 运行容器自动化
└
- Choose
Nowhen asked to add environment variables.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◇ What would you like to call this extension?
│ Container Use
│
◇ What command should be run?
│ npx -y mcp-remote https://container-use.com/mcp
│
◇ Please set the timeout for this tool (in secs):
│ 300
│
◇ Enter a description for this extension:
│ 使用 container-use 运行容器自动化
│
◆ Would you like to add environment variables?
│ No
│
└ Added Container Use extension
- goose Desktop
- goose CLI
- Launch the installer
- Click
Yesto confirm the installation - Click the button in the top-left to open the sidebar
- Navigate to the chat
- Run the
configurecommand:
goose configure
- Choose to add a
Command-line Extension.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◆ What type of extension would you like to add?
│ ○ Built-in Extension
│ ● Command-line Extension (Run a local command or script)
│ ○ Remote Extension (Streamable HTTP)
└
- Give your extension a name.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◆ What would you like to call this extension?
│ Container Use
└
- Enter the command to run when this extension is used.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◇ What would you like to call this extension?
│ Container Use
│
◆ What command should be run?
│ container-use stdio
└
- Enter the number of seconds goose should wait for actions to complete before timing out. Default is
300seconds.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◇ What would you like to call this extension?
│ Container Use
│
◇ What command should be run?
│ container-use stdio
│
◆ Please set the timeout for this tool (in secs):
│ 300
└
- Enter a description for this extension.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◇ What would you like to call this extension?
│ Container Use
│
◇ What command should be run?
│ container-use stdio
│
◇ Please set the timeout for this tool (in secs):
│ 300
│
◆ Enter a description for this extension:
│ 使用 container-use 运行容器自动化
└
- Choose
Nowhen asked to add environment variables.
┌ goose-configure
│
◇ What would you like to configure?
│ Add Extension
│
◇ What type of extension would you like to add?
│ Command-line Extension
│
◇ What would you like to call this extension?
│ Container Use
│
◇ What command should be run?
│ container-use stdio
│
◇ Please set the timeout for this tool (in secs):
│ 300
│
◇ Enter a description for this extension:
│ 使用 container-use 运行容器自动化
│
◆ Would you like to add environment variables?
│ No
│
└ Added Container Use extension
使用示例
下面是一个简单示例:把基于文件的待办应用改成使用 SQLite 数据库,并完成完整测试。这一切都在隔离的容器环境中进行。
信息
更多示例、常见工作流和故障排查提示,见隔离开发环境。
提示词
运行一个容器代理,添加把待办列表数据保存到 sqlite 的功能,构建并运行测试,但使用单独的 Git 分支,这样我的主代码保持安全。
goose 输出
我来帮你创建一个容器环境,在单独的 Git 分支上为待办列表应用添加 SQLite 功能。先创建环境并查看当前代码结构。
─── environment_create | containeruse ──────────────────────────
environment_source: ./examples/todo-list
explanation: ...
title: ...
现在配置环境所需的工具,然后继续开发 SQLite 功能:
─── environment_config | containeruse ──────────────────────────
config:
base_image: python:3.11-slim
setup_commands:
-
[REDACTED: 63 chars]
-
pip install pytest pytest-cov
environment_id: thankful-whale
environment_source: ./examples/todo-list
explanation: ...
等环境运行后再安装 pytest:
---
很好!我已经创建了一个容器环境,可以安全地为待办列表应用添加 SQLite 功能。先探索当前代码结构,然后创建新的 Git 分支。
---
现在我会创建基于 SQLite 的存储实现。首先,创建一个支持 SQLite 的新版 TaskManager:
---
## ✅ SQLite 功能已成功添加!
我已成功创建容器环境,并为你的待办列表应用添加了 SQLite 功能!完成的内容如下:
### 🎯 **已实现的功能**
1. **SQLite 数据库存储**
- 用 SQLite 数据库替换了纯文本文件存储
- 创建了带自增 ID 的正确数据库 schema
2. **增强的任务管理**
- 保留了全部原有功能(添加、列出、标记完成/未完成、删除、清空)
- 新增**统计功能**,显示完成率
- 用数据库 ID 改进了任务显示
3. **两个实现版本**
- `taskman_sqlite.py` - 带 Rich UI 的完整功能版
- `taskman_sqlite_simple.py` - 无外部依赖的简化版
### 🧪 **测试已完成**
- ✅ 创建了完整测试套件(`test_taskman_sqlite.py`)
- ✅ 构建了简单测试运行器(`test_simple.py`)
- ✅ 所有测试均通过
- ✅ 手动测试确认功能工作正常
### 📊 **现场演示结果**
# 成功添加任务
✓ Added task: Buy groceries
✓ Added task: Walk the dog
# 用 SQLite ID 列出任务
📋 Task List (SQLite)
# ID Status Task
1 1 ✓ Done Buy groceries
2 2 ○ Todo Walk the dog
# 统计功能正常
Task Statistics:
Total tasks: 2
Completed: 1
Pending: 1
Completion rate: 50.0%
# 数据库已验证
sqlite3 tasks.db "SELECT * FROM tasks;"
1|Buy groceries|1
2|Walk the dog|0
### 🔒 **安全开发**
- ✅ 使用了单独的容器环境
- ✅ 所有更改都与主代码隔离
- ✅ 保留了原始实现
- ✅ 保持了向后兼容
### 📁 **创建的文件**
- `taskman_sqlite_simple.py` - 主要的 SQLite 实现
- `test_simple.py` - 测试套件
- `SQLITE_FEATURE_README.md` - 完整文档
- `tasks.db` - SQLite 数据库文件
SQLite 实现功能完整,可以立即使用!基于文件的原版本保持不变,因此你可以安全评估新的 SQLite 功能,而不会危及现有代码。