基于 MCP 的代码执行:构建更高效的智能体

Code execution with MCP: Building more efficient agents

Anthropic · 2025-11-04 · Anthropic Engineering ↗

打开互动全文版(逐段中英对照 + 针对本篇提问)→

摘要 · Abstract

模型上下文协议(MCP)已成为连接 AI 智能体与外部工具和数据的事实标准,但随着智能体接入数十个 MCP 服务器上的成百上千个工具,预先加载全部工具定义并通过上下文窗口传递中间结果会拖慢智能体速度并增加成本。本文主张,将 MCP 服务器以代码 API 而非直接工具调用的形式呈现,让智能体编写代码与之交互,从而同时解决上述两个难题:智能体可以按需只加载所需的工具,并在执行环境中处理数据后再将结果传回模型。例如,将工具以文件系统上的文件树形式呈现,在文中 Google Drive 到 Salesforce 的示例里可将 token 用量从 150,000 降至 2,000,节省 98.7%;而在代码中过滤大型数据集、在单一步骤中执行循环和条件判断、将中间结果保留在执行环境中,则进一步提升了上下文效率、安全性和状态持久性。文章最后指出,代码执行将成熟的软件工程模式应用于智能体,但运行智能体生成的代码需要具备资源限制和监控的安全沙箱环境,因此 token 成本降低、延迟下降和工具组合能力提升等收益应与这些实现成本相权衡。

The Model Context Protocol (MCP) has become the de-facto standard for connecting AI agents to external tools and data, but as agents connect to hundreds or thousands of tools across dozens of MCP servers, loading all tool definitions upfront and passing intermediate results through the context window slows agents down and increases costs. This article argues that presenting MCP servers as code APIs rather than direct tool calls lets agents write code to interact with them, addressing both challenges: agents can load only the tools they need on demand and process data in the execution environment before passing results back to the model. Presenting tools as a file tree on a filesystem, for example, reduces token usage from 150,000 to 2,000 tokens in the article's Google Drive to Salesforce example, a 98.7% saving, while filtering large datasets in code, executing loops and conditionals in a single step, and keeping intermediate results in the execution environment further improve context efficiency, security, and state persistence. The article concludes that code execution applies established software engineering patterns to agents, but notes that running agent-generated code requires a secure sandboxed environment with resource limits and monitoring, so the benefits of reduced token costs, lower latency, and improved tool composition should be weighed against these implementation costs.

核心贡献 · Key contributions

局限 · Limitations

章节 · Sections(共 12)

全文 · Full text(逐段中英对照)

基于 MCP 的代码执行:构建更高效的智能体 Code execution with MCP:Building more efficient agents

* 01 工具消耗过多 token 会降低智能体效率

* 01 Excessive token consumption from tools makes agents less efficient

* 02 基于 MCP 的代码执行提升上下文效率

* 02 Code execution with MCP improves context efficiency

* 03 基于 MCP 的代码执行的优势

* 03 Benefits of code execution with MCP

2025 年 11 月 24 日 在 Claude 开发者平台推出高级工具使用功能

Nov 24, 2025 Introducing advanced tool use on the Claude Developer Platform

模型上下文协议(MCP)是连接 AI 智能体与外部系统的开放标准。传统上,将智能体连接到工具和数据需要为每一对连接进行自定义集成,这造成了碎片化和重复工作,使得真正互联的系统难以规模化。MCP 提供了一个通用协议——开发者只需在智能体中实现一次 MCP,即可解锁整个集成生态系统。

The Model Context Protocol (MCP) is an open standard for connecting AI agents to external systems. Connecting agents to tools and data traditionally requires a custom integration for each pairing, creating fragmentation and duplicated effort that makes it difficult to scale truly connected systems. MCP provides a universal protocol—developers implement MCP once in their agent and it unlocks an entire ecosystem of integrations.

自 2024 年 11 月推出 MCP 以来,其采用速度十分迅速:社区已构建了数千个 MCP 服务器,所有主流编程语言均有可用的 SDK,业界也已将 MCP 采纳为连接智能体与工具及数据的事实标准。

Since launching MCP in November 2024, adoption has been rapid: the community has built thousands of MCP servers, SDKs are available for all major programming languages, and the industry has adopted MCP as the de-facto standard for connecting agents to tools and data.

