FastGPTFastGPT
Plugin System

Package and SDK reference

Tool plugin build artifacts, author metadata and schema declarations, and SDK and CLI entry points

This reference explains delivery files and code declarations for tool plugin authors. For commands, see debugging, packing, and publishing. For service capacity and environment variables, see plugin runtime configuration. Model presets use a separate static configuration contribution workflow.

Build artifacts

A tool plugin's index.ts default export is a defineTool() or defineToolSet() definition. The CLI build typically produces:

FilePurpose
dist/index.jsExecutable tool build
dist/manifest.jsonGenerated metadata and schemas
Icon filesMain tool icon and optional Toolkit child icons
README.mdOptional plugin documentation
assets/**Optional static resources

The pack command generates a .pkg installation file. Its output location follows the project's pack script or the CLI --output option. To update metadata or schemas, edit the source and rebuild the package.

Metadata and schemas

Authors maintain the following fields in SDK definitions. The CLI and SDK versions determine the generated Manifest structure.

DeclarationPurpose
manifest.pluginIdStable identifier shared by the plugin's versions
manifest.versionSemantic version used during installation and updates
manifest.name, manifest.descriptionEnglish and Chinese display names and descriptions
manifest.versionDescriptionChanges in this version
manifest.tagsPlugin category tags
createToolHandler({ inputSchema })Input types, constraints, defaults, and UI field descriptions
createToolHandler({ outputSchema })Handler return types and field descriptions
createToolHandler({ secretSchema }), defineToolSet({ secretSchema })Secret configuration and sensitive field declarations (declared in handler for single tools, shared at top level for Toolkits)
defineToolSet({ children })Toolkit child IDs, names, descriptions, and handlers

Keep child tool IDs stable so configured Workflows can continue to reference them. Declare secrets through secretSchema and read them from ctx.secrets in handlers. See icon requirements for icon names.

The CLI uses tool and tool-suite to select project skeletons. Build artifacts and the plugin service provide the installed tool's type, child relationships, and display data.

Runtime context capabilities

When executing a handler, the SDK supplies the ctx runtime context with the following capabilities:

Property / MethodPurposeTypical Use Case
ctx.secretsDecrypted secret values configured for the toolReading API keys, tokens, and trusted upstream endpoints
ctx.invoke.uploadFile()Uploads a file ({ file, fileName, contentType }) to the FastGPT host and returns [result, err] with result.accessURLReturning generated reports, images, or media artifacts
ctx.streamResponse()Streams text answer chunks ({ type: 'answer' | 'fastAnswer', content }) to the callerStreaming incremental text answers during execution

SDK and CLI entry points

ComponentAudienceResponsibility
@fastgpt-plugin/sdk-factoryPlugin authorsDefine tools, Toolkits, handlers, schemas, and host capability calls
@fastgpt-plugin/cliPlugin authorsCreate projects, debug locally and remotely, build, check, and pack
@fastgpt-plugin/sdk-clientFastGPT service integration developersCall plugin management and runtime interfaces

Use compatible versions declared by the target project. Consult the matching versions of the SDK Factory documentation and CLI documentation for complete interfaces.

Delivery and installation

Edit on GitHub

Last updated

On this page

Put your business knowledge to work with AI

Import company documents and build accurate, reliable, traceable AI answers.