Agregar declaracion de tipos TypeScript para webmcp.js
- src/webmcp.d.ts con tipos para la API publica (WebMCP, options, handlers) - package.json: campo "types" apuntando al .d.ts
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"version": "0.2.0",
|
||||
"description": "Fork de WebMCP con registro dinamico de herramientas - Nucleo Rio Frio",
|
||||
"main": "src/websocket-server.js",
|
||||
"types": "src/webmcp.d.ts",
|
||||
"bin": {
|
||||
"@nucleoriofrio/webmcp": "./build/index.js"
|
||||
},
|
||||
|
||||
52
src/webmcp.d.ts
vendored
Normal file
52
src/webmcp.d.ts
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user