@ frontmcp/ 插件编码调用
一个用于服务器的FrontMCP插件,其工具比模型多,可以有用地读取. 而不是每一个工具 及其计划,
tools/list 显示 CodeCall 的元工具。 模型以 codecall:search,读取
被它挑出来的 codecall:describe,并给他们打电话: codecall:invoke,或数个
请求与 codecall:execute,它运行着一个以 AgentScript 编写的短程序,一个限制的子集
JavaScript,位于服务器上的一个沙盒中. 脚本可以循环结果,过滤并加入结果,所以只有答案
回到模特儿身边.
安装
npm install @frontmcp/plugin-codecall @frontmcp/plugin-cache @frontmcp/sdk
需要节点.js 24或后. @frontmcp/plugin-cache 是一个
需要的对等依赖性: 在同一版本, 在此软件包旁边安装 。 CodeCall 注册缓存插件
自己,所以你不列出它 plugins保留 @frontmcp/sdk 同样版本.
对于 embedding: { strategy: 'ml' },同时安装 @huggingface/transformers,可选的对等依赖
vectoriadb,用于搜索的代码Call.
使用量
注册插件为 init(),在 plugins 一、导 言 @App 或 @FrontMcp数字 :
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数字 :
@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可以使用哪个。 见 模式。 。 。 . |
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 电话可以叫. |
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 警告和搜索。 无法读取元数据的工具被跳过警告; 其他人留下来 可搜索 .
文档
- 代码: 每个选项,工具,代理脚本 沙盒的限度和安全性, 有可运行的例子
- 允许使用代码的写作规范范本数字 : 逐个教训
- 带代码呼叫的 CRM: 整个服务器建在它上
- 插件和适配器: 在哪里注册插件
相关软件包
@frontmcp/sdk: 此插件扩展的框架@frontmcp/plugin-cache: 所需同伴依赖@frontmcp/plugin-skilled-openapi:服务于 a REST API作为技能codecall:searchSkills发现@frontmcp/plugins: 重新导出此插件的元包 与另外三个
捐款
资料来源: plugins/plugin-codecall问题
欢迎抽取请求;见 捐款额。 。 。 .
许可证
阿帕奇2.0 (英语). 见 自由主义。 。 。 .