-
Notifications
You must be signed in to change notification settings - Fork 358
Expand file tree
/
Copy pathtool.ts
More file actions
executable file
·39 lines (32 loc) · 895 Bytes
/
tool.ts
File metadata and controls
executable file
·39 lines (32 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import type {
ImageContent,
TextContent,
} from "@modelcontextprotocol/sdk/types.js";
import type { z } from "zod";
import type { Context } from "../context.js";
export type ToolSchema<Input extends InputType> = {
name: string;
description: string;
inputSchema: Input;
};
// Export InputType
export type InputType = z.Schema;
export type ToolActionResult =
| { content?: (ImageContent | TextContent)[] }
| undefined
| void;
export type ToolResult = {
action?: () => Promise<ToolActionResult>;
waitForNetwork: boolean;
};
export type Tool<Input extends InputType = InputType> = {
capability: string;
schema: ToolSchema<Input>;
handle: (context: Context, params: z.output<Input>) => Promise<ToolResult>;
};
export function defineTool<Input extends InputType>(
tool: Tool<Input>,
): Tool<Input> {
return tool;
}
export {}; // Ensure this is treated as a module