# @frontmcp/plugin-codecall 中文文档

规范地址：https://npmcn.com/package/%40frontmcp/plugin-codecall/

版本：1\.12\.2
npm 元数据更新时间：2026-11-14T21:10:38.837Z
中文译文更新时间：2026-11-15T15:15:34.890Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40frontmcp/plugin-codecall
原文对照：https://npmcn.com/package/%40frontmcp/plugin-codecall/?lang=original
项目主页：https://frontmcp.dev/reference/plugins/codecall
源码仓库：https://github.com/agentfront/frontmcp

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：403 kB，88 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=24\.0\.0
- 运行依赖：6 个
- peer 依赖：@frontmcp/sdk 1\.12\.2，@frontmcp/lazy-zod 1\.12\.2，@frontmcp/plugin-cache 1\.12\.2
- 首次发布：2026-01-09T03:03:12.464Z
- 最新版本发布：2026-11-14T21:10:38.483Z
- 近 30 天下载量：7673（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：112（近 12 个月 112 个）

## 中文简介

FrontMCP 的 CodeCall 插件: 在搜索后放置许多工具, 描述、 引用和执行元工具, 并运行在沙盒中调用它们的脚本

## 安装

```sh
npm install @frontmcp/plugin-codecall
```

也可以使用：`pnpm add @frontmcp/plugin-codecall`、`yarn add @frontmcp/plugin-codecall`、`bun add @frontmcp/plugin-codecall`

## README

# @ frontmcp/ 插件编码调用

一个用于服务器的FrontMCP插件,其工具比模型多,可以有用地读取. 而不是每一个工具 及其计划, `tools/list` 显示 CodeCall 的元工具。 模型以 `codecall:search`,读取 被它挑出来的 `codecall:describe`,并给他们打电话: `codecall:invoke`,或数个 请求与 `codecall:execute`,它运行着一个以 AgentScript 编写的短程序,一个限制的子集 JavaScript,位于服务器上的一个沙盒中. 脚本可以循环结果,过滤并加入结果,所以只有答案 回到模特儿身边.

