tbadk

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

README

MCP Toolbox Logo

MCP Toolbox tbadk SDK

[!IMPORTANT] Breaking Change Notice: As of version 0.6.0, this repository has transitioned to a multi-module structure.

  • For new versions (v0.6.0+): You must import specific modules (e.g., go get github.com/googleapis/mcp-toolbox-sdk-go/tbadk).
  • For older versions (v0.5.1 and below): The repository remains a single-module library (go get github.com/googleapis/mcp-toolbox-sdk-go).
  • Please update your imports and go.mod accordingly when upgrading.

This SDK allows you to seamlessly integrate the functionalities of Toolbox allowing you to load and use tools defined in the service as standard Go structs within your ADK Go applications.

This simplifies integrating external functionalities (like APIs, databases, or custom logic) managed by the Toolbox into your workflows, especially those involving Large Language Models (LLMs).

Installation

go get github.com/googleapis/mcp-toolbox-sdk-go/tbadk

This SDK is supported on Go version 1.24.4 and higher.

[!NOTE]

  • While the SDK itself is synchronous, you can execute its functions within goroutines to achieve asynchronous behavior.

Quickstart

Here's a minimal example to get you started. Ensure your Toolbox service is running and accessible.

package main

import (
  "context"
  "fmt"
  "github.com/googleapis/mcp-toolbox-sdk-go/tbadk"
)

func quickstart() string {
  inputs := map[string]any{"location": "London"}
  client, err := tbadk.NewToolboxClient("http://localhost:5000")
  if err != nil {
    return fmt.Sprintln("Could not start Toolbox Client", err)
  }
  tool, err := client.LoadTool("get_weather", ctx)
  if err != nil {
    return fmt.Sprintln("Could not load Toolbox Tool", err)
  }
  // pass the tool.Context as ctx into the Run() method
  result, err := tool.Run(ctx, inputs)
  if err != nil {
    return fmt.Sprintln("Could not invoke tool", err)
  }
  return fmt.Sprintln(result["output"])
}

func main() {
  fmt.Println(quickstart())
}

Usage

The tbadk package provides a framework-agnostic way to interact with your MCP Toolbox server. For detailed guides and advanced configuration, please visit the following sections on our Documentation Site:

Contributing

Contributions are welcome! Please refer to the DEVELOPER.md file for guidelines on how to set up a development environment and run tests.

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Support

If you encounter issues or have questions, check the existing GitHub Issues for the main Toolbox project.

Documentation

Index

Constants

View Source
const Version = "1.0.0" // x-release-please-version

Version is the current version of the library. This is updated automatically by release-please.

Variables

This section is empty.

Functions

This section is empty.

Types

type ToolboxClient

type ToolboxClient struct {
	*core.ToolboxClient
}

The MCP Toolbox for Databases Client.

func NewToolboxClient

func NewToolboxClient(url string, opts ...core.ClientOption) (ToolboxClient, error)

NewToolboxClient creates and configures a new, immutable client for interacting with a Toolbox server.

Inputs:

  • url: The base URL of the Toolbox server.
  • opts: A variadic list of core.ClientOption functions to configure the client, such as setting a custom http.Client or default headers.

Returns:

A configured ToolboxClient and a nil error on success, or an empty client
and an error if configuration fails.

func (ToolboxClient) LoadTool

func (tc ToolboxClient) LoadTool(name string, ctx context.Context, opts ...core.ToolOption) (ToolboxTool, error)

LoadTool fetches a single tool from the Toolbox server

Inputs:

  • name: The specific name of the tool to load.
  • ctx: The context to control the lifecycle of the request.
  • opts: A variadic list of ToolOption functions to configure auth tokens or bind parameters for this tool.

Returns:

A configured *ToolboxTool and a nil error on success, or an empty tool and
an error if loading or validation fails.

func (ToolboxClient) LoadToolset

func (tc ToolboxClient) LoadToolset(name string, ctx context.Context, opts ...core.ToolOption) ([]ToolboxTool, error)

LoadToolset fetches a collection of tools from the Toolbox server

Inputs:

  • name: Name of the toolset to be loaded.Set this arg to "" to load the default toolset
  • ctx: The context to control the lifecycle of the request.
  • opts: A variadic list of ToolOption functions. These can include WithStrict and options for auth or bound params that may apply to tools in the set.

Returns:

A slice of configured *ToolboxTool and a nil error on success, or a nil
slice and an error if loading or validation fails.

type ToolboxTool

type ToolboxTool struct {
	*core.ToolboxTool
	// contains filtered or unexported fields
}

func (ToolboxTool) Declaration

func (tt ToolboxTool) Declaration() *genai.FunctionDeclaration

Declaration returns the tool's function declaration.

func (ToolboxTool) IsLongRunning

func (tt ToolboxTool) IsLongRunning() bool

IsLongRunning indicates whether the tool is a long-running operation TBADK will not support long running tools for now

func (ToolboxTool) ProcessRequest

func (tt ToolboxTool) ProcessRequest(ctx agent.Context, req *model.LLMRequest) error

This function is copied from ADK Go if there is already a tool with a function declaration, it appends another to it; otherwise, it creates a new genai tool.

func (ToolboxTool) Run

func (tt ToolboxTool) Run(ctx agent.Context, args any) (result map[string]any, err error)

Run executes the tool with the given input.

Inputs:

  • ctx: The tool context to control the lifecycle of the API request.
  • args: A map of parameter names to values provided by the user for this specific invocation.

Returns:

The result from the API call, in the form of a map[string]any with the result
in the 'output' field.

func (ToolboxTool) ToolFrom

func (tt ToolboxTool) ToolFrom(opts ...core.ToolOption) (ToolboxTool, error)

ToolFrom creates a new, more specialized tool from an existing one by applying additional options. This is useful for creating variations of a tool with different bound parameters / auth tokens without modifying the original and all provided options must be applicable.

Inputs:

  • opts: A variadic list of ToolOption functions to further configure the new tool, such as binding more parameters.

Returns:

A new, specialized ToolboxTool and a nil error, or an empty tool and an
error if the new options are invalid or conflict with existing settings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL