8a21a212f8
Deploy Documentation / deploy (push) Has been cancelled
Canary / build-cli (push) Has been skipped
Canary / Upload Install Script (push) Has been skipped
Canary / bundle-desktop (push) Has been skipped
Canary / bundle-desktop-intel (push) Has been skipped
Canary / bundle-desktop-linux (push) Has been skipped
Canary / bundle-desktop-windows (push) Has been skipped
Canary / bundle-desktop-windows-cuda (push) Has been skipped
Canary / Release (push) Has been skipped
Cargo Deny / deny (push) Has been skipped
Unused Dependencies / machete (push) Has been skipped
Canary / Prepare Version (push) Failing after 1s
Live Provider Tests / check-fork (push) Failing after 0s
Create Minor Release PR / check-version-bump-pr (push) Has been skipped
Publish Ask AI Bot Docker Image / docker (push) Failing after 1s
Live Provider Tests / changes (push) Has been skipped
Scorecard supply-chain security / Scorecard analysis (push) Has been skipped
Publish Docker Image / docker (push) Failing after 1s
CI / changes (push) Failing after 8s
Create Minor Release PR / release (push) Has been skipped
Live Provider Tests / Smoke Tests (push) Has been cancelled
Live Provider Tests / Smoke Tests (Code Execution) (push) Has been cancelled
Live Provider Tests / Compaction Tests (push) Has been cancelled
CI / Build Rust Project on Windows (push) Has been cancelled
Live Provider Tests / Build Binary (push) Has been cancelled
CI / Lint Rust Code (push) Has been cancelled
CI / Check Generated Schemas are Up-to-Date (push) Has been cancelled
CI / Test and Lint Electron Desktop App (push) Has been cancelled
CI / Check Rust Code Format (push) Has been cancelled
CI / Build and Test Rust Project (push) Has been cancelled
CI / Check MSRV (push) Has been cancelled
80 lines
2.5 KiB
Markdown
80 lines
2.5 KiB
Markdown
---
|
|
title: Code Mode Extension
|
|
description: Execute JavaScript code to interact with multiple MCP tools
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
import { PlatformExtensionNote } from '@site/src/components/PlatformExtensionNote';
|
|
import GooseBuiltinInstaller from '@site/src/components/GooseBuiltinInstaller';
|
|
|
|
The Code Mode extension enables [Code Mode](/docs/guides/managing-tools/code-mode), a programmatic approach for interacting with MCP tools.
|
|
|
|
The Code Mode extension is an MCP server that exposes three meta-tools. When Code Mode is enabled, the LLM writes JavaScript code that goose executes using a Deno-based runtime called [Port of Context](https://github.com/AdrianCole/pctx) to discover tools, learn their interfaces, and call them programmatically.
|
|
|
|
This helps manage context window usage more efficiently when multiple extensions are enabled and when performing workflows with multiple tool calls.
|
|
|
|
## Configuration
|
|
|
|
<PlatformExtensionNote defaultEnabled={false} />
|
|
|
|
<Tabs groupId="interface">
|
|
<TabItem value="ui" label="goose Desktop" default>
|
|
<GooseBuiltinInstaller
|
|
extensionName="Code Mode"
|
|
description="Execute JavaScript code to interact with MCP tools efficiently"
|
|
/>
|
|
</TabItem>
|
|
<TabItem value="cli" label="goose CLI">
|
|
|
|
1. Run the `configure` command:
|
|
```sh
|
|
goose configure
|
|
```
|
|
|
|
2. Choose to `Toggle Extensions`
|
|
```sh
|
|
┌ goose-configure
|
|
│
|
|
◇ What would you like to configure?
|
|
│ Toggle Extensions
|
|
│
|
|
◆ Enable extensions: (use "space" to toggle and "enter" to submit)
|
|
// highlight-start
|
|
│ ● code_execution
|
|
// highlight-end
|
|
└ Extension settings updated successfully
|
|
```
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
## Example Usage
|
|
|
|
In this example, we'll ask goose to compile a report that requires multiple tool calls.
|
|
|
|
### goose Prompt
|
|
|
|
```
|
|
Create a LOG.md file with the current git branch, last 3 commits, and the version from package.json
|
|
```
|
|
|
|
### goose Output
|
|
|
|
:::note Desktop
|
|
I'll help you create a LOG.md file with the git branch, last 3 commits, and version from package.json. Let me gather all this information in one operation.
|
|
|
|
`Execute Code code: import { shell, text_editor } from "developer" ...`
|
|
|
|
Let me check the package.json path first:
|
|
|
|
`Execute Code code: import { shell, text_editor } from "developer" ...`
|
|
|
|
Perfect! I've created the **LOG.md** file with:
|
|
|
|
- ✅ **Current git branch**
|
|
- ✅ **Last 3 commits** (with hash, message, author, and relative time)
|
|
- ✅ **Version** from ui/desktop/package.json
|
|
|
|
The file has been saved to the root directory as `LOG.md`.
|
|
:::
|