McpTool

class McpTool(mcpClient: Client, val descriptor: ToolDescriptor) : Tool<McpTool.Args, McpTool.Result> (source)

A Tool implementation that calls an MCP (Model Context Protocol) tool.

This class serves as a bridge between the agent framework's Tool interface and the MCP SDK. It allows MCP tools to be used within the agent framework by:

  1. Converting agent framework tool arguments to MCP tool arguments

  2. Calling the MCP tool through the MCP client

  3. Converting MCP tool results back to agent framework tool results

Constructors

Link copied to clipboard
constructor(mcpClient: Client, descriptor: ToolDescriptor)

Types

Link copied to clipboard
@Serializable(with = McpTool.ArgsSerializer::class)
data class Args(val arguments: JsonObject) : Tool.Args

Arguments for an MCP tool call.

Link copied to clipboard
class ArgsSerializer : KSerializer<McpTool.Args>

Custom serializer for the Args class.

Link copied to clipboard
class Result(val promptMessageContents: List<PromptMessageContent>) : ToolResult

Result of an MCP tool call.

Properties

Link copied to clipboard
open override val argsSerializer: KSerializer<McpTool.Args>
Link copied to clipboard
open override val descriptor: ToolDescriptor
Link copied to clipboard

Functions

Link copied to clipboard
fun decodeArgs(rawArgs: JsonObject): McpTool.Args
Link copied to clipboard
Link copied to clipboard
fun encodeArgs(args: McpTool.Args): JsonObject
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard