Skip to content

Commit 6621ea9

Browse files
authored
Merge pull request #1925 from dgageot/aqua
Support auto-downloading tools
2 parents 7ad8eee + c0bfc6e commit 6621ea9

File tree

21 files changed

+2579
-5
lines changed

21 files changed

+2579
-5
lines changed

agent-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,10 @@
844844
"items": {
845845
"type": "string"
846846
}
847+
},
848+
"version": {
849+
"type": "string",
850+
"description": "Package reference for auto-installation of MCP/LSP tool binaries. Format: 'owner/repo' or 'owner/repo@version'. Set to 'false' to disable auto-install for this toolset."
847851
}
848852
},
849853
"additionalProperties": false,

docs/configuration/overview/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ API keys and secrets are read from environment variables — never stored in con
146146
| `XAI_API_KEY` | xAI |
147147
| `NEBIUS_API_KEY` | Nebius |
148148

149+
**Tool Auto-Installation:**
150+
151+
| Variable | Description |
152+
| --------------------- | --------------------------------------------------------------- |
153+
| `DOCKER_AGENT_AUTO_INSTALL` | Set to `false` to disable automatic tool installation |
154+
| `DOCKER_AGENT_TOOLS_DIR` | Override the base directory for installed tools (default: `~/.cagent/tools/`) |
155+
149156
<div class="callout callout-warning">
150157
<div class="callout-title">⚠️ Important
151158
</div>

