Skip to content

Interface: PromptConfig<TContext, TArgs>

Defined in: packages/core/src/prompt/types.ts:437

Configuration for definePrompt().

Type Parameters

Type ParameterDefault typeDescription
TContext-Application context type
TArgs extends Record<string, unknown>Record<string, unknown>Validated args type (inferred from args)

Properties

args?

ts
optional args: 
  | ZodObject<ZodRawShape, UnknownKeysParam, ZodTypeAny, {
[key: string]: any;
}, {
[key: string]: any;
}>
  | PromptParamsMap;

Defined in: packages/core/src/prompt/types.ts:457

Argument definitions.

Accepts either:

  • PromptParamsMap (JSON descriptors) — zero Zod imports needed
  • ZodObject — for power users who need full Zod control

Constraint: Only flat primitives allowed. Arrays and nested objects will fail with a runtime error at definition time.


description?

ts
optional description: string;

Defined in: packages/core/src/prompt/types.ts:442

Human-readable description shown in the slash command palette


handler()

ts
handler: (ctx, args) => Promise<PromptResult>;

Defined in: packages/core/src/prompt/types.ts:496

The hydration handler.

Receives validated, typed, coerced args and returns a PromptResult. This is where server-side data fetching and Presenter calls happen.

DX: ctx is typed as TContext & LoopbackContextinvokeTool() appears in autocomplete without any manual cast.

Parameters

ParameterType
ctxTContext & LoopbackContext
argsTArgs

Returns

Promise<PromptResult>


hydrationTimeout?

ts
optional hydrationTimeout: number;

Defined in: packages/core/src/prompt/types.ts:485

Maximum hydration time in milliseconds.

When set, the handler is wrapped in a strict deadline. If external data sources (APIs, databases) don't respond within this time, the framework cuts the Promise and returns a graceful SYSTEM ALERT. The UI unblocks immediately — the user never sees a frozen screen.

Example

typescript
definePrompt('morning_briefing', {
    hydrationTimeout: 3000, // 3 seconds strict
    handler: async (ctx, args) => {
        // If Jira takes 15s, the framework cuts at 3s
        const tickets = await ctx.invokeTool('jira.get_assigned');
        return { messages: [...] };
    },
});

icons?

ts
optional icons: {
  dark?: string;
  light?: string;
};

Defined in: packages/core/src/prompt/types.ts:445

Icons for light/dark themes (MCP spec Icons)

dark?

ts
optional dark: string;

light?

ts
optional light: string;

middleware?

ts
optional middleware: MiddlewareFn<TContext>[];

Defined in: packages/core/src/prompt/types.ts:463

Middleware chain (same signature as tool middleware)


tags?

ts
optional tags: string[];

Defined in: packages/core/src/prompt/types.ts:460

Capability tags for selective exposure


title?

ts
optional title: string;

Defined in: packages/core/src/prompt/types.ts:439

Human-readable title for display in UI (MCP spec BaseMetadata.title)