labring/fastgpt-plugin/fastgpt-system-tool-development

Claude Code and agent skill by labring/fastgpt-plugin

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when writing a FastGPT system tool plugin with @fastgpt-plugin/sdk-factory and @fastgpt-plugin/cli, including tool structure, SDK writing rules, required files, avatar/logo naming, and build/check/pack tooling.

Install

npx vskill@latest install labring/fastgpt-plugin/fastgpt-system-tool-development

SKILL.md

The same SKILL.md was published earlier as labring/fastgpt-plugin/fastgpt-system-tool-development.

FastGPT 系统工具开发规范

在编写 FastGPT 系统工具插件时使用这个 skill。目标是指导代理用 @fastgpt-plugin/sdk-factory 写出符合 FastGPT 约定的系统工具,并用 @fastgpt-plugin/cli 创建、构建、检查和打包。

使用工具

同时参考这些能力:

  • fastgpt-sdk-factory: 处理 defineTool()、defineToolSet()、createToolHandler()、Zod schema、secretSchema、ctx.invoke、ctx.streamResponse() 等 SDK 写法。
  • cli-usage: 使用 @fastgpt-plugin/cli 的 create、build、check、pack 命令。

常用命令:

bash
npx @fastgpt-plugin/cli create <plugin-name> --type tool --cwd <target-directory>
bash
npx @fastgpt-plugin/cli create <plugin-name> --type tool-suite --cwd <target-directory>
bash
npx @fastgpt-plugin/cli build --entry <plugin-directory> --output <plugin-directory>/dist
bash
npx @fastgpt-plugin/cli check --entry <plugin-directory> --output <plugin-directory>/dist
bash
npx @fastgpt-plugin/cli pack --entry <plugin-directory> --dist <plugin-directory>/dist --output <plugin-directory>/out

系统工具包含内容

一个系统工具目录通常包含:

  • index.ts: 系统工具入口,默认导出 defineTool() 或 defineToolSet() 的返回值。
  • package.json: 声明依赖和 build、build:dev、pack、test 脚本。
  • logo.<ext>: 主工具头像,必须放在工具根目录。
  • README.en.md、README.zh-CN.md(及可选 README.zh-Hant.md):根目录下的多语言说明文档(描述工具用途、输入、输出、密钥配置和使用说明);文件名严格区分大小写,构建与打包会自动识别并写入 readmeUrls,展示端优先按当前用户语言展示并依次回退到 zh-CN、en(旧插件仅保留 README.md 仍兼容)。
  • assets/: 可选资源目录,例如图标或示例资源。
  • dist/: CLI 构建输出目录,包含 index.js、manifest.json 和必要资源。
  • out/: CLI 打包输出目录,通常包含 .pkg 文件。

依赖建议:

  • 运行依赖:@fastgpt-plugin/sdk-factory、zod。
  • 开发依赖:@fastgpt-plugin/cli、typescript、vitest。

系统工具写法

入口文件必须默认导出 SDK factory 实例:

  • 单工具使用 defineTool()。
  • 多个相关工具组成一个插件时使用 defineToolSet()。
  • 每个 handler 用 createToolHandler() 定义。
  • inputSchema、outputSchema 和 secretSchema 分别使用 defineInputSchema()、defineOutputSchema() 和 defineSecretSchema(),返回可直接交给 createToolHandler() 的普通 Zod object。
  • 每个字段 descriptor 的 type 是 Zod schema 实例;title 必须包含 en、zh-CN,可选包含 zh-Hant;description 是可选 UI 文案。
  • 输入 descriptor 额外支持可选 boolean isToolParam(包括 false);description 是字段 UI 与工具说明的唯一来源。旧输入 Schema 属性上的 toolDescription 仅在未显式设置 isToolParam 时推导为 true,显式值优先;它不会覆盖 description,FastGPT 不会将其作为文案使用。
  • 密钥 descriptor 必须提供 boolean isSecret(需要加密存储的字段标记为 true),不支持 isToolParam。
  • helper 生成英文普通 title / description 和完整 x-i18n 多语言对象,保留 schema 其他 .meta() metadata,不修改源 schema。未知键默认 strip;需要严格校验时可对返回对象调用 .strict()。
  • 字段可嵌套组合或作为数组元素,例如 type: z.array(defineOutputSchema({ label: { type: z.string(), title: { en: 'Label', 'zh-CN': '标签' } } }))。
  • 高级 metadata 仍可使用低层 .meta();手动书写 z.object() 时,密钥字段使用 .meta({ isSecret: true | false, ... } satisfies SecretSchemaMetaType)。
  • handler 返回值必须匹配 outputSchema。
  • 需要向模型返回图片时,用 defineContentSchema(valueType) 声明多模态输出字段,返回 { value, images }。