docs/configuration/tools/index.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ toolsets:
321321
| `tools` | array | Optional: only expose these tools |
322322
| `env` | array | Environment variables (`"KEY=value"` format) |
323323
| `instruction` | string | Custom instructions injected into the agent's context |
324+
| `version` | string | Package reference for [auto-installing](#auto-installing-tools) the command binary |
324325

325326
### Remote MCP (SSE / Streamable HTTP)
326327

@@ -343,6 +344,81 @@ toolsets:
343344
| `remote.transport_type` | string | `sse` or `streamable` |
344345
| `remote.headers` | object | HTTP headers (typically for auth) |
345346

347+
## Auto-Installing Tools
348+
349+
When configuring MCP or LSP tools that require a binary command, cagent can **automatically download and install** the command if it's not already available on your system. This uses the [aqua registry](https://github.com/aquaproj/aqua-registry) — a curated index of CLI tool packages.
350+
351+
### How It Works
352+
353+
1. When a toolset with a `command` is loaded, cagent checks if the command is available in your `PATH`
354+
2. If not found, it checks the cagent tools directory (`~/.cagent/tools/bin/`)
355+
3. If still not found, it looks up the command in the aqua registry and installs it automatically
356+
357+
### Explicit Package Reference
358+
359+
Use the `version` property to specify exactly which package to install:
360+
361+
```yaml
362+
toolsets:
363+
- type: mcp
364+
command: gopls
365+
version: "golang/tools@v0.25.0"
366+
args: ["mcp"]
367+
- type: lsp
368+
command: rust-analyzer
369+
version: "rust-lang/rust-analyzer@2024-01-01"
370+
file_types: [".rs"]
371+
```
372+
373+
The format is `owner/repo` or `owner/repo@version`. When a version is omitted, the latest release is used.
374+
375+
### Automatic Detection
376+
377+
If the `version` property is not set, cagent tries to auto-detect the package from the command name by searching the aqua registry:
378+
379+
```yaml
380+
toolsets:
381+
- type: mcp
382+
command: gopls # auto-detected as golang/tools
383+
args: ["mcp"]
384+
```
385+
386+
### Disabling Auto-Install
387+
388+
You can disable auto-installation in two ways:
389+
390+
**Per toolset** — set `version` to `"false"` or `"off"`:
391+
392+
```yaml
393+
toolsets:
394+
- type: mcp
395+
command: my-custom-server
396+
version: "false"
397+
```
398+
399+
**Globally** — set the `DOCKER_AGENT_AUTO_INSTALL` environment variable:
400+
401+
```bash
402+
export DOCKER_AGENT_AUTO_INSTALL=false
403+
```
404+
405+
### Environment Variables
406+
407+
| Variable | Default | Description |
408+
| --------------------- | ---------------------- | ------------------------------------------------ |
409+
| `DOCKER_AGENT_AUTO_INSTALL` | (enabled) | Set to `false` to disable all auto-installation |
410+
| `DOCKER_AGENT_TOOLS_DIR` | `~/.cagent/tools/` | Base directory for installed tools |
411+
| `GITHUB_TOKEN` | — | GitHub token to raise API rate limits (optional) |
412+
413+
Installed binaries are placed in `~/.cagent/tools/bin/` and cached so they are only downloaded once.
414+
415+
<div class="callout callout-tip">
416+
<div class="callout-title">💡 Tip
417+
</div>
418+
<p>Auto-install supports both Go packages (via <code>go install</code>) and GitHub release binaries (via archive download). The aqua registry metadata determines which method is used.</p>
419+
420+
</div>
421+
346422
## Tool Filtering
347423

348424
Toolsets may expose many tools. Use the `tools` property to whitelist only the ones your agent needs. This works for any toolset type — not just MCP:

docs/tools/lsp/index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ agents:
4444
| `args` | array | ✗ | Command-line arguments for the LSP server |
4545
| `env` | object | ✗ | Environment variables for the LSP process |
4646
| `file_types` | array | ✗ | File extensions this LSP handles (e.g., `[".go", ".mod"]`) |
47+
| `version` | string | ✗ | Package reference for [auto-installing](/configuration/tools/#auto-installing-tools) the command binary (e.g., `"golang/tools@v0.25.0"`) |
4748

4849
## Available Tools
4950

@@ -77,6 +78,7 @@ Here are configurations for popular languages:
7778
toolsets:
7879
- type: lsp
7980
command: gopls
81+
version: "golang/tools@v0.25.0" # optional: auto-install if not in PATH
8082
file_types: [".go"]
8183
```
8284

@@ -196,9 +198,9 @@ All LSP tools use **1-based** line and character positions:
196198
}
197199
```
198200

199-
<div class="callout callout-warning">
200-
<div class="callout-title">⚠️ Server Installation
201+
<div class="callout callout-tip">
202+
<div class="callout-title">💡 Auto-Installation
201203
</div>
202-
<p>The LSP server must be installed and available in the system PATH. docker-agent does not install LSP servers automatically. Install them using your language's package manager (e.g., <code>go install golang.org/x/tools/gopls@latest</code>).</p>
204+
<p>docker-agent can automatically download and install LSP servers if they are not found in your PATH. Use the <code>version</code> property to specify a package, or let docker-agent auto-detect it from the command name. See <a href="/configuration/tools/#auto-installing-tools">Auto-Installing Tools</a> for details.</p>
203205

204206
</div>

examples/elicitation/demo.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ agents:
3737
toolsets:
3838
- type: mcp
3939
command: uvx
40+
version: "astral-sh/uv"
4041
args:
4142
["--with", "mcp[cli]", "mcp", "run", "examples/elicitation/server.py"]

examples/finance.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ agents:
5050
toolsets:
5151
- type: mcp
5252
command: uvx
53+
version: "astral-sh/uv"
5354
args: ["yfmcp"]
5455

5556
web_search_agent:

examples/gopher.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ agents:
6565
- type: todo
6666
- type: mcp
6767
command: gopls
68+
version: "golang/tools@v0.25.0"
6869
args: ["mcp"]
6970
commands:
7071
fix-lint:
@@ -164,6 +165,7 @@ agents:
164165
- type: shell
165166
- type: mcp
166167
command: gopls
168+
version: "golang/tools@v0.25.0"
167169
args: ["mcp"]
168170

169171
librarian:

examples/modernize-go-tests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ agents:
8787
- type: todo
8888
- type: mcp
8989
command: gopls
90+
version: "golang/tools@v0.25.0"
9091
args: ["mcp"]
9192
tools:
9293
[

pkg/config/latest/types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,12 @@ type Toolset struct {
542542
Remote Remote `json:"remote"`
543543
Config any `json:"config,omitempty"`
544544

545+
// For `mcp` and `lsp` tools - version/package reference for auto-installation.
546+
// Format: "owner/repo" or "owner/repo@version"
547+
// When empty and auto-install is enabled, cagent auto-detects from the command name.
548+
// Set to "false" or "off" to disable auto-install for this toolset.
549+
Version string `json:"version,omitempty"`
550+
545551
// For the `a2a` and `openapi` tools
546552
Name string `json:"name,omitempty"`
547553
URL string `json:"url,omitempty"`

pkg/config/latest/validate.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ func (t *Toolset) validate() error {
8282
if t.Shared && t.Type != "todo" {
8383
return errors.New("shared can only be used with type 'todo'")
8484
}
85+
if t.Version != "" && t.Type != "mcp" && t.Type != "lsp" {
86+
return errors.New("version can only be used with type 'mcp' or 'lsp'")
87+
}
8588
if t.Command != "" && t.Type != "mcp" && t.Type != "lsp" {
8689
return errors.New("command can only be used with type 'mcp' or 'lsp'")
8790
}

0 commit comments

Comments
 (0)