如今,开发者常常构建能够访问数十个 MCP 服务器中数百乃至数千个工具的智能体。然而,随着所连接工具数量的增长,预先加载全部工具定义并通过上下文窗口传递中间结果会拖慢智能体并增加成本。

Today developers routinely build agents with access to hundreds or thousands of tools across dozens of MCP servers. However, as the number of connected tools grows, loading all tool definitions upfront and passing intermediate results through the context window slows down agents and increases costs.

在本篇博客中,我们将探讨代码执行如何使智能体能够更高效地与 MCP 服务器交互,在减少 token 使用量的同时处理更多工具。

In this blog we'll explore how code execution can enable agents to interact with MCP servers more efficiently, handling more tools while using fewer tokens.

工具导致的过度 token 消耗使智能体效率降低 Excessive token consumption from tools makes agents less efficient

随着 MCP 使用规模的扩大,有两种常见模式会增加智能体的成本与延迟:

As MCP usage scales, there are two common patterns that can increase agent cost and latency:

1. 工具定义使上下文窗口过载;

1. Tool definitions overload the context window;

2. 中间工具结果消耗额外的 token。

2. Intermediate tool results consume additional tokens.

1. 工具定义使上下文窗口过载 1. Tool definitions overload the context window

大多数 MCP 客户端会预先将所有工具定义直接加载到上下文窗口中,并通过直接的工具调用语法将其暴露给模型。这些工具定义可能如下所示:

Most MCP clients load all tool definitions upfront directly into context, exposing them to the model using a direct tool-calling syntax. These tool definitions might look like:

``` gdrive.getDocument Description: Retrieves a document from Google Drive Parameters: documentId (required, string): The ID of the document to retrieve fields (optional, string): Specific fields to return Returns: Document object with title, body content, metadata, permissions, etc. ```

``` gdrive.getDocument Description: Retrieves a document from Google Drive Parameters: documentId (required, string): The ID of the document to retrieve fields (optional, string): Specific fields to return Returns: Document object with title, body content, metadata, permissions, etc. ```

``` salesforce.updateRecord Description: Updates a record in Salesforce Parameters: objectType (required, string): Type of Salesforce object (Lead, Contact, Account, etc.) recordId (required, string): The ID of the record to update data (required, object): Fields to update with their new values Returns: Updated record object with confirmation ```

``` salesforce.updateRecord Description: Updates a record in Salesforce Parameters: objectType (required, string): Type of Salesforce object (Lead, Contact, Account, etc.) recordId (required, string): The ID of the record to update data (required, object): Fields to update with their new values Returns: Updated record object with confirmation ```

工具描述会占用更多上下文窗口空间,从而增加响应时间和成本。当智能体连接数千个工具时,它们在读取请求之前就需要处理数十万个 token。

Tool descriptions occupy more context window space, increasing response time and costs. In cases where agents are connected to thousands of tools, they'll need to process hundreds of thousands of tokens before reading a request.

2. 中间工具结果消耗额外 token 2. Intermediate tool results consume additional tokens

大多数 MCP 客户端允许模型直接调用 MCP 工具。例如,你可以要求你的智能体:“从 Google Drive 下载我的会议记录,并将其附加到 Salesforce 线索上。”

Most MCP clients allow models to directly call MCP tools. For example, you might ask your agent: "Download my meeting transcript from Google Drive and attach it to the Salesforce lead."

``` TOOL CALL: gdrive.getDocument(documentId: "abc123") → returns "Discussed Q4 goals...\n[full transcript text]" (loaded into model context) TOOL CALL: salesforce.updateRecord( objectType: "SalesMeeting", recordId: "00Q5f000001abcXYZ", data: { "Notes": "Discussed Q4 goals...\n[full transcript text written out]" } ) (model needs to write entire transcript into context again) ```

``` TOOL CALL: gdrive.getDocument(documentId: "abc123") → returns "Discussed Q4 goals...\n[full transcript text]" (loaded into model context) TOOL CALL: salesforce.updateRecord( objectType: "SalesMeeting", recordId: "00Q5f000001abcXYZ", data: { "Notes": "Discussed Q4 goals...\n[full transcript text written out]" } ) (model needs to write entire transcript into context again) ```

每个中间结果都必须经过模型。在此示例中,完整的调用记录会流经模型两次。对于一场 2 小时的销售会议,这可能意味着要额外处理 50,000 个 token。更大的文档甚至可能超出上下文窗口限制,从而中断工作流。

