Class: McpTool<TParams, TResult>
MCP schema-based tool class
McpTool
Description
Tool that uses MCP (Model Context Protocol) schema format for parameter definition.
Example
import { McpTool } from '@robota-sdk/tools';
const mcpTool = new McpTool({
name: 'calculateSum',
description: 'Calculate the sum of two numbers',
category: 'math',
parameters: {
type: 'object',
properties: {
a: {
type: 'number',
description: 'First number'
},
b: {
type: 'number',
description: 'Second number'
}
},
required: ['a', 'b']
},
execute: async (params) => {
const result = params.a + params.b;
return {
status: 'success',
data: { sum: result }
};
}
});
Type parameters
Name | Type | Description |
---|---|---|
TParams | any | Tool parameter type |
TResult | any | Tool result type |
Hierarchy
BaseTool
<TParams
,TResult
>↳
McpTool
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new McpTool<TParams
, TResult
>(options
): McpTool
<TParams
, TResult
>
Constructor
Type parameters
Name | Type |
---|---|
TParams | any |
TResult | any |
Parameters
Name | Type | Description |
---|---|---|
options | McpToolOptions <TParams , TResult > | MCP tool options |
Returns
McpTool
<TParams
, TResult
>
Overrides
Defined in
packages/tools/src/tool/mcp-tool.ts:71
Properties
name
• Readonly
name: string
Tool name
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:29
description
• Readonly
description: string
Tool description
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:34
category
• Optional
Readonly
category: string
Tool category
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:39
version
• Optional
Readonly
version: string
Tool version
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:44
Accessors
schema
• get
schema(): any
Tool schema (returns MCP schema)
Returns
any
MCP schema
Overrides
BaseTool.schema
Defined in
packages/tools/src/tool/mcp-tool.ts:81
Methods
execute
▸ execute(params
): Promise
<ToolResult
<TResult
>>
Execute tool
Parameters
Name | Type | Description |
---|---|---|
params | TParams | Tool parameters |
Returns
Promise
<ToolResult
<TResult
>>
Tool execution result
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:108
toFunctionSchema
▸ toFunctionSchema(): FunctionSchema
Convert to function schema
Returns
Function schema
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:145
toFunctionDefinition
▸ toFunctionDefinition(): FunctionDefinition
Convert to function definition
Returns
Function definition
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:158
toString
▸ toString(): string
Generate string representation
Returns
string
String representation of the tool
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:171
create
▸ create<TParams
, TResult
>(options
): McpTool
<TParams
, TResult
>
MCP tool creation helper method
Type parameters
Name | Type |
---|---|
TParams | any |
TResult | any |
Parameters
Name | Type | Description |
---|---|---|
options | McpToolOptions <TParams , TResult > | MCP tool options |
Returns
McpTool
<TParams
, TResult
>
McpTool instance