Documentation
¶
Overview ¶
Copyright 2025 Google LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func IsAuthorized(authRequiredSources []string, verifiedAuthServices []string) bool
- func IsValidName(s string) bool
- func Register(resourceType string, factory ToolConfigFactory) bool
- func ShouldSuppress(ctx context.Context, t Tool, src sources.Source) bool
- type AccessToken
- type BaseTool
- func (b BaseTool[T]) Authorized(verifiedAuthServices []string) bool
- func (b BaseTool[T]) EmbedParams(ctx context.Context, paramValues parameters.ParamValues, ...) (parameters.ParamValues, error)
- func (b BaseTool[T]) GetAnnotations(_ sources.Source) *ToolAnnotations
- func (b BaseTool[T]) GetAuthRequired() []string
- func (b BaseTool[T]) GetAuthTokenHeaderName(_ sources.Source) (string, error)
- func (b BaseTool[T]) GetDescription() string
- func (b BaseTool[T]) GetName() string
- func (b BaseTool[T]) GetParameters(_ sources.Source) (parameters.Parameters, error)
- func (b BaseTool[T]) GetScopesRequired() []string
- func (b BaseTool[T]) GetToolUIMetadata() *ToolUIMetadata
- func (b BaseTool[T]) HasSecureParams() bool
- func (b BaseTool[T]) Manifest(_ sources.Source) (Manifest, error)
- func (b BaseTool[T]) RequiresClientAuthorization(_ sources.Source) (bool, error)
- func (b BaseTool[T]) StaticManifest() Manifest
- type ConfigBase
- type HTTPMethod
- type Manifest
- type PrimitiveManagerI
- type Tool
- type ToolAnnotations
- type ToolConfig
- type ToolConfigFactory
- type ToolMeta
- type ToolUIMetadata
- type ToolVisibility
- type Toolset
- type ToolsetConfig
- type ToolsetManifest
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownToolType = fmt.Errorf("unknown tool type")
Functions ¶
func IsAuthorized ¶
Helper function that returns if a tool invocation request is authorized
func IsValidName ¶
func Register ¶
func Register(resourceType string, factory ToolConfigFactory) bool
Register allows individual tool packages to register their configuration factory function. This is typically called from an init() function in the tool's package. It associates a 'type' string with a function that can produce the specific ToolConfig type. It returns true if the registration was successful, and false if a tool with the same type was already registered.
func ShouldSuppress ¶ added in v1.10.0
ShouldSuppress returns true if the tool should be suppressed from registration when its data source is in read-only mode, and logs relevant warnings or info messages. By default, if the source is read-only and the tool's ReadOnlyHint is explicitly false, the tool is suppressed. Unannotated tools (ReadOnlyHint == nil) or read-only tools (ReadOnlyHint == true) are not suppressed.
Types ¶
type AccessToken ¶
type AccessToken string
func (AccessToken) ParseBearerToken ¶
func (token AccessToken) ParseBearerToken() (string, error)
type BaseTool ¶ added in v1.4.0
type BaseTool[T ToolMeta] struct { Cfg T StaticParameters parameters.Parameters // contains filtered or unexported fields }
BaseTool provides default implementations of various methods on the Tool interface. Tools embed BaseTool to drop their boilerplate and override only methods that need custom behavior.
func NewBaseTool ¶ added in v1.4.0
func NewBaseTool[T ToolMeta](cfg T, annotations *ToolAnnotations, metadata Manifest, staticParameters parameters.Parameters) BaseTool[T]
NewBaseTool constructs a BaseTool from a resolved Config (typically the per-tool Config after Initialize has filled in defaults), the resolved annotations, the precomputed Manifest, and the tool's static parameters.
func (BaseTool[T]) Authorized ¶ added in v1.4.0
func (BaseTool[T]) EmbedParams ¶ added in v1.4.0
func (b BaseTool[T]) EmbedParams(ctx context.Context, paramValues parameters.ParamValues, pMgr PrimitiveManagerI) (parameters.ParamValues, error)
func (BaseTool[T]) GetAnnotations ¶ added in v1.4.0
func (b BaseTool[T]) GetAnnotations(_ sources.Source) *ToolAnnotations
func (BaseTool[T]) GetAuthRequired ¶ added in v1.4.0
func (BaseTool[T]) GetAuthTokenHeaderName ¶ added in v1.4.0
func (BaseTool[T]) GetDescription ¶ added in v1.4.0
func (BaseTool[T]) GetParameters ¶ added in v1.4.0
func (b BaseTool[T]) GetParameters(_ sources.Source) (parameters.Parameters, error)
func (BaseTool[T]) GetScopesRequired ¶ added in v1.4.0
func (BaseTool[T]) GetToolUIMetadata ¶ added in v1.11.0
func (b BaseTool[T]) GetToolUIMetadata() *ToolUIMetadata
func (BaseTool[T]) HasSecureParams ¶ added in v1.10.0
func (BaseTool[T]) Manifest ¶ added in v1.4.0
Manifest returns the precomputed metadata. It and GetParameters stay trivial and never call each other: embedded methods have no virtual dispatch, so a BaseTool method calling another would miss a concrete tool's override.
func (BaseTool[T]) RequiresClientAuthorization ¶ added in v1.4.0
func (BaseTool[T]) StaticManifest ¶ added in v1.5.0
StaticManifest returns the manifest baked at Initialize, with no source resolution. Dynamic tools override Manifest/GetParameters to refine params against a live source, but not this method, so it always reaches the baked skeleton — used for offline generation (e.g. skills) where no source exists.
type ConfigBase ¶ added in v1.4.0
type ConfigBase struct {
Name string `yaml:"name" validate:"required"`
Description string `yaml:"description"`
AuthRequired []string `yaml:"authRequired"`
ScopesRequired []string `yaml:"scopesRequired"`
UI *ToolUIMetadata `yaml:"ui,omitempty"`
}
ConfigBase owns the YAML fields that every tool's Config shares and that BaseTool reads through. Description is eagerly defaulted by the tool's Initialize (many prebuilt configs omit description: and rely on a canned per-tool string), so post-Initialize ConfigBase.Description holds the resolved value.
func (ConfigBase) GetAuthRequired ¶ added in v1.4.0
func (c ConfigBase) GetAuthRequired() []string
func (ConfigBase) GetDescription ¶ added in v1.4.0
func (c ConfigBase) GetDescription() string
func (ConfigBase) GetName ¶ added in v1.4.0
func (c ConfigBase) GetName() string
func (ConfigBase) GetScopesRequired ¶ added in v1.4.0
func (c ConfigBase) GetScopesRequired() []string
func (ConfigBase) GetToolUIMetadata ¶ added in v1.11.0
func (c ConfigBase) GetToolUIMetadata() *ToolUIMetadata
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod is a string of a valid HTTP method (e.g "GET")
func (*HTTPMethod) UnmarshalYAML ¶
func (i *HTTPMethod) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error
type Manifest ¶
type Manifest struct {
Description string `json:"description"`
Parameters []parameters.ParameterManifest `json:"parameters"`
AuthRequired []string `json:"authRequired"`
}
Manifest is the representation of tools sent to Client SDKs.
type PrimitiveManagerI ¶ added in v1.9.0
type PrimitiveManagerI interface {
GetSource(string) (sources.Source, bool)
GetEmbeddingModel(string) (embeddingmodels.EmbeddingModel, bool)
}
PrimitiveManagerI defines the minimal view of the primitives.PrimitiveManager that the Tool package needs. This is implemented to prevent import cycles.
type Tool ¶
type Tool interface {
GetName() string
GetSourceName() string
GetDescription() string
GetAuthRequired() []string
GetAnnotations(sources.Source) *ToolAnnotations
GetToolUIMetadata() *ToolUIMetadata
Invoke(context.Context, sources.Source, parameters.ParamValues, AccessToken) (any, util.ToolboxError)
EmbedParams(context.Context, parameters.ParamValues, PrimitiveManagerI) (parameters.ParamValues, error)
Manifest(sources.Source) (Manifest, error)
StaticManifest() Manifest
Authorized([]string) bool
RequiresClientAuthorization(sources.Source) (bool, error)
ToConfig() ToolConfig
GetAuthTokenHeaderName(sources.Source) (string, error)
GetParameters(sources.Source) (parameters.Parameters, error)
GetScopesRequired() []string
ValidateSource(sources.Source) error
HasSecureParams() bool
}
type ToolAnnotations ¶
type ToolAnnotations struct {
DestructiveHint *bool `json:"destructiveHint,omitempty" yaml:"destructiveHint,omitempty"`
IdempotentHint *bool `json:"idempotentHint,omitempty" yaml:"idempotentHint,omitempty"`
OpenWorldHint *bool `json:"openWorldHint,omitempty" yaml:"openWorldHint,omitempty"`
ReadOnlyHint *bool `json:"readOnlyHint,omitempty" yaml:"readOnlyHint,omitempty"`
}
https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations
func GetAnnotationsOrDefault ¶
func GetAnnotationsOrDefault(annotations *ToolAnnotations, defaultFn func() *ToolAnnotations) *ToolAnnotations
GetAnnotationsOrDefault returns the provided annotations if non-nil, otherwise returns the result of calling defaultFn.
func NewDestructiveAnnotations ¶
func NewDestructiveAnnotations() *ToolAnnotations
NewDestructiveAnnotations creates default annotations for a destructive tool. Use this for tools that create, update, or delete data.
func NewReadOnlyAnnotations ¶
func NewReadOnlyAnnotations() *ToolAnnotations
NewReadOnlyAnnotations creates default annotations for a read-only tool. Use this for tools that only query/fetch data without side effects.
func NewWriteAnnotations ¶ added in v1.4.0
func NewWriteAnnotations() *ToolAnnotations
NewWriteAnnotations creates default annotations for a non-destructive write tool: ReadOnlyHint is false, DestructiveHint is left unset.
type ToolConfig ¶
func DecodeConfig ¶
func DecodeConfig(ctx context.Context, resourceType string, name string, decoder *yaml.Decoder) (ToolConfig, error)
DecodeConfig looks up the registered factory for the given type and uses it to decode the tool configuration.
type ToolConfigFactory ¶
type ToolConfigFactory func(ctx context.Context, name string, decoder *yaml.Decoder) (ToolConfig, error)
ToolConfigFactory defines the signature for a function that creates and decodes a specific tool's configuration. It takes the context, the tool's name, and a YAML decoder to parse the config.
type ToolMeta ¶ added in v1.4.0
type ToolMeta interface {
GetName() string
GetDescription() string
GetAuthRequired() []string
GetScopesRequired() []string
GetToolUIMetadata() *ToolUIMetadata
}
ToolMeta is the read-only view BaseTool needs of any tool's Config. Tools satisfy it for free by embedding ConfigBase.
type ToolUIMetadata ¶ added in v1.11.0
type ToolUIMetadata struct {
Resource string `yaml:"resource" validate:"required"`
Visibility []ToolVisibility `yaml:"visibility,omitempty" validate:"omitempty,dive,oneof=model app"`
}
ToolUIMetadata defines the UI-specific metadata for a tool with UI Resource
type ToolVisibility ¶ added in v1.11.0
type ToolVisibility string
ToolVisibility defines the visibility of a tool in the UI.
const ( VisibilityModel ToolVisibility = "model" VisibilityApp ToolVisibility = "app" )
type Toolset ¶
type Toolset struct {
ToolsetConfig
Tools []*Tool `yaml:",inline"`
Manifest ToolsetManifest `yaml:",inline"`
// contains filtered or unexported fields
}
func (Toolset) BuildManifest ¶ added in v1.5.0
func (t Toolset) BuildManifest(pMgr PrimitiveManagerI) (ToolsetManifest, error)
BuildManifest resolves the manifest for every tool in the toolset against the provided sources, returning an error if any tool's manifest cannot be built.
func (Toolset) ContainsTool ¶ added in v1.3.0
ContainsTool reports whether the toolset includes a tool with the given name. When built via Initialize, lookups are O(1) via toolNameSet; for Toolsets constructed directly (e.g., in tests), falls back to a linear scan of ToolNames.
func (Toolset) ToConfig ¶
func (t Toolset) ToConfig() ToolsetConfig
type ToolsetConfig ¶
func (ToolsetConfig) Initialize ¶
type ToolsetManifest ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
alloydb
|
|
|
arcadedb
|
|
|
bigquery
|
|
|
bigtable
|
|
|
cassandra
|
|
|
clickhouse
|
|
|
cloudhealthcare
|
|
|
cloudloggingadmin
|
|
|
cloudsql
|
|
|
cloudsqlconnectgce
Package cloudsqlconnectgce provides a single tool that connects any Cloud SQL instance (PostgreSQL, MySQL, or SQL Server) to a Google Compute Engine VM.
|
Package cloudsqlconnectgce provides a single tool that connects any Cloud SQL instance (PostgreSQL, MySQL, or SQL Server) to a Google Compute Engine VM. |
|
cloudsqladmin
|
|
|
cloudsqlmssql
|
|
|
cloudsqlmysql
|
|
|
cloudsqlpg
|
|
|
cloudstorage
|
|
|
cloudstoragecommon
Package cloudstoragecommon holds helpers shared across the Cloud Storage tool implementations, chiefly error classification.
|
Package cloudstoragecommon holds helpers shared across the Cloud Storage tool implementations, chiefly error classification. |
|
cockroachdb
|
|
|
conversationalanalytics
|
|
|
databaseinsights
|
|
|
dataform
|
|
|
datalineage
|
|
|
dataplex
|
|
|
dataproc
|
|
|
elasticsearch
|
|
|
falkordb
|
|
|
falkordbschema
Package falkordbschema provides a tool that extracts the schema of a FalkorDB graph: node labels, relationship types, observed property shapes, indexes, constraints, and statistics.
|
Package falkordbschema provides a tool that extracts the schema of a FalkorDB graph: node labels, relationship types, observed property shapes, indexes, constraints, and statistics. |
|
falkordbschema/helpers
Package helpers provides utilities to turn raw FalkorDB query results into the schema structures defined by the types package.
|
Package helpers provides utilities to turn raw FalkorDB query results into the schema structures defined by the types package. |
|
falkordbschema/types
Package types defines the data structures used to represent a FalkorDB graph schema, as returned by the falkordb-schema tool.
|
Package types defines the data structures used to represent a FalkorDB graph schema, as returned by the falkordb-schema tool. |
|
firebird
|
|
|
firestore
|
|
|
firestoremongodb
|
|
|
looker
|
|
|
mindsdb
|
|
|
mongodb
|
|
|
mongodbcommon
Package mongodbcommon holds helpers shared across the MongoDB tools.
|
Package mongodbcommon holds helpers shared across the MongoDB tools. |
|
mssql
|
|
|
mysql
|
|
|
neo4j
|
|
|
neo4jexecutecypher/classifier
Package classifier provides tools to classify Cypher queries as either read-only or write operations.
|
Package classifier provides tools to classify Cypher queries as either read-only or write operations. |
|
neo4jschema/cache
Package cache provides a simple, thread-safe, in-memory key-value store.
|
Package cache provides a simple, thread-safe, in-memory key-value store. |
|
neo4jschema/helpers
Package helpers provides utility functions for transforming and processing Neo4j schema data.
|
Package helpers provides utility functions for transforming and processing Neo4j schema data. |
|
neo4jschema/types
Package types contains the shared data structures for Neo4j schema representation.
|
Package types contains the shared data structures for Neo4j schema representation. |
|
oceanbase
|
|
|
oracle
|
|
|
postgres
|
|
|
scylladb
|
|
|
serverlessspark
|
|
|
singlestore
|
|
|
snowflake
|
|
|
spanner
|
|
|
sqlite
|
|
|
tidb
|
|
|
trino
|
|
|
utility
|
|