Every intermediate result must pass through the model. In this example, the full call transcript flows through twice. For a 2-hour sales meeting, that could mean processing an additional 50,000 tokens. Even larger documents may exceed context window limits, breaking the workflow.

对于大型文档或复杂数据结构,模型在工具调用之间复制数据时可能更容易出错。

With large documents or complex data structures, models may be more likely to make mistakes when copying data between tool calls.

基于代码执行的 MCP 上下文效率提升 Code execution with MCP improves context efficiency

随着代码执行环境在智能体中日益普及,一种解决方案是将 MCP 服务器以代码 API 的形式呈现,而非直接的工具调用。智能体随后可以编写代码与 MCP 服务器交互。这一方法同时应对了两项挑战:智能体可以只加载所需的工具,并在执行环境中处理数据后再将结果传回模型。

With code execution environments becoming more common for agents, a solution is to present MCP servers as code APIs rather than direct tool calls. The agent can then write code to interact with MCP servers. This approach addresses both challenges: agents can load only the tools they need and process data in the execution environment before passing results back to the model.

实现方式有多种。一种方法是为已连接的 MCP 服务器中所有可用工具生成文件树。以下是使用 TypeScript 的实现:

There are a number of ways to do this. One approach is to generate a file tree of all available tools from connected MCP servers. Here's an implementation using TypeScript:

``` servers ├── google-drive │ ├── getDocument.ts │ ├── ... (other tools) │ └── index.ts ├── salesforce │ ├── updateRecord.ts │ ├── ... (other tools) │ └── index.ts └── ... (other servers) ```

``` servers ├── google-drive │ ├── getDocument.ts │ ├── ... (other tools) │ └── index.ts ├── salesforce │ ├── updateRecord.ts │ ├── ... (other tools) │ └── index.ts └── ... (other servers) ```

随后每个工具对应一个文件,大致如下:

Then each tool corresponds to a file, something like:

``` // ./servers/google-drive/getDocument.ts import { callMCPTool } from "../../../client.js"; interface GetDocumentInput { documentId: string; } interface GetDocumentResponse { content: string; } /* Read a document from Google Drive */ export async function getDocument(input: GetDocumentInput): Promise<GetDocumentResponse> { return callMCPTool<GetDocumentResponse>('google_drive__get_document', input); } ```

``` // ./servers/google-drive/getDocument.ts import { callMCPTool } from "../../../client.js"; interface GetDocumentInput { documentId: string; } interface GetDocumentResponse { content: string; } /* Read a document from Google Drive */ export async function getDocument(input: GetDocumentInput): Promise<GetDocumentResponse> { return callMCPTool<GetDocumentResponse>('google_drive__get_document', input); } ```

上面 Google Drive 到 Salesforce 的示例就变成了如下代码:

Our Google Drive to Salesforce example above becomes the code:

``` // Read transcript from Google Docs and add to Salesforce prospect import * as gdrive from './servers/google-drive'; import * as salesforce from './servers/salesforce'; const transcript = (await gdrive.getDocument({ documentId: 'abc123' })).content; await salesforce.updateRecord({ objectType: 'SalesMeeting', recordId: '00Q5f000001abcXYZ', data: { Notes: transcript } }); ```

``` // Read transcript from Google Docs and add to Salesforce prospect import * as gdrive from './servers/google-drive'; import * as salesforce from './servers/salesforce'; const transcript = (await gdrive.getDocument({ documentId: 'abc123' })).content; await salesforce.updateRecord({ objectType: 'SalesMeeting', recordId: '00Q5f000001abcXYZ', data: { Notes: transcript } }); ```

智能体通过浏览文件系统来发现工具:列出 \(./servers/\) 目录以查找可用的服务器(如 \(google-drive\) 和 \(salesforce\)),然后读取它所需的具体工具文件(如 \(getDocument.ts\) 和 \(updateRecord.ts\))以了解每个工具的接口。这使得智能体只需加载当前任务所需的定义。这将 token 用量从 150,000 个 token 降至 2,000 个 token——节省了 98.7% 的时间与成本。

The agent discovers tools by exploring the filesystem: listing the \(./servers/\) directory to find available servers (like \(google-drive\) and \(salesforce\)), then reading the specific tool files it needs (like \(getDocument.ts\) and \(updateRecord.ts\)) to understand each tool's interface. This lets the agent load only the definitions it needs for the current task. This reduces the token usage from 150,000 tokens to 2,000 tokens—a time and cost saving of 98.7%.

