Documentation
¶
Overview ¶
Package mcptoolset provides an MCP tool set.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns MCP ToolSet. MCP ToolSet connects to a MCP Server, retrieves MCP Tools into ADK Tools and passes them to the LLM. It uses https://github.com/modelcontextprotocol/go-sdk for MCP communication. MCP session is created lazily on the first request to LLM.
Usage: create MCP ToolSet with mcptoolset.New() and provide it to the LLMAgent in the llmagent.Config.
Example:
llmagent.New(llmagent.Config{
Name: "agent_name",
Model: model,
Description: "...",
Instruction: "...",
Toolsets: []tool.Set{
mcptoolset.New(mcptoolset.Config{
Transport: &mcp.CommandTransport{Command: exec.Command("myserver")}
}),
},
})
Types ¶
type Config ¶
type Config struct {
// Client is an optional custom MCP client to use. If nil, a default client will be created.
Client *mcp.Client
// Transport that will be used to connect to MCP server.
Transport mcp.Transport
// Deprecated: use tool.FilterToolset instead.
// ToolFilter selects tools for which tool.Predicate returns true.
// If ToolFilter is nil, then all tools are returned.
// tool.StringPredicate can be convenient if there's a known fixed list of tool names.
ToolFilter tool.Predicate
// RequireConfirmation flags whether the tools from this toolset must always ask for user confirmation
// before execution. If set to true, the ADK framework will automatically initiate
// a Human-in-the-Loop (HITL) confirmation request when a tool is invoked.
RequireConfirmation bool
// RequireConfirmationProvider allows for dynamic determination of whether
// user confirmation is needed. This field is a function called at runtime to decide if
// a confirmation request should be sent. The function takes the toolName and tool's input parameters as arguments.
// This provider offers more flexibility than the static RequireConfirmation flag,
// enabling conditional confirmation based on the invocation details.
// If set, this takes precedence over the RequireConfirmation flag.
//
// Required signature for a provider function:
// func(name string, toolInput any) bool
// Returning true means confirmation is required.
RequireConfirmationProvider ConfirmationProvider
}
Config provides initial configuration for the MCP ToolSet.
type ConfirmationProvider ¶
ConfirmationProvider defines a function that dynamically determines whether a specific tool execution requires user confirmation.
It accepts the tool name and the input parameters as arguments. Returning true signals that the system must wait for Human-in-the-Loop (HITL) approval before proceeding with the execution.