tools

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCompatibleSource added in v0.25.0

func GetCompatibleSource[T any](resourceMgr SourceProvider, sourceName, toolName, toolKind string) (T, error)

func IsAuthorized added in v0.0.4

func IsAuthorized(authRequiredSources []string, verifiedAuthServices []string) bool

Helper function that returns if a tool invocation request is authorized

func IsValidName

func IsValidName(s string) bool

func Register added in v0.7.0

func Register(kind 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 'kind' 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 kind was already registered.

Types

type AccessToken added in v0.13.0

type AccessToken string

func (AccessToken) ParseBearerToken added in v0.15.0

func (token AccessToken) ParseBearerToken() (string, error)

type HTTPMethod added in v0.3.0

type HTTPMethod string

HTTPMethod is a string of a valid HTTP method (e.g "GET")

func (*HTTPMethod) UnmarshalYAML added in v0.3.0

func (i *HTTPMethod) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error

type Manifest added in v0.0.2

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 McpManifest added in v0.3.0

type McpManifest struct {
	// The name of the tool.
	Name string `json:"name"`
	// A human-readable description of the tool.
	Description string           `json:"description,omitempty"`
	Annotations *ToolAnnotations `json:"annotations,omitempty"`
	// A JSON Schema object defining the expected parameters for the tool.
	InputSchema parameters.McpToolsSchema `json:"inputSchema,omitempty"`
	Metadata    map[string]any            `json:"_meta,omitempty"`
}

Definition for a tool the MCP client can call.

func GetMcpManifest added in v0.17.0

func GetMcpManifest(name, desc string, authInvoke []string, params parameters.Parameters, annotations *ToolAnnotations) McpManifest

type SourceProvider added in v0.22.0

type SourceProvider interface {
	GetSource(sourceName string) (sources.Source, bool)
}

SourceProvider defines the minimal view of the server.ResourceManager that the Tool package needs. This is implemented to prevent import cycles.

type Tool

type Tool interface {
	Invoke(context.Context, SourceProvider, parameters.ParamValues, AccessToken) (any, error)
	ParseParams(map[string]any, map[string]map[string]any) (parameters.ParamValues, error)
	EmbedParams(context.Context, parameters.ParamValues, map[string]embeddingmodels.EmbeddingModel) (parameters.ParamValues, error)
	Manifest() Manifest
	McpManifest() McpManifest
	Authorized([]string) bool
	RequiresClientAuthorization(SourceProvider) (bool, error)
	ToConfig() ToolConfig
	GetAuthTokenHeaderName(SourceProvider) (string, error)
}

type ToolAnnotations added in v0.22.0

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

type ToolConfig added in v0.0.2

type ToolConfig interface {
	ToolConfigKind() string
	Initialize(map[string]sources.Source) (Tool, error)
}

func DecodeConfig added in v0.7.0

func DecodeConfig(ctx context.Context, kind string, name string, decoder *yaml.Decoder) (ToolConfig, error)

DecodeConfig looks up the registered factory for the given kind and uses it to decode the tool configuration.

type ToolConfigFactory added in v0.7.0

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 Toolset

type Toolset struct {
	ToolsetConfig
	Tools       []*Tool         `yaml:",inline"`
	Manifest    ToolsetManifest `yaml:",inline"`
	McpManifest []McpManifest   `yaml:",inline"`
}

func (Toolset) ToConfig added in v0.20.0

func (t Toolset) ToConfig() ToolsetConfig

type ToolsetConfig

type ToolsetConfig struct {
	Name      string   `yaml:"name"`
	ToolNames []string `yaml:",inline"`
}

func (ToolsetConfig) Initialize

func (t ToolsetConfig) Initialize(serverVersion string, toolsMap map[string]Tool) (Toolset, error)

type ToolsetManifest

type ToolsetManifest struct {
	ServerVersion string              `json:"serverVersion"`
	ToolsManifest map[string]Manifest `json:"tools"`
}

Directories

Path Synopsis
alloydb
bigquery
cassandra
clickhouse
cloudhealthcare
cloudsql
cloudsqlmssql
cloudsqlmysql
cloudsqlpg
dataform
dataplex
elasticsearch
firebird
firestore
looker
mindsdb
mongodb
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
serverlessspark
singlestore
snowflake
spanner
sqlite
tidb
trino
utility

Jump to

Keyboard shortcuts

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