Cloudflare 也发表了类似发现,将使用 MCP 的代码执行称为“Code Mode”。其核心洞见相同:LLM 擅长编写代码,开发者应利用这一优势来构建能更高效地与 MCP 服务器交互的智能体。

Cloudflare published similar findings, referring to code execution with MCP as "Code Mode." The core insight is the same: LLMs are adept at writing code, and developers should take advantage of this strength to build agents that interact with MCP servers more efficiently.

使用 MCP 进行代码执行的优势 Benefits of code execution with MCP

借助 MCP 进行代码执行,智能体能够更高效地利用上下文:按需加载工具、在数据进入模型之前进行过滤,并在单一步骤中执行复杂逻辑。采用这种方法还能带来安全性和状态管理方面的优势。

Code execution with MCP enables agents to use context more efficiently by loading tools on demand, filtering data before it reaches the model, and executing complex logic in a single step. There are also security and state management benefits to using this approach.

渐进式披露 Progressive disclosure

模型非常擅长在文件系统中导航。将工具以代码形式呈现在文件系统上,使模型能够按需读取工具定义,而不是预先一次性读取全部定义。

Models are great at navigating filesystems. Presenting tools as code on a filesystem allows models to read tool definitions on-demand, rather than reading them all up-front.

另一种做法是,在服务器上添加一个 \(search_tools\) 工具来查找相关定义。例如,在使用上文假设的 Salesforce 服务器时,智能体搜索 “salesforce”,只加载当前任务所需的那些工具。在 \(search_tools\) 工具中加入一个细节层级参数,让智能体可以选择所需的细节程度(例如仅名称、名称与描述,或包含 schema 的完整定义),也有助于智能体节省上下文窗口并高效地查找工具。

Alternatively, a \(search_tools\) tool can be added to the server to find relevant definitions. For example, when working with the hypothetical Salesforce server used above, the agent searches for "salesforce" and loads only those tools that it needs for the current task. Including a detail level parameter in the \(search_tools\) tool that allows the agent to select the level of detail required (such as name only, name and description, or the full definition with schemas) also helps the agent conserve context and find tools efficiently.

上下文高效的工具结果 Context efficient tool results

在处理大型数据集时,智能体可以在返回结果之前先用代码对结果进行过滤和转换。试想获取一个包含 10,000 行的电子表格:

When working with large datasets, agents can filter and transform results in code before returning them. Consider fetching a 10,000-row spreadsheet:

``` // Without code execution - all rows flow through context TOOL CALL: gdrive.getSheet(sheetId: 'abc123') → returns 10,000 rows in context to filter manually // With code execution - filter in the execution environment const allRows = await gdrive.getSheet({ sheetId: 'abc123' }); const pendingOrders = allRows.filter(row => row["Status"] === 'pending' ); console.log(`Found ${pendingOrders.length} pending orders`); console.log(pendingOrders.slice(0, 5)); // Only log first 5 for review ```

``` // Without code execution - all rows flow through context TOOL CALL: gdrive.getSheet(sheetId: 'abc123') → returns 10,000 rows in context to filter manually // With code execution - filter in the execution environment const allRows = await gdrive.getSheet({ sheetId: 'abc123' }); const pendingOrders = allRows.filter(row => row["Status"] === 'pending' ); console.log(`Found ${pendingOrders.length} pending orders`); console.log(pendingOrders.slice(0, 5)); // Only log first 5 for review ```

智能体看到的是五行,而不是 10,000 行。类似的模式也适用于聚合、跨多个数据源的连接,或提取特定字段——所有这些都不会使上下文窗口膨胀。

The agent sees five rows instead of 10,000. Similar patterns work for aggregations, joins across multiple data sources, or extracting specific fields—all without bloating the context window.

更强大且上下文高效的控制流 More powerful and context-efficient control flow

循环、条件判断和错误处理可以用熟悉的代码模式来完成,而不必逐个串联工具调用。例如,如果你需要在 Slack 中收到部署通知,智能体可以编写:

Loops, conditionals, and error handling can be done with familiar code patterns rather than chaining individual tool calls. For example, if you need a deployment notification in Slack, the agent can write:

``` let found = false; while (!found) { const messages = await slack.getChannelHistory({ channel: 'C123456' }); found = messages.some(m => m.text.includes('deployment complete')); if (!found) await new Promise(r => setTimeout(r, 5000)); } console.log('Deployment notification received'); ```

