Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADD THE WORDS CODE MODE ON HERE..BIG LETTERS ..or share the canva file with me so i can edit. this is one we want people to click a ton 🔥 thank you for writing this!!!

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions documentation/blog/2025-12-15-code-mode-mcp/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: "Code Mode MCP in goose"
description: An emerging approach to MCP tool calling gets an open source implementation in goose
authors:
- alexhancock
---

![code mode MCP in goose!](header-image.jpg)

# Code Mode MCP

There is an emerging approach to MCP tool calling referred to as "sandbox mode" or "code mode". These ideas were initially
presented by Cloudflare in their [Code Mode: the better way to use MCP](https://blog.cloudflare.com/code-mode/) post and Anthropic
in their [Code execution with MCP: Building more efficient agents](https://www.anthropic.com/engineering/code-execution-with-mcp)
posts. Since the approach and the benefits are clearly laid out in those posts I will summarize them here.

<!-- truncate -->

## The approach

### Summary

* Instead of exposing the tools directly to the model an MCP client application can:
* Generate a programmatic interface to these same tools (typically JS or TS powered)
* Provide a limited set of tools to the model (search available modules/tool source code, read the source code for a tool, and then a tool to execute some code)
* Run the code the model generates to call the programmatic API in a sandboxed environment for safety

### Benefits

* The model can progressively discover relevant tools, without all server and tool definitions in the context window from the beginning
* The model can chain tool call results into inputs to further tool calls without the intermediate results needing to flow back to the model - this saves on tokens and avoids exposing potentially sensitive data to the model unnecessarily
* The models pre-training datasets have made them very efficient at analyzing large programmatic APIs and writing code to call them, as compared to having been trained only on contrived examples of MCP tool calling
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing possessive apostrophe. "models pre-training datasets" should be "models' pre-training datasets" (or "model's pre-training datasets" if referring to a singular model).

Suggested change
* The models pre-training datasets have made them very efficient at analyzing large programmatic APIs and writing code to call them, as compared to having been trained only on contrived examples of MCP tool calling
* The models' pre-training datasets have made them very efficient at analyzing large programmatic APIs and writing code to call them, as compared to having been trained only on contrived examples of MCP tool calling

Copilot uses AI. Check for mistakes.

## In goose

In v1.17.0 of goose, we've introduced an open source implementation of this idea in a new platform extension called: Code Execution.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not out yet..so we should make it clear to people that it's coming up.

Because the blog is going to merge and go live immediately..and people will say where is code mode, but we're all on 1.16.1

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah agreed! going to wait for release

Our implementation generates a JavaScript interface representing the connected MCP tools and then lets the model write code to run
against it in [boa](https://github.com/boa-dev/boa) which is an embeddable Javascript engine. One neat feature of boa we were able
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent capitalization of "JavaScript". The term should be consistently capitalized as "JavaScript" (capital S) throughout the document, but line 38 uses "Javascript".

Suggested change
against it in [boa](https://github.com/boa-dev/boa) which is an embeddable Javascript engine. One neat feature of boa we were able
against it in [boa](https://github.com/boa-dev/boa) which is an embeddable JavaScript engine. One neat feature of boa we were able

Copilot uses AI. Check for mistakes.
to take advantage of was the concept of [NativeFunction](https://docs.rs/boa_engine/latest/boa_engine/native_function/struct.NativeFunction.html).

In boa, a `NativeFunction` is something which exposes a function in the embedded JavaScript environment which calls back into a
natively implemented rust function. This is perfect for the calls originating in JS and then routing the tool call to the underlying
MCP server with ease!

## Help us evaluate it

Our hope is that we improve tool calling performance and handling of large numbers of tools in goose, but
also provide an open source implementation of this emerging approach.

* Try out the feature by enabling the "Code Execution" extension in v1.17.0 or later of goose by clicking extensions on the left side of the desktop app or running `goose configure` on cli
* Please give us feedback on how it works for you by joining our [discord](https://discord.gg/goose-oss).
* The source code is [here](https://github.com/block/goose/blob/main/crates/goose/src/agents/code_execution_extension.rs)

Kudos to my colleague [Mic Neale](https://github.com/michaelneale) for collaborating with me on the implementation!

<head>
<meta property="og:title" content="Code Mode MCP in goose" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://block.github.io/goose/blog/2025/12/15/code-mode-mcp-in-goose" />
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The URL path in the og:url meta tag references "2025/12/15" which is inconsistent with the future date issue. This should match the actual publication date of the blog post.

Suggested change
<meta property="og:url" content="https://block.github.io/goose/blog/2025/12/15/code-mode-mcp-in-goose" />
<meta property="og:url" content="https://block.github.io/goose/blog/2024/12/15/code-mode-mcp-in-goose" />

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The og:url metadata uses "code-mode-mcp-in-goose" but the folder is named "code-mode-mcp". Based on other blog posts, the URL slug should match the folder name. The URL should be "https://block.github.io/goose/blog/2025/12/15/code-mode-mcp" instead of "code-mode-mcp-in-goose".

Suggested change
<meta property="og:url" content="https://block.github.io/goose/blog/2025/12/15/code-mode-mcp-in-goose" />
<meta property="og:url" content="https://block.github.io/goose/blog/2025/12/15/code-mode-mcp" />

Copilot uses AI. Check for mistakes.
<meta property="og:description" content="An emerging approach to MCP tool calling gets an open source implementation in goose" />
<meta property="og:image" content="https://block.github.io/goose/assets/images/header-image-1fa39f1d26aea7722e2c10fc424804f5.jpg" />
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content="block.github.io/goose" />
<meta name="twitter:title" content="Code Mode MCP in goose" />
<meta name="twitter:description" content="An emerging approach to MCP tool calling gets an open source implementation in goose" />
<meta name="twitter:image" content="https://block.github.io/goose/assets/images/header-image-1fa39f1d26aea7722e2c10fc424804f5.jpg" />
</head>
9 changes: 9 additions & 0 deletions documentation/blog/authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,12 @@ jeuston:
socials:
linkedin: joeeuston
github: joeeuston-dev

alexhancock:
name: Alex Hancock
title: Software Engineer
image_url: https://avatars.githubusercontent.com/u/427516?v=4
page: true
socials:
linkedin: alexjhancock
github: alexhancock
Loading