manifest 至少包含:

  • pluginId: 稳定唯一工具 ID。
  • version: 工具版本。
  • name: { en, 'zh-CN' } 格式。
  • description: { en, 'zh-CN' } 格式。

常用可选字段:

  • versionDescription
  • author
  • repoUrl
  • tutorialUrl
  • tags
  • permission
  • icon

工具和子工具以 description 作为描述来源;旧输入 Schema 属性上的 toolDescription 仅在未显式设置 isToolParam 时推导为 true,不覆盖 description。服务端会为兼容保留该字段,FastGPT 不用它作为文案。

permission 用于声明插件运行时需要的宿主能力,类型为权限字符串数组。只声明当前插件实际使用的最小权限;没有使用对应能力时不要添加。使用 ctx.invoke 反向调用宿主能力时,必须声明对应权限。

当前可用权限:

  • userInfo:read: 读取用户信息,例如调用 ctx.invoke.userInfo()。
  • teamInfo:read: 读取团队信息。
  • model:read: 读取模型信息。
  • dataset:read: 读取知识库信息。
  • file-upload:allow: 上传文件,例如调用 ctx.invoke.uploadFile()。

兼容性要求:

  • pluginId、工具 id、输入字段名、输出字段名对外使用后保持稳定。
  • 用户配置的密钥、API Key、Base URL 等使用 secretSchema 描述,通过 ctx.secrets 读取。
  • 错误信息应能帮助定位问题,同时避免暴露密钥、令牌和完整上游敏感响应。
  • 需要向用户展示执行进度时使用 ctx.streamResponse()。
  • 需要生成文件时使用 ctx.invoke.uploadFile(),并在 manifest.permission 中声明 file-upload:allow;收到 [result, err] 的 err 时保留原始 err,避免覆盖反向调用的宿主错误信息。

头像规范

CLI 构建时会自动扫描系统工具根目录中的头像文件,并写入 manifest.icon 或子工具 icon 字段。工具代码里通常不用手写 icon。

命名方式:

  • 主工具头像:logo.<ext>,例如 logo.svg、logo.png。
  • 工具集子工具头像:<childId>.logo.<ext>,例如子工具 id 为 search 时使用 search.logo.svg。
  • 子工具没有独立头像时,CLI 会复用主工具头像。

格式限制:

  • 支持扩展名:.svg、.png、.jpg、.jpeg、.webp、.gif。
  • 头像文件必须放在系统工具根目录,不能放在 assets/ 后再通过 manifest 引用。
  • childId 必须和 defineToolSet({ children }) 中的子工具 id 完全一致。
  • 避免使用空格、中文或特殊符号作为头像文件名的一部分。
  • logo.* 和 <childId>.logo.* 只保留一个匹配文件,避免不同扩展名同时存在导致扫描结果不明确。
  • build 后检查 dist/manifest.json 中的 icon 字段是否指向已复制到 dist/ 的头像文件。

单工具模板

ts
import {
createToolHandler,
defineInputSchema,
defineOutputSchema,
defineTool
} from '@fastgpt-plugin/sdk-factory';
import z from 'zod';
const handler = createToolHandler({
inputSchema: defineInputSchema({
text: {
type: z.string().min(1),
title: { en: 'Text', 'zh-CN': '文本' },
description: { en: 'Text to normalize', 'zh-CN': '需要规范化的文本' },
isToolParam: true
}
}),
outputSchema: defineOutputSchema({
result: {
type: z.string(),
title: { en: 'Result', 'zh-CN': '结果' }
}
}),
handler: async (input) => {
return {
result: input.text.trim()
};
}
});
export default defineTool({
manifest: {
pluginId: 'text-normalizer',
version: '1.0.0',
name: {
en: 'Text Normalizer',
'zh-CN': '文本规范化'
},
description: {
en: 'Normalize input text',
'zh-CN': '规范化输入文本'
},
versionDescription: {
en: 'Initial version',
'zh-CN': '初始版本'
},
permission: []
},
handler
});

