- src/webmcp.d.ts con tipos para la API publica (WebMCP, options, handlers) - package.json: campo "types" apuntando al .d.ts
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
export interface WebMCPOptions {
|
|
color?: string;
|
|
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
size?: string;
|
|
padding?: string;
|
|
inactivityTimeout?: number;
|
|
}
|
|
|
|
export interface ToolInputSchema {
|
|
type: string;
|
|
properties: Record<string, any>;
|
|
required?: string[];
|
|
}
|
|
|
|
export interface ResourceOptions {
|
|
uri?: string;
|
|
uriTemplate?: string;
|
|
mimeType?: string;
|
|
}
|
|
|
|
export interface PromptArgument {
|
|
name: string;
|
|
description?: string;
|
|
required?: boolean;
|
|
}
|
|
|
|
export type ToolHandler = (args: any) => string | object | Promise<string | object>;
|
|
export type PromptHandler = (args: any) => object | Promise<object>;
|
|
export type ResourceHandler = (uri: string) => object | Promise<object>;
|
|
|
|
declare class WebMCP {
|
|
readonly isConnected: boolean;
|
|
readonly isExpanded: boolean;
|
|
|
|
constructor(options?: WebMCPOptions);
|
|
|
|
connect(connectionToken: string): Promise<void>;
|
|
disconnect(): void;
|
|
|
|
registerTool(name: string, description: string, schema: ToolInputSchema, executeFn: ToolHandler): void;
|
|
unregisterTool(name: string): void;
|
|
unregisterAllTools(): void;
|
|
|
|
registerPrompt(name: string, description: string, args: PromptArgument[], executeFn: PromptHandler): void;
|
|
unregisterPrompt(name: string): void;
|
|
|
|
registerResource(name: string, description: string, options: ResourceOptions, provideFn: ResourceHandler): void;
|
|
unregisterResource(name: string): void;
|
|
}
|
|
|
|
export default WebMCP;
|
|
export { WebMCP };
|