addTool

fun addTool(tool: Tool, handler: suspend (CallToolRequest) -> CallToolResult)(source)

Registers a single tool. The client can then call this tool.

Parameters

tool

A Tool object describing the tool.

handler

A suspend function that handles executing the tool when called by the client.

Throws

If the server does not support tools.


fun addTool(name: String, description: String, inputSchema: Tool.Input = Tool.Input(), title: String? = null, outputSchema: Tool.Output? = null, toolAnnotations: ToolAnnotations? = null, handler: suspend (CallToolRequest) -> CallToolResult)(source)

Registers a single tool. The client can then call this tool.

Parameters

name

The name of the tool.

title

An optional human-readable name of the tool for display purposes.

description

A human-readable description of what the tool does.

inputSchema

The expected input schema for the tool.

outputSchema

The optional expected output schema for the tool.

toolAnnotations

Optional additional tool information.

handler

A suspend function that handles executing the tool when called by the client.

Throws

If the server does not support tools.