@directus/api
Version:
Directus is a real-time API and App dashboard for managing SQL database content
41 lines (40 loc) • 1.13 kB
TypeScript
import type { Accountability, SchemaOverview } from '@directus/types';
import type { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
import type { ZodType } from 'zod';
export type ToolResultBase = {
type?: 'text' | 'image' | 'audio';
url?: string | undefined;
};
export type TextToolResult = ToolResultBase & {
type: 'text';
data: unknown;
};
export type AssetToolResult = ToolResultBase & {
type: 'image' | 'audio';
data: string;
mimeType: string;
};
export type ToolResult = TextToolResult | AssetToolResult;
export type ToolHandler<T> = {
(options: {
args: T;
schema: SchemaOverview;
accountability: Accountability | undefined;
}): Promise<ToolResult | undefined>;
};
export type ToolEndpoint<T> = {
(options: {
input: T;
data: unknown;
}): string[] | undefined;
};
export interface ToolConfig<T> {
name: string;
description: string;
endpoint?: ToolEndpoint<T>;
admin?: boolean;
inputSchema: ZodType<any>;
validateSchema?: ZodType<T>;
annotations?: ToolAnnotations;
handler: ToolHandler<T>;
}