[![npm](https://img.shields.io/npm/v/@frontmcp/plugin-codecall.svg)](https://www.npmjs.com/package/@frontmcp/plugin-codecall) [![License](https://img.shields.io/npm/l/@frontmcp/plugin-codecall.svg)](https://github.com/agentfront/frontmcp/blob/main/LICENSE)

## 安装

```bash
npm install @frontmcp/plugin-codecall @frontmcp/plugin-cache @frontmcp/sdk
```

需要节点.js 24或后. [`@frontmcp/plugin-cache`](https://www.npmjs.com/package/@frontmcp/plugin-cache) 是一个 需要的对等依赖性: 在同一版本, 在此软件包旁边安装 。 CodeCall 注册缓存插件 自己,所以你不列出它 `plugins`保留 `@frontmcp/sdk` 同样版本.

对于 `embedding: { strategy: 'ml' }`,同时安装 `@huggingface/transformers`,可选的对等依赖 `vectoriadb`,用于搜索的代码Call.

## 使用量

注册插件为 `init()`,在 `plugins` 一、导 言 `@App` 或 `@FrontMcp`数字 :

```ts
import { CodeCallPlugin } from '@frontmcp/plugin-codecall';
import { App, FrontMcp, Tool, ToolContext, z } from '@frontmcp/sdk';

@Tool({
  name: 'list_tickets',
  description: 'List support tickets',
  inputSchema: { status: z.enum(['open', 'closed']) },
})
class ListTickets extends ToolContext {
  async execute({ status }: { status: 'open' | 'closed' }) {
    return { tickets: [{ id: 'T-1', status, customerId: 'C-7' }] };
  }
}

@Tool({ name: 'get_customer', description: 'Get a customer by id', inputSchema: { id: z.string() } })
class GetCustomer extends ToolContext {
  async execute({ id }: { id: string }) {
    return { id, name: 'Ada', plan: 'pro' };
  }
}

@App({
  id: 'help-desk',
  name: 'Help Desk',
  tools: [ListTickets, GetCustomer],
  plugins: [CodeCallPlugin.init({ mode: 'codecall_only' })],
})
class HelpDeskApp {}

@FrontMcp({ info: { name: 'help-desk', version: '1.0.0' }, apps: [HelpDeskApp] })
export default class Server {}
```

`tools/list` 现在只显示 `codecall:*` 工具。 在一个应用程序上注册的 CodeCall 仍然隐藏每个应用程序的工具 (除非你设定) `appIds`及其工具搜索和调用每个应用程序的工具.

每个选项都是可选的 : `CodeCallPlugin.init()` 财务报告和审定财务报表 `plugins: [CodeCallPlugin]` 使用默认值. `init()` 检查 模块导入时的选项,并丢出一个 `ZodError` 命名错误.

## 工具代码Call添加

| 工具 | 它会做什么 |
| --- | --- |
| `codecall:search` | 查找简短查询的工具( E)`queries`: 1到10个短语. |
| `codecall:describe` | 返回工具的输入和输出计划,包括使用实例. |
| `codecall:invoke` | 调用一个工具并返回结果 . |
| `codecall:execute` | 运行调用工具的代理脚本程序. |
| `codecall:searchSkills` | 找到调用工具的技能. |
| `codecall:searchKnowledge` | 找到只是指示的技能. |

每个模式都列出它们, 也没有 `codecall:invoke` 剧本也不能叫他们.

## 模式

| `mode` | 单位 `tools/list` | 代码呼叫可以使用什么 |
| --- | --- | --- |
| `'codecall_only'` (默认) | 代码Call的工具和工具 `codecall: { visibleInListTools: true }` | 每一个工具,除了有 `enabledInCodeCall: false` |
| `'codecall_opt_in'` | 每一个工具,除了有 `visibleInListTools: false` | 只有工具为 `codecall: { enabledInCodeCall: true }` |
| `'metadata_driven'` | 每一个工具,除了有 `visibleInListTools: false` | 每一个工具,除了有 `enabledInCodeCall: false` |

调用工具 CodeCall 的客户端 `tools/list` 获得 `Tool "…" not found` (单位:千美元)`TOOL_NOT_FOUND`) (中文(简体) ). 电话 通过 CodeCall 自己的工具或 `this.callTool()`,仍然达到它。 单位 `codecall_only`,工具 a 客户端或部件呼叫直接需要 `visibleInListTools: true`。 。 。 .

插件添加一个 `codecall` 字段改为 `@Tool`数字 :

```ts
@Tool({
  name: 'delete_customer',
  description: 'Delete a customer and all their tickets',
  inputSchema: { id: z.string() },
  codecall: { enabledInCodeCall: false, visibleInListTools: true },
})
```

## 选项

| 选项 | 默认 | 说明 |
| --- | --- | --- |
| `mode` | `'codecall_only'` | 哪些工具 `tools/list` 显示,以及代码Call可以使用哪个。 见 [模式](https://npmcn.com/package/%40frontmcp/plugin-codecall/#readme-modes)。 。 。 . |
| `appIds` | 每个应用程序 | 单位 `codecall_only`,只隐藏这些应用程序的工具 `tools/list`它并不限制密码搜索或呼叫. |
| `includeTools` |  | `(tool) => boolean`返回的工具 `false` 无法从脚本中搜索、描述、引用或调用. |
| `directCalls` | 未设定 | `{ enabled, allowedTools?, filter? }`,限制什么 `codecall:invoke` 可能会打电话. |
| `vm` | `{ preset: 'secure' }` | 沙盒的极限: `preset` (单位:千美元)`'locked_down'`, (中文(简体) ), `'secure'`, (中文(简体) ), `'balanced'`, (中文(简体) ), `'experimental'`, (中文(简体) ), `timeoutMs`, (中文(简体) ), `maxSteps`, (中文(简体) ), `allowLoops`还有其他. |
| `embedding` | TF-IDF (英语) | 怎么样 `codecall:search` 排序工具 : `strategy` (单位:千美元)`'tfidf'` 或者说 `'ml'`, (中文(简体) ), `modelName`, (中文(简体) ), `cacheDir`, (中文(简体) ), `useHNSW`, (中文(简体) ), `synonymExpansion`。 。 。 . |
| `sidecar` | `{ enabled: false }` | 允许脚本超过64 KB. |
| `topK` | `8` | 每次查询的结果 `codecall:search` 电话不给自己的 `topK`。 。 。 . |
| `maxDefinitions` | `8` | 大多数工具之一 `codecall:describe` 电话可以叫. |

```ts
CodeCallPlugin.init({
  mode: 'codecall_opt_in',
  directCalls: { enabled: true, allowedTools: ['get_customer'] },
  vm: { preset: 'secure', timeoutMs: 3500 },
  embedding: { strategy: 'ml' },
});
```

## 限制

-   **脚本时间和呼叫.** 在默认情况下 `secure` 预设,3.5秒后的脚本出错(`vm.timeoutMs`(中文(简体) ) 并且最多可调用5 000次的工具(`vm.maxSteps`) (中文(简体) ). 循环仅限于 `for…of`,以及 `for (…; …; …)` 与 `vm.allowLoops: true`。其他预设设定了其他限制.
-   **呼叫一个工具.** 超过 `vm.rapidEnumerationThreshold` 调用( 默认 30) 到 2 个工具 秒停止脚本 `[RAPID_ENUMERATION]`; 电话通过 `parallel()` 计数。 每个工具值设定为 `vm.rapidEnumerationOverrides` (单位:千美元)`{ 'users:get': 100 }`) (中文(简体) ). 沙盒的留言是"在5",但它只保留了 最后两秒钟的电话.
-   **嵌入型号.** 与 `embedding.strategy: 'ml'`,CodeCall装入本地模型(`Xenova/all-MiniLM-L6-v2` 以 默认),将其下载到 `embedding.cacheDir` 如果它不在的话。 当模型无法装入或使用时 (离线,没有缓存, `@huggingface/transformers` 缺少,或嵌入工具失败),CodeCall日志一 使用 TF- IDF 警告和搜索。 无法读取元数据的工具被跳过警告; 其他人留下来 可搜索 .

## 文档

-   [代码](https://frontmcp.dev/reference/plugins/codecall): 每个选项,工具,代理脚本 沙盒的限度和安全性, 有可运行的例子
-   [允许使用代码的写作规范范本](https://frontmcp.dev/learn/letting-the-model-write-code-with-codecall)数字 : 逐个教训
-   [带代码呼叫的 CRM](https://frontmcp.dev/examples/crm-with-codecall): 整个服务器建在它上
-   [插件和适配器](https://frontmcp.dev/reference/plugins): 在哪里注册插件

## 相关软件包

-   [`@frontmcp/sdk`](https://www.npmjs.com/package/@frontmcp/sdk): 此插件扩展的框架
-   [`@frontmcp/plugin-cache`](https://www.npmjs.com/package/@frontmcp/plugin-cache): 所需同伴依赖
-   [`@frontmcp/plugin-skilled-openapi`](https://www.npmjs.com/package/@frontmcp/plugin-skilled-openapi):服务于 a REST API作为技能 `codecall:searchSkills` 发现
-   [`@frontmcp/plugins`](https://www.npmjs.com/package/@frontmcp/plugins): 重新导出此插件的元包 与另外三个

## 捐款

资料来源: [`plugins/plugin-codecall`](https://github.com/agentfront/frontmcp/tree/main/plugins/plugin-codecall)问题 欢迎抽取请求;见 [捐款额](https://github.com/agentfront/frontmcp/blob/main/CONTRIBUTING.md)。 。 。 .

## 许可证

阿帕奇2.0 (英语). 见 [自由主义](https://github.com/agentfront/frontmcp/blob/main/LICENSE)。 。 。 .

## 常见问题

### @frontmcp/plugin-codecall 是什么？

FrontMCP 的 CodeCall 插件: 在搜索后放置许多工具, 描述、 引用和执行元工具, 并运行在沙盒中调用它们的脚本

### 如何安装 @frontmcp/plugin-codecall？

在项目目录运行 npm install @frontmcp/plugin-codecall，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@frontmcp/sdk（1\.12\.2）、@frontmcp/lazy-zod（1\.12\.2）、@frontmcp/plugin-cache（1\.12\.2）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @frontmcp/plugin-codecall 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @frontmcp/plugin-codecall 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @frontmcp/plugin-codecall 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=24\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @frontmcp/plugin-codecall 可以商用吗？

@frontmcp/plugin-codecall 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @frontmcp/plugin-codecall 的下载量有多少？

根据 npm 官方下载统计，@frontmcp/plugin-codecall 在 2026/10/16 – 2026/11/14 这 30 天内被下载 7,673 次，日均约 256 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @frontmcp/plugin-codecall 还在维护吗？

最新版本 1\.12\.2 发布于 2026/11/15（1 天前）；至今共发布 112 个版本，其中过去 12 个月发布了 112 个；首次发布于 2026/01/09。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

