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: ToolSchema = ToolSchema(), title: String? = null, outputSchema: ToolSchema? = null, toolAnnotations: ToolAnnotations? = null, meta: JsonObject? = 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.

meta

Optional metadata as a JsonObject.

handler

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

Throws

If the server does not support tools.