``` let found = false; while (!found) { const messages = await slack.getChannelHistory({ channel: 'C123456' }); found = messages.some(m => m.text.includes('deployment complete')); if (!found) await new Promise(r => setTimeout(r, 5000)); } console.log('Deployment notification received'); ```

这种方法比在智能体循环中交替执行 MCP 工具调用和 sleep 命令更高效。

This approach is more efficient than alternating between MCP tool calls and sleep commands through the agent loop.

此外,能够写出一个会被执行的条件树还能节省“首 token 时间”延迟:智能体无需等待模型来求值一个 if 语句,而是可以让代码执行环境来完成这件事。

Additionally, being able to write out a conditional tree that gets executed also saves on "time to first token" latency: rather than having to wait for a model to evaluate an if-statement, the agent can let the code execution environment do this.

隐私保护操作 Privacy-preserving operations

当智能体使用带有 MCP 的代码执行时,中间结果默认保留在执行环境中。这样,智能体只能看到你显式记录或返回的内容,这意味着你不希望与模型共享的数据可以在你的工作流中流动,而无需进入模型的上下文。

When agents use code execution with MCP, intermediate results stay in the execution environment by default. This way, the agent only sees what you explicitly log or return, meaning data you don’t wish to share with the model can flow through your workflow without ever entering the model's context.

对于更敏感的工作负载,智能体框架可以自动对敏感数据进行标记化。例如,假设你需要将客户联系详情从电子表格导入 Salesforce。智能体编写:

For even more sensitive workloads, the agent harness can tokenize sensitive data automatically. For example, imagine you need to import customer contact details from a spreadsheet into Salesforce. The agent writes:

``` const sheet = await gdrive.getSheet({ sheetId: 'abc123' }); for (const row of sheet.rows) { await salesforce.updateRecord({ objectType: 'Lead', recordId: row.salesforceId, data: { Email: row.email, Phone: row.phone, Name: row.name } }); } console.log(`Updated ${sheet.rows.length} leads`); ```

``` const sheet = await gdrive.getSheet({ sheetId: 'abc123' }); for (const row of sheet.rows) { await salesforce.updateRecord({ objectType: 'Lead', recordId: row.salesforceId, data: { Email: row.email, Phone: row.phone, Name: row.name } }); } console.log(`Updated ${sheet.rows.length} leads`); ```

MCP 客户端拦截数据并在数据到达模型之前对 PII 进行标记化:

The MCP client intercepts the data and tokenizes PII before it reaches the model:

``` // What the agent would see, if it logged the sheet.rows: [ { salesforceId: '00Q...', email: '[EMAIL_1]', phone: '[PHONE_1]', name: '[NAME_1]' }, { salesforceId: '00Q...', email: '[EMAIL_2]', phone: '[PHONE_2]', name: '[NAME_2]' }, ... ] ```

``` // What the agent would see, if it logged the sheet.rows: [ { salesforceId: '00Q...', email: '[EMAIL_1]', phone: '[PHONE_1]', name: '[NAME_1]' }, { salesforceId: '00Q...', email: '[EMAIL_2]', phone: '[PHONE_2]', name: '[NAME_2]' }, ... ] ```

然后,当数据在另一个 MCP 工具调用中共享时,通过 MCP 客户端中的查找进行去标记化。真实的电子邮件地址、电话号码和姓名从 Google Sheets 流向 Salesforce,但从不经过模型。这可以防止智能体意外记录或处理敏感数据。你也可以使用此功能来定义确定性的安全规则,选择数据可以流向何处以及从何处流入。

Then, when the data is shared in another MCP tool call, it is untokenized via a lookup in the MCP client. The real email addresses, phone numbers, and names flow from Google Sheets to Salesforce, but never through the model. This prevents the agent from accidentally logging or processing sensitive data. You can also use this to define deterministic security rules, choosing where data can flow to and from.

状态持久化与技能 State persistence and skills

借助文件系统访问的代码执行使智能体能够在多次操作之间保持状态。智能体可以将中间结果写入文件,从而能够恢复工作并跟踪进度:

Code execution with filesystem access allows agents to maintain state across operations. Agents can write intermediate results to files, enabling them to resume work and track progress:

``` const leads = await salesforce.query({ query: 'SELECT Id, Email FROM Lead LIMIT 1000' }); const csvData = leads.map(l => `${l.Id},${l.Email}`).join('\n'); await fs.writeFile('./workspace/leads.csv', csvData); // Later execution picks up where it left off const saved = await fs.readFile('./workspace/leads.csv', 'utf-8'); ```

