Skip to main content
The SDK package provides functions for defining plugins, tools, and sources.

Exports

definePlugin(config): Plugin

Creates a plugin with a manifest and handler registry.
PluginConfig: Returns: Plugin object with:
  • manifest — serialized PluginManifest (Zod schemas converted to JSON Schema)
  • handlersMap<string, handler> keyed by tool path
Handlers are wrapped with Zod parsing. definePlugin doesn’t store the handler reference verbatim — it wraps it in (ctx, input) => handler(ctx, tool.inputSchema.parse(input ?? {})). This means schema defaults are applied before your handler sees the input, and invalid input throws a Zod error before any side effects. If you write inputSchema: z.object({ calendarId: z.string().default("primary") }) and the caller omits calendarId, your handler reads "primary", not undefined. Tests that compare handler references for equality won’t work — invoke through the wrapper.

defineTool(config): ToolConfig

Type-safe wrapper for tool definitions. Returns the config as-is with proper generic inference.

defineSource(config): SourceConfig

Type-safe wrapper for source configurations. Returns the config as-is.

elicit(ctx, request): Promise<ElicitationResponse>

Convenience wrapper for requesting user approval. Equivalent to calling ctx.elicit(request) directly.

SourceConfigSchema

Zod discriminated union schema for validating source configurations. Validates openapi, graphql, mcp, and plugin source types.

Type exports

Plugin, PluginConfig, ToolConfig, Source, SourceAdapter, SourceConfig, SourceAuth, OpenAPISourceConfig, MCPSourceConfig, GraphQLSourceConfig, PluginSourceConfig