-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool-adapter.ts
More file actions
41 lines (36 loc) · 1.19 KB
/
tool-adapter.ts
File metadata and controls
41 lines (36 loc) · 1.19 KB
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
40
41
/**
* Tool Adapter Base Class
* Extends Adapter to provide tool-specific functionality
*/
import { Adapter } from './adapter';
import type { ToolDefinition, ToolExecutionContext, ToolResult, ValidationResult } from './types';
export abstract class ToolAdapter extends Adapter {
/**
* Get the tool definition (name, description, schema)
* This is used by MCP to list available tools
*/
abstract getToolDefinition(): ToolDefinition;
/**
* Execute the tool with given arguments
* @param args Tool arguments from MCP client
* @param context Execution context (logger, config, etc.)
* @returns Tool result (success/error with data)
*/
abstract execute(
args: Record<string, unknown>,
context: ToolExecutionContext
): Promise<ToolResult>;
/**
* Optional: Validate arguments before execution
* @param args Tool arguments to validate
* @returns Validation result
*/
validate?(args: Record<string, unknown>): ValidationResult;
/**
* Optional: Estimate token usage for the response
* Used for token budget management
* @param args Tool arguments
* @returns Estimated token count
*/
estimateTokens?(args: Record<string, unknown>): number;
}