``` const leads = await salesforce.query({ query: 'SELECT Id, Email FROM Lead LIMIT 1000' }); const csvData = leads.map(l => `${l.Id},${l.Email}`).join('\n'); await fs.writeFile('./workspace/leads.csv', csvData); // Later execution picks up where it left off const saved = await fs.readFile('./workspace/leads.csv', 'utf-8'); ```

智能体还可以将自身的代码持久化为可复用的函数。一旦智能体为某项任务开发出可用的代码,它就可以将该实现保存下来以供未来使用:

Agents can also persist their own code as reusable functions. Once an agent develops working code for a task, it can save that implementation for future use:

``` // In ./skills/save-sheet-as-csv.ts import * as gdrive from './servers/google-drive'; export async function saveSheetAsCsv(sheetId: string) { const data = await gdrive.getSheet({ sheetId }); const csv = data.map(row => row.join(',')).join('\n'); await fs.writeFile(`./workspace/sheet-${sheetId}.csv`, csv); return `./workspace/sheet-${sheetId}.csv`; } // Later, in any agent execution: import { saveSheetAsCsv } from './skills/save-sheet-as-csv'; const csvPath = await saveSheetAsCsv('abc123'); ```

``` // In ./skills/save-sheet-as-csv.ts import * as gdrive from './servers/google-drive'; export async function saveSheetAsCsv(sheetId: string) { const data = await gdrive.getSheet({ sheetId }); const csv = data.map(row => row.join(',')).join('\n'); await fs.writeFile(`./workspace/sheet-${sheetId}.csv`, csv); return `./workspace/sheet-${sheetId}.csv`; } // Later, in any agent execution: import { saveSheetAsCsv } from './skills/save-sheet-as-csv'; const csvPath = await saveSheetAsCsv('abc123'); ```

这与技能(Skills)的概念密切相关:技能是包含可复用指令、脚本和资源的文件夹,用于提升模型在专门任务上的表现。在这些已保存的函数中添加一个 SKILL.md 文件,就能创建一个结构化的技能,供模型引用和使用。随着时间推移,这使你的智能体能够构建一个由更高层能力组成的工具箱,并不断演进其高效工作所需的脚手架。

This ties in closely to the concept of Skills: folders of reusable instructions, scripts, and resources for models to improve performance on specialized tasks. Adding a SKILL.md file to these saved functions creates a structured skill that models can reference and use. Over time, this allows your agent to build a toolbox of higher-level capabilities, evolving the scaffolding that it needs to work most effectively.

需要注意的是,代码执行本身也带来了复杂性。运行智能体生成的代码需要一个安全的执行环境,并配备适当的沙箱隔离、资源限制和监控。这些基础设施要求带来了额外的运维开销和安全考量,而直接工具调用则可避免这些问题。代码执行带来的收益——降低 token 成本、降低延迟以及改进工具组合——应当与这些实现成本进行权衡。

Note that code execution introduces its own complexity. Running agent-generated code requires a secure execution environment with appropriate sandboxing, resource limits, and monitoring. These infrastructure requirements add operational overhead and security considerations that direct tool calls avoid. The benefits of code execution—reduced token costs, lower latency, and improved tool composition—should be weighed against these implementation costs.

总结 Summary

MCP 为智能体连接众多工具与系统提供了基础协议。然而,一旦连接的服务器过多,工具定义与结果就会消耗过多 token,从而降低智能体的效率。

MCP provides a foundational protocol for agents to connect to many tools and systems. However, once too many servers are connected, tool definitions and results can consume excessive tokens, reducing agent efficiency.

尽管这里的许多问题看似新颖——上下文管理、工具组合、状态持久化——但它们在软件工程中已有已知的解决方案。代码执行将这些成熟模式应用于智能体,使其能够使用熟悉的编程结构更高效地与 MCP 服务器交互。如果你实现了这一方法,我们鼓励你与 MCP 社区分享你的发现。

Although many of the problems here feel novel—context management, tool composition, state persistence—they have known solutions from software engineering. Code execution applies these established patterns to agents, letting them use familiar programming constructs to interact with MCP servers more efficiently. If you implement this approach, we encourage you to share your findings with the MCP community.

互动版:针对本篇提问 →

接着读 · Read next