工具集模板

ts
import {
createToolHandler,
defineInputSchema,
defineOutputSchema,
defineSecretSchema,
defineToolSet
} from '@fastgpt-plugin/sdk-factory';
import z from 'zod';
const secretSchema = defineSecretSchema({
apiKey: {
type: z.string().min(1),
title: { en: 'API Key', 'zh-CN': 'API 密钥' },
isSecret: true
}
});
const searchHandler = createToolHandler({
inputSchema: defineInputSchema({
query: {
type: z.string().min(1),
title: { en: 'Query', 'zh-CN': '查询' },
description: { en: 'Search query', 'zh-CN': '搜索查询' },
isToolParam: true
}
}),
outputSchema: defineOutputSchema({
items: {
type: z.array(z.string()),
title: { en: 'Items', 'zh-CN': '项目' }
}
}),
secretSchema,
handler: async (input, ctx) => {
ctx.streamResponse({
type: 'answer',
content: `Searching: ${input.query}`
});
return {
items: []
};
}
});
export default defineToolSet({
secretSchema,
manifest: {
pluginId: 'example-search-tools',
version: '1.0.0',
name: {
en: 'Example Search Tools',
'zh-CN': '示例搜索工具集'
},
description: {
en: 'Search public example data',
'zh-CN': '搜索公开示例数据'
},
permission: []
},
children: [
{
id: 'search',
name: {
en: 'Search',
'zh-CN': '搜索'
},
description: {
en: 'Search by query',
'zh-CN': '按查询搜索'
},
handler: searchHandler
}
]
});

返回图片内容(可选)

通过 SDK 的 defineContentSchema(valueType) 声明顶层输出字段,字段名由工具决定。value 符合传入的 Schema,images 是 OpenAI image_url parts 数组:

ts
import { createToolHandler, defineContentSchema, defineOutputSchema } from '@fastgpt-plugin/sdk-factory';
import z from 'zod';
const handler = createToolHandler({
inputSchema: z.object({ prompt: z.string() }),
outputSchema: defineOutputSchema({
result: {
type: defineContentSchema(z.array(z.object({ title: z.string() }))),
title: { en: 'Result', 'zh-CN': '结果' }
}
}),
handler: async ({ prompt }) => ({
result: {
value: [{ title: prompt }],
images: [{ type: 'image_url', image_url: { url: 'https://example.com/result.png' } }]
}
})
});

工作流中该字段的类型和值都是 value;Agent 将 value 转成文本,按字段顺序追加对应图片。images 可为空;每条结果最多发送 4 张图片。图片 URL 支持 http(s) 或图片 data URI,detail 可为 auto、low、high。仅支持图片;普通字段和未标记的 content 保持业务数据,不自动转成视觉输入。

验证重点

  • index.ts 默认导出正确。
  • manifest 字段完整,国际化字段包含 en 和 zh-CN。
  • permission 只包含插件实际使用的权限,且权限值来自当前支持的枚举。
  • 使用 ctx.invoke 时已在 manifest.permission 声明对应权限,例如上传文件声明 file-upload:allow。
  • Zod schema 覆盖全部用户可见输入和输出;推荐由 AI 托管补充的输入字段设置 isToolParam: true。
  • handler 成功路径返回值与 outputSchema 一致。
  • 多模态输出使用 defineContentSchema,返回的 value 符合声明类型,images 只包含合法的 image_url parts。
  • 构建后的 JSON Schema 保留 x-fastgpt-output-kind: model-content 标记,图片不超过 4 张。
  • 外部调用失败、空响应、超时、鉴权失败都有明确错误。
  • 密钥配置只通过 secretSchema 和 ctx.secrets 处理。
  • 系统工具根目录存在 logo.<ext>。
  • 工具集子工具头像按 <childId>.logo.<ext> 命名,或确认复用主头像。
  • build 后存在 dist/index.js 和 dist/manifest.json。
  • check 通过后再执行 pack。

Security

  • Security scanPassed, 96 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
40
Repository forks
90
7-day trend score
19

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/labring/fastgpt-plugin/fastgpt-system-tool-development/badge)](https://verified-skill.com/skills/labring/fastgpt-plugin/fastgpt-system-tool-development)

Something wrong with this skill or its page? Tell us.