Documentation
¶
Index ¶
- func GetGoogleIDToken(ctx context.Context, audience string) (string, error)
- func GetSupportedMcpVersions() []string
- func NewCustomTokenSource(provider func() string) oauth2.TokenSource
- type ClientOption
- func WithClientHeaderString(headerName string, value string) ClientOption
- func WithClientHeaderTokenSource(headerName string, value oauth2.TokenSource) ClientOption
- func WithClientName(name string) ClientOption
- func WithClientVersion(version string) ClientOption
- func WithDefaultToolOptions(opts ...ToolOption) ClientOption
- func WithHTTPClient(client *http.Client) ClientOption
- func WithProtocol(p Protocol) ClientOption
- type Float
- type Integer
- type ManifestSchema
- type ParameterSchema
- type Protocol
- type ToolConfig
- type ToolOption
- func WithAuthTokenSource(authSourceName string, idToken oauth2.TokenSource) ToolOption
- func WithAuthTokenString(authSourceName string, idToken string) ToolOption
- func WithBindParamAnyMap(name string, value map[string]any) ToolOption
- func WithBindParamAnyMapFunc(name string, fn func() (map[string]any, error)) ToolOption
- func WithBindParamBool(name string, value bool) ToolOption
- func WithBindParamBoolArray(name string, value []bool) ToolOption
- func WithBindParamBoolArrayFunc(name string, fn func() ([]bool, error)) ToolOption
- func WithBindParamBoolFunc(name string, fn func() (bool, error)) ToolOption
- func WithBindParamBoolMap(name string, value map[string]bool) ToolOption
- func WithBindParamBoolMapFunc(name string, fn func() (map[string]bool, error)) ToolOption
- func WithBindParamFloat[T Float](name string, value T) ToolOption
- func WithBindParamFloatArray[T Float](name string, value []T) ToolOption
- func WithBindParamFloatArrayFunc[T Float](name string, fn func() ([]T, error)) ToolOption
- func WithBindParamFloatFunc[T Float](name string, fn func() (T, error)) ToolOption
- func WithBindParamFloatMap[T Float](name string, value map[string]T) ToolOption
- func WithBindParamFloatMapFunc[T Float](name string, fn func() (map[string]T, error)) ToolOption
- func WithBindParamInt[T Integer](name string, value T) ToolOption
- func WithBindParamIntArray[T Integer](name string, value []T) ToolOption
- func WithBindParamIntArrayFunc[T Integer](name string, fn func() ([]T, error)) ToolOption
- func WithBindParamIntFunc[T Integer](name string, fn func() (T, error)) ToolOption
- func WithBindParamIntMap[T Integer](name string, value map[string]T) ToolOption
- func WithBindParamIntMapFunc[T Integer](name string, fn func() (map[string]T, error)) ToolOption
- func WithBindParamString(name string, value string) ToolOption
- func WithBindParamStringArray(name string, value []string) ToolOption
- func WithBindParamStringArrayFunc(name string, fn func() ([]string, error)) ToolOption
- func WithBindParamStringFunc(name string, fn func() (string, error)) ToolOption
- func WithBindParamStringMap(name string, value map[string]string) ToolOption
- func WithBindParamStringMapFunc(name string, fn func() (map[string]string, error)) ToolOption
- func WithStrict(strict bool) ToolOption
- type ToolSchema
- type ToolboxClient
- type ToolboxTool
- func (tt *ToolboxTool) DescribeParameters() string
- func (tt *ToolboxTool) Description() string
- func (tt *ToolboxTool) InputSchema() ([]byte, error)
- func (tt *ToolboxTool) Invoke(ctx context.Context, input map[string]any) (any, error)
- func (tt *ToolboxTool) Name() string
- func (tt *ToolboxTool) Parameters() []ParameterSchema
- func (tt *ToolboxTool) ToolFrom(opts ...ToolOption) (*ToolboxTool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetGoogleIDToken ¶
GetGoogleIDToken fetches a Google ID token for a specific audience.
Inputs:
- ctx: The context for the request, which can be used for cancellation or deadlines.
- audience: The recipient of the token, typically the URL of the secured service
Returns:
A string in the format "Bearer <token>" on success, or an error if the token could not be fetched.
func GetSupportedMcpVersions ¶
func GetSupportedMcpVersions() []string
GetSupportedMcpVersions returns a list of supported MCP protocol versions.
func NewCustomTokenSource ¶
func NewCustomTokenSource(provider func() string) oauth2.TokenSource
This function converts a custom function that returns a string into an oauth2.TokenSource type.
Inputs:
- provider: A custom function that returns a token as a string.
Returns:
- An oauth2.TokenSource that wraps the custom function.
Types ¶
type ClientOption ¶
type ClientOption func(*ToolboxClient) error
ClientOption configures a ToolboxClient at creation time.
func WithClientHeaderString ¶
func WithClientHeaderString(headerName string, value string) ClientOption
WithClientHeaderString adds a static string value as a client-wide HTTP header.
func WithClientHeaderTokenSource ¶
func WithClientHeaderTokenSource(headerName string, value oauth2.TokenSource) ClientOption
WithClientHeaderTokenSource adds a dynamic client-wide HTTP header from a TokenSource.
func WithClientName ¶
func WithClientName(name string) ClientOption
WithClientName sets the client name used in the MCP protocol handshake. Defaults to "toolbox-core-go" if not set.
func WithClientVersion ¶ added in v0.7.0
func WithClientVersion(version string) ClientOption
WithClientVersion sets the client version used in the MCP protocol handshake. Defaults to the core SDK version if not set.
func WithDefaultToolOptions ¶
func WithDefaultToolOptions(opts ...ToolOption) ClientOption
WithDefaultToolOptions provides default Options that will be applied to every tool loaded by this client.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) ClientOption
WithHTTPClient provides a custom http.Client to the ToolboxClient.
func WithProtocol ¶
func WithProtocol(p Protocol) ClientOption
WithProtocol provides a the underlying transport protocol to the ToolboxClient..
type ManifestSchema ¶
type ManifestSchema = transport.ManifestSchema
type ParameterSchema ¶
type ParameterSchema = transport.ParameterSchema
ParameterSchema defines the structure and validation logic for tool parameters.
type Protocol ¶
type Protocol string
Protocol defines underlying transport protocols.
const ( // MCP Version Constants MCPv20251125 Protocol = "2025-11-25" MCPv20250618 Protocol = "2025-06-18" MCPv20250326 Protocol = "2025-03-26" MCPv20241105 Protocol = "2024-11-05" // MCP is the default alias pointing to the newest supported version. MCP = MCPv20250618 )
type ToolConfig ¶
type ToolConfig struct {
AuthTokenSources map[string]oauth2.TokenSource
BoundParams map[string]any
Strict bool
// contains filtered or unexported fields
}
ToolConfig holds all configurable aspects for creating or deriving a tool.
type ToolOption ¶
type ToolOption func(*ToolConfig) error
ToolOption defines a single, universal type for a functional option that configures a tool.
func WithAuthTokenSource ¶
func WithAuthTokenSource(authSourceName string, idToken oauth2.TokenSource) ToolOption
WithAuthTokenSource provides an authentication token from a standard TokenSource.
func WithAuthTokenString ¶
func WithAuthTokenString(authSourceName string, idToken string) ToolOption
WithAuthTokenString provides a static string authentication token.
func WithBindParamAnyMap ¶ added in v0.7.0
func WithBindParamAnyMap(name string, value map[string]any) ToolOption
WithBindParamAnyMap binds a generic map to a parameter.
func WithBindParamAnyMapFunc ¶ added in v0.7.0
func WithBindParamAnyMapFunc(name string, fn func() (map[string]any, error)) ToolOption
WithBindParamAnyMapFunc binds a function that returns a generic map to a parameter.
func WithBindParamBool ¶
func WithBindParamBool(name string, value bool) ToolOption
WithBindParamBool binds a static boolean value to a parameter.
func WithBindParamBoolArray ¶
func WithBindParamBoolArray(name string, value []bool) ToolOption
WithBindParamBoolArray binds a static slice of booleans to a parameter.
func WithBindParamBoolArrayFunc ¶
func WithBindParamBoolArrayFunc(name string, fn func() ([]bool, error)) ToolOption
WithBindParamBoolArrayFunc binds a function that returns a slice of booleans.
func WithBindParamBoolFunc ¶
func WithBindParamBoolFunc(name string, fn func() (bool, error)) ToolOption
WithBindParamBoolFunc binds a function that returns a boolean to a parameter.
func WithBindParamBoolMap ¶ added in v0.7.0
func WithBindParamBoolMap(name string, value map[string]bool) ToolOption
WithBindParamBoolMap binds a static map of booleans to a parameter.
func WithBindParamBoolMapFunc ¶ added in v0.7.0
func WithBindParamBoolMapFunc(name string, fn func() (map[string]bool, error)) ToolOption
WithBindParamBoolMapFunc binds a function that returns a map of booleans to a parameter.
func WithBindParamFloat ¶
func WithBindParamFloat[T Float](name string, value T) ToolOption
WithBindParamFloat binds a static float value to a parameter.
func WithBindParamFloatArray ¶
func WithBindParamFloatArray[T Float](name string, value []T) ToolOption
WithBindParamFloatArray binds a static slice of floats to a parameter.
func WithBindParamFloatArrayFunc ¶
func WithBindParamFloatArrayFunc[T Float](name string, fn func() ([]T, error)) ToolOption
WithBindParamFloatArrayFunc binds a function that returns a slice of floats.
func WithBindParamFloatFunc ¶
func WithBindParamFloatFunc[T Float](name string, fn func() (T, error)) ToolOption
WithBindParamFloatFunc binds a function that returns a float to a parameter.
func WithBindParamFloatMap ¶ added in v0.7.0
func WithBindParamFloatMap[T Float](name string, value map[string]T) ToolOption
WithBindParamFloatMap binds a static map of floats to a parameter.
func WithBindParamFloatMapFunc ¶ added in v0.7.0
func WithBindParamFloatMapFunc[T Float](name string, fn func() (map[string]T, error)) ToolOption
WithBindParamFloatMapFunc binds a function that returns a map of floats to a parameter.
func WithBindParamInt ¶
func WithBindParamInt[T Integer](name string, value T) ToolOption
WithBindParamInt binds a static integer value to a parameter.
func WithBindParamIntArray ¶
func WithBindParamIntArray[T Integer](name string, value []T) ToolOption
WithBindParamIntArray binds a static slice of integers to a parameter.
func WithBindParamIntArrayFunc ¶
func WithBindParamIntArrayFunc[T Integer](name string, fn func() ([]T, error)) ToolOption
WithBindParamIntArrayFunc binds a function that returns a slice of integers.
func WithBindParamIntFunc ¶
func WithBindParamIntFunc[T Integer](name string, fn func() (T, error)) ToolOption
WithBindParamIntFunc binds a function that returns an integer to a parameter.
func WithBindParamIntMap ¶ added in v0.7.0
func WithBindParamIntMap[T Integer](name string, value map[string]T) ToolOption
WithBindParamIntMap binds a static map of integers to a parameter.
func WithBindParamIntMapFunc ¶ added in v0.7.0
func WithBindParamIntMapFunc[T Integer](name string, fn func() (map[string]T, error)) ToolOption
WithBindParamIntMapFunc binds a function that returns a map of integers to a parameter.
func WithBindParamString ¶
func WithBindParamString(name string, value string) ToolOption
WithBindParamString binds a static string value to a parameter.
func WithBindParamStringArray ¶
func WithBindParamStringArray(name string, value []string) ToolOption
WithBindParamStringArray binds a static slice of strings to a parameter.
func WithBindParamStringArrayFunc ¶
func WithBindParamStringArrayFunc(name string, fn func() ([]string, error)) ToolOption
WithBindParamStringArrayFunc binds a function that returns a slice of strings.
func WithBindParamStringFunc ¶
func WithBindParamStringFunc(name string, fn func() (string, error)) ToolOption
WithBindParamStringFunc binds a function that returns a string to a parameter.
func WithBindParamStringMap ¶ added in v0.7.0
func WithBindParamStringMap(name string, value map[string]string) ToolOption
WithBindParamStringMap binds a static map of strings to a parameter.
func WithBindParamStringMapFunc ¶ added in v0.7.0
func WithBindParamStringMapFunc(name string, fn func() (map[string]string, error)) ToolOption
WithBindParamStringMapFunc binds a function that returns a map of strings to a parameter.
func WithStrict ¶
func WithStrict(strict bool) ToolOption
WithStrict provides an option to enable strict validation for LoadToolset.
type ToolSchema ¶
type ToolSchema = transport.ToolSchema
ToolSchema defines a single tool in the manifest.
type ToolboxClient ¶
type ToolboxClient struct {
// contains filtered or unexported fields
}
The synchronous interface for a Toolbox service client.
func NewToolboxClient ¶
func NewToolboxClient(url string, opts ...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 ClientOption functions to configure the client, such as setting a custom http.Client, default headers, or the underlying protocol.
Returns:
A configured *ToolboxClient and a nil error on success, or a nil client and an error if configuration fails.
func (*ToolboxClient) LoadTool ¶
func (tc *ToolboxClient) LoadTool(name string, ctx context.Context, opts ...ToolOption) (*ToolboxTool, error)
LoadTool fetches a manifest for a single tool
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 a nil tool and an error if loading or validation fails.
func (*ToolboxClient) LoadToolset ¶
func (tc *ToolboxClient) LoadToolset(name string, ctx context.Context, opts ...ToolOption) ([]*ToolboxTool, error)
LoadToolset fetches a manifest for a collection of tools.
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 {
// contains filtered or unexported fields
}
ToolboxTool represents an immutable, universal definition of a Toolbox tool.
func (*ToolboxTool) DescribeParameters ¶
func (tt *ToolboxTool) DescribeParameters() string
DescribeParameters returns a single, human-readable string that describes all of the tool's unbound parameters, including their names, types, and descriptions.
Returns:
A formatted string of parameter descriptions, or an empty string if there are no unbound parameters.
func (*ToolboxTool) Description ¶
func (tt *ToolboxTool) Description() string
Description returns the tool's description.
func (*ToolboxTool) InputSchema ¶
func (tt *ToolboxTool) InputSchema() ([]byte, error)
InputSchema generates an OpenAPI JSON Schema for the tool's input parameters and returns it as raw bytes.
func (*ToolboxTool) Invoke ¶
Invoke executes the tool with the given input.
Inputs:
- ctx: The context to control the lifecycle of the API request.
- input: A map of parameter names to values provided by the user for this specific invocation.
Returns:
The result from the API call, which can be a structured object (from a JSON 'result' field) or a raw string. Returns an error if any step of the process fails.
func (*ToolboxTool) Parameters ¶
func (tt *ToolboxTool) Parameters() []ParameterSchema
Parameters returns the list of parameters that must be provided by a user at invocation time.
func (*ToolboxTool) ToolFrom ¶
func (tt *ToolboxTool) ToolFrom(opts ...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 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 a nil tool and an error if the new options are invalid or conflict with existing settings.
