Documentation
¶
Overview ¶
Package toolmodel provides a single, canonical data model for tools in the system, based on the MCP Tool specification (2025-11-25). Target protocol version: MCPVersion.
This package is the only place that defines what a "tool" is (fields, constraints, IDs), and all downstream modules depend on it for tool definitions. It provides:
- Tool and ToolIcon types matching the MCP Tool specification
- Namespace and Version extensions for stable tool identification
- Backend binding types (MCP, Provider, Local) for execution metadata
- Optional tool Tags for search/discovery layers
- JSON Schema validation helpers for inputs and outputs
- JSON serialization compatible with the MCP Tool spec
- Tag normalization helpers for discovery layers
The package enforces MCP schema rules by default:
- inputSchema MUST be a valid JSON Schema object
- Schemas may be provided as map[string]any, json.RawMessage, or []byte
- JSON Schema 2020-12 is assumed when no $schema is present
- External $ref resolution is disabled to prevent network access
This package has no networking or JSON-RPC dependencies and is safe to embed in public APIs.
Tool name validation mirrors MCP rules: 1-128 chars, [A-Za-z0-9_.-] only.
Example (BackendBinding) ¶
Example_backendBinding demonstrates creating backend binding information.
package main
import (
"fmt"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
// MCP backend (tool from an MCP server)
mcpBackend := model.ToolBackend{
Kind: model.BackendKindMCP,
MCP: &model.MCPBackend{
ServerName: "filesystem-server",
},
}
fmt.Printf("MCP Backend: kind=%s, server=%s\n", mcpBackend.Kind, mcpBackend.MCP.ServerName)
// Provider backend (external tool provider)
providerBackend := model.ToolBackend{
Kind: model.BackendKindProvider,
Provider: &model.ProviderBackend{
ProviderID: "openai",
ToolID: "gpt-4-vision",
},
}
fmt.Printf("Provider Backend: kind=%s, provider=%s, tool=%s\n",
providerBackend.Kind, providerBackend.Provider.ProviderID, providerBackend.Provider.ToolID)
// Local backend (locally implemented tool)
localBackend := model.ToolBackend{
Kind: model.BackendKindLocal,
Local: &model.LocalBackend{
Name: "custom-handler",
},
}
fmt.Printf("Local Backend: kind=%s, name=%s\n", localBackend.Kind, localBackend.Local.Name)
}
Output: MCP Backend: kind=mcp, server=filesystem-server Provider Backend: kind=provider, provider=openai, tool=gpt-4-vision Local Backend: kind=local, name=custom-handler
Example (CreateTool) ¶
Example_createTool demonstrates creating a Tool with the toolmodel library.
package main
import (
"fmt"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
// Create a tool that embeds the MCP Tool type
tool := model.Tool{
Tool: mcp.Tool{
Name: "search",
Description: "Search for documents by query",
InputSchema: map[string]any{
"type": "object",
"properties": map[string]any{
"query": map[string]any{
"type": "string",
"description": "The search query",
},
"limit": map[string]any{
"type": "integer",
"description": "Maximum number of results",
"default": 10,
},
},
"required": []any{"query"},
},
},
Namespace: "docs",
Version: "1.0.0",
}
fmt.Printf("Tool ID: %s\n", tool.ToolID())
fmt.Printf("Name: %s\n", tool.Name)
fmt.Printf("Description: %s\n", tool.Description)
}
Output: Tool ID: docs:search:1.0.0 Name: search Description: Search for documents by query
Example (FromMCPJSON) ¶
Example_fromMCPJSON demonstrates deserializing an MCP Tool from JSON.
package main
import (
"fmt"
"log"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
mcpJSON := `{
"name": "calculate",
"description": "Perform calculations",
"inputSchema": {
"type": "object",
"properties": {
"expression": {"type": "string"}
},
"required": ["expression"]
}
}`
tool, err := model.FromMCPJSON([]byte(mcpJSON))
if err != nil {
log.Fatal(err)
}
fmt.Printf("Name: %s\n", tool.Name)
fmt.Printf("Namespace: %q (empty from MCP JSON)\n", tool.Namespace)
}
Output: Name: calculate Namespace: "" (empty from MCP JSON)
Example (NoParametersTool) ¶
Example_noParametersTool demonstrates creating a tool with no parameters.
package main
import (
"fmt"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
// MCP recommended schema for tools with no parameters
tool := model.Tool{
Tool: mcp.Tool{
Name: "get_time",
Description: "Get the current time",
InputSchema: map[string]any{
"type": "object",
"additionalProperties": false,
},
},
}
validator := model.NewDefaultValidator()
// Empty object is valid
err := validator.ValidateInput(&tool, map[string]any{})
fmt.Printf("Empty object: valid=%v\n", err == nil)
// Extra properties are rejected
err = validator.ValidateInput(&tool, map[string]any{"unexpected": "value"})
fmt.Printf("Extra properties: rejected=%v\n", err != nil)
}
Output: Empty object: valid=true Extra properties: rejected=true
Example (ParseToolID) ¶
Example_parseToolID demonstrates parsing a tool ID into its components.
package main
import (
"fmt"
"log"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
// Parse a namespaced tool ID
namespace, name, err := model.ParseToolID("filesystem:read")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Namespace: %q, Name: %q\n", namespace, name)
// Parse a versioned tool ID
namespace, name, err = model.ParseToolID("filesystem:read:1.2.3")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Namespace: %q, Name: %q\n", namespace, name)
// Parse a simple tool ID (no namespace)
namespace, name, err = model.ParseToolID("echo")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Namespace: %q, Name: %q\n", namespace, name)
}
Output: Namespace: "filesystem", Name: "read" Namespace: "filesystem", Name: "read:1.2.3" Namespace: "", Name: "echo"
Example (ToolJSON) ¶
Example_toolJSON demonstrates JSON serialization of tools.
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
tool := model.Tool{
Tool: mcp.Tool{
Name: "greet",
Description: "Greet a user",
InputSchema: map[string]any{
"type": "object",
"properties": map[string]any{
"name": map[string]any{"type": "string"},
},
},
},
Namespace: "example",
Version: "2.0.0",
}
// ToMCPJSON strips toolmodel extensions (namespace, version)
mcpJSON, _ := tool.ToMCPJSON()
fmt.Println("MCP JSON (no namespace/version):")
var mcpResult map[string]any
if err := json.Unmarshal(mcpJSON, &mcpResult); err != nil {
log.Fatal(err)
}
_, hasNamespace := mcpResult["namespace"]
fmt.Printf(" Has namespace: %v\n", hasNamespace)
// ToJSON includes all fields
fullJSON, _ := tool.ToJSON()
fmt.Println("Full JSON (with namespace/version):")
var fullResult map[string]any
if err := json.Unmarshal(fullJSON, &fullResult); err != nil {
log.Fatal(err)
}
fmt.Printf(" namespace: %v\n", fullResult["namespace"])
fmt.Printf(" version: %v\n", fullResult["version"])
}
Output: MCP JSON (no namespace/version): Has namespace: false Full JSON (with namespace/version): namespace: example version: 2.0.0
Example (ValidateInput) ¶
Example_validateInput demonstrates validating tool input with SchemaValidator.
package main
import (
"fmt"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
tool := model.Tool{
Tool: mcp.Tool{
Name: "send_email",
Description: "Send an email",
InputSchema: map[string]any{
"type": "object",
"properties": map[string]any{
"to": map[string]any{"type": "string"},
"subject": map[string]any{"type": "string"},
"body": map[string]any{"type": "string"},
},
"required": []any{"to", "subject"},
},
},
}
validator := model.NewDefaultValidator()
// Valid input
validArgs := map[string]any{
"to": "user@example.com",
"subject": "Hello",
"body": "Hi there!",
}
err := validator.ValidateInput(&tool, validArgs)
fmt.Printf("Valid input: error=%v\n", err)
// Invalid input (missing required field)
invalidArgs := map[string]any{
"body": "Hi there!",
}
err = validator.ValidateInput(&tool, invalidArgs)
fmt.Printf("Invalid input: error=%v\n", err != nil)
}
Output: Valid input: error=<nil> Invalid input: error=true
Example (ValidateSchema) ¶
Example_validateSchema demonstrates direct schema validation.
package main
import (
"fmt"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
schema := map[string]any{
"type": "object",
"properties": map[string]any{
"name": map[string]any{"type": "string"},
"age": map[string]any{"type": "integer", "minimum": 0},
},
"required": []any{"name"},
}
validator := model.NewDefaultValidator()
// Valid instance
valid := map[string]any{"name": "Alice", "age": 30}
err := validator.Validate(schema, valid)
fmt.Printf("Valid: %v\n", err == nil)
// Invalid instance (wrong type)
invalid := map[string]any{"name": 123}
err = validator.Validate(schema, invalid)
fmt.Printf("Invalid type: %v\n", err != nil)
// Invalid instance (missing required)
missing := map[string]any{"age": 25}
err = validator.Validate(schema, missing)
fmt.Printf("Missing required: %v\n", err != nil)
}
Output: Valid: true Invalid type: true Missing required: true
Index ¶
- Constants
- Variables
- func NormalizeTags(tags []string) []string
- func ParseToolID(id string) (namespace, name string, err error)
- func ParseToolIDWithVersion(id string) (namespace, name, version string, err error)
- type BackendKind
- type DefaultValidator
- type LocalBackend
- type MCPBackend
- type ProviderBackend
- type SchemaValidator
- type Tool
- type ToolBackend
- type ToolBuilder
- func (b *ToolBuilder) Annotations(annotations *mcp.ToolAnnotations) *ToolBuilder
- func (b *ToolBuilder) Build() (*Tool, error)
- func (b *ToolBuilder) Description(desc string) *ToolBuilder
- func (b *ToolBuilder) Destructive() *ToolBuilder
- func (b *ToolBuilder) Icons(icons ...mcp.Icon) *ToolBuilder
- func (b *ToolBuilder) Idempotent() *ToolBuilder
- func (b *ToolBuilder) InputSchema(schema map[string]any) *ToolBuilder
- func (b *ToolBuilder) Meta(meta mcp.Meta) *ToolBuilder
- func (b *ToolBuilder) MustBuild() *Tool
- func (b *ToolBuilder) Namespace(ns string) *ToolBuilder
- func (b *ToolBuilder) NonDestructive() *ToolBuilder
- func (b *ToolBuilder) OpenWorld() *ToolBuilder
- func (b *ToolBuilder) OutputSchema(schema map[string]any) *ToolBuilder
- func (b *ToolBuilder) ReadOnly() *ToolBuilder
- func (b *ToolBuilder) Tags(tags ...string) *ToolBuilder
- func (b *ToolBuilder) Title(title string) *ToolBuilder
- func (b *ToolBuilder) Version(v string) *ToolBuilder
- type ToolIcon
Examples ¶
- Package (BackendBinding)
- Package (CreateTool)
- Package (FromMCPJSON)
- Package (NoParametersTool)
- Package (ParseToolID)
- Package (ToolJSON)
- Package (ValidateInput)
- Package (ValidateSchema)
- NewDefaultValidator
- NewLocalBackend
- NewMCPBackend
- NewProviderBackend
- NormalizeTags
- ParseToolID
- Tool
- Tool.Clone
- Tool.Validate
Constants ¶
const ( SchemaDialect202012 = "https://json-schema.org/draft/2020-12/schema" SchemaDialectDraft07 = "http://json-schema.org/draft-07/schema#" SchemaDialectDraft07Alt = "http://json-schema.org/draft-07/schema" )
Supported JSON Schema dialects.
const MCPVersion = "2025-11-25"
MCPVersion is the MCP protocol version this package targets. Keep in sync with the latest MCP spec.
Variables ¶
var ( // ErrUnsupportedSchema is returned when the $schema dialect is not supported. ErrUnsupportedSchema = errors.New("unsupported JSON Schema dialect") // ErrExternalRef is returned when an external $ref is encountered. ErrExternalRef = errors.New("external $ref resolution is disabled") // ErrInvalidSchema is returned when a schema is not a valid JSON Schema object. ErrInvalidSchema = errors.New("invalid JSON Schema") )
Common validation errors.
var ErrInvalidBackend = errors.New("invalid backend")
var ErrInvalidTool = errors.New("invalid tool")
var ErrInvalidToolID = errors.New("invalid tool ID format")
ErrInvalidToolID is returned when a tool ID string is malformed.
Functions ¶
func NormalizeTags ¶
NormalizeTags normalizes a list of tags for indexing/search. Rules: - lowercase - trim whitespace - replace internal whitespace with '-' - allow only [a-z0-9-_.] - dedupe while preserving order - drop empty/invalid tags - max tag length: 64 chars - max tag count: 20
Example ¶
package main
import (
"fmt"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
tags := []string{
" Machine Learning ",
"AI",
"machine-learning", // duplicate after normalization
"Data Science!",
}
normalized := model.NormalizeTags(tags)
fmt.Println(normalized)
}
Output: [machine-learning ai data-science]
func ParseToolID ¶
ParseToolID parses a tool ID string into namespace and name components. The format is "namespace:name:version", "namespace:name", or just "name". Returns an error if the ID is empty or contains more than two colons. When a version segment is present, the returned name includes ":version".
Example ¶
package main
import (
"fmt"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
// With namespace
ns, name, _ := model.ParseToolID("github:list_repos")
fmt.Printf("Namespace: %q, Name: %q\n", ns, name)
// With namespace and version
ns, name, _ = model.ParseToolID("github:list_repos:1.0.0")
fmt.Printf("Namespace: %q, Name: %q\n", ns, name)
// Without namespace
ns, name, _ = model.ParseToolID("simple_tool")
fmt.Printf("Namespace: %q, Name: %q\n", ns, name)
}
Output: Namespace: "github", Name: "list_repos" Namespace: "github", Name: "list_repos:1.0.0" Namespace: "", Name: "simple_tool"
func ParseToolIDWithVersion ¶ added in v0.3.0
ParseToolIDWithVersion parses a tool ID string into namespace, name, and version. The format is "namespace:name:version", "namespace:name", or just "name". Returns an error if the ID is empty or contains more than two colons.
Types ¶
type BackendKind ¶
type BackendKind string
BackendKind defines the type of backend backing a tool.
const ( BackendKindMCP BackendKind = "mcp" BackendKindProvider BackendKind = "provider" BackendKindLocal BackendKind = "local" )
type DefaultValidator ¶
type DefaultValidator struct{}
DefaultValidator is the default SchemaValidator implementation using jsonschema-go. It supports JSON Schema 2020-12 (default) and draft-07. External $ref resolution is disabled to prevent network access.
Limitations (from jsonschema-go):
- The "format" keyword is not validated by default (treated as annotation)
- Content-related keywords (contentEncoding, contentMediaType) are not validated
func NewDefaultValidator ¶
func NewDefaultValidator() *DefaultValidator
NewDefaultValidator creates a new DefaultValidator.
Example ¶
package main
import (
"fmt"
"log"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
validator := model.NewDefaultValidator()
schema := map[string]any{
"type": "object",
"properties": map[string]any{
"name": map[string]any{"type": "string"},
"age": map[string]any{"type": "integer", "minimum": 0},
},
"required": []string{"name"},
}
// Valid input
err := validator.Validate(schema, map[string]any{
"name": "Alice",
"age": 30,
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Valid input accepted")
// Invalid input (missing required field)
err = validator.Validate(schema, map[string]any{
"age": 25,
})
if err != nil {
fmt.Println("Invalid input rejected")
}
}
Output: Valid input accepted Invalid input rejected
func (*DefaultValidator) Validate ¶
func (v *DefaultValidator) Validate(schema any, instance any) error
Validate validates an instance against a JSON Schema.
func (*DefaultValidator) ValidateInput ¶
func (v *DefaultValidator) ValidateInput(tool *Tool, args any) error
ValidateInput validates tool input arguments against the tool's InputSchema.
func (*DefaultValidator) ValidateOutput ¶
func (v *DefaultValidator) ValidateOutput(tool *Tool, result any) error
ValidateOutput validates tool output against the tool's OutputSchema if present. Returns nil if OutputSchema is not defined.
type LocalBackend ¶
type LocalBackend struct {
// Name identifies the local function or handler.
Name string `json:"name"`
}
LocalBackend defines metadata for a locally executed tool.
type MCPBackend ¶
type MCPBackend struct {
// ServerName identifies the MCP server (e.g. in a registry or config).
ServerName string `json:"serverName,omitempty"`
}
MCPBackend defines metadata for an MCP server backend.
type ProviderBackend ¶
ProviderBackend defines metadata for an external/manual tool provider.
type SchemaValidator ¶
type SchemaValidator interface {
// Validate validates an instance against a JSON Schema.
// The schema must be a valid JSON Schema object (map[string]any or *jsonschema.Schema).
// The instance is the data to validate.
// Returns nil if validation passes, otherwise returns a validation error.
Validate(schema any, instance any) error
// ValidateInput validates tool input arguments against a tool's InputSchema.
// Convenience method that extracts InputSchema from Tool.
ValidateInput(tool *Tool, args any) error
// ValidateOutput validates tool output against a tool's OutputSchema if present.
// Returns nil if OutputSchema is not defined.
ValidateOutput(tool *Tool, result any) error
}
SchemaValidator validates JSON instances against JSON Schemas.
Contract:
- Thread-safety: implementations must be safe for concurrent use unless documented otherwise.
- Ownership: implementations must not mutate caller-owned schema objects or instances.
- Errors: validation failures should wrap/return ErrInvalidSchema or ErrUnsupportedSchema where appropriate.
- ValidateInput: must validate against tool.InputSchema; return ErrInvalidSchema if tool is nil or InputSchema is nil.
- ValidateOutput: must validate against tool.OutputSchema when present; return nil when OutputSchema is nil.
- Determinism: repeated calls with same inputs should be deterministic.
Implementations can be swapped to use different validation libraries.
type Tool ¶
type Tool struct {
mcp.Tool
// Namespace provides a way to namespace tools, e.g. for stable IDs.
Namespace string `json:"namespace,omitempty"`
// Version is an optional version string for the tool.
Version string `json:"version,omitempty"`
// Tags is an optional set of search keywords for discovery layers (e.g. toolindex).
Tags []string `json:"tags,omitempty"`
}
Tool mirrors the MCP Tool definition and adds Namespace and Version. It embeds mcp.Tool to ensure compatibility with the official SDK.
Example ¶
package main
import (
"fmt"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
tool := model.Tool{
Namespace: "files",
Tool: mcp.Tool{
Name: "read_file",
Description: "Read contents of a file",
InputSchema: map[string]any{
"type": "object",
"properties": map[string]any{
"path": map[string]any{
"type": "string",
"description": "Path to the file",
},
},
"required": []string{"path"},
},
},
Version: "1.0.0",
Tags: []string{"files", "io"},
}
fmt.Println("Tool ID:", tool.ToolID())
fmt.Println("Name:", tool.Name)
}
Output: Tool ID: files:read_file:1.0.0 Name: read_file
func FromJSON ¶
FromJSON deserializes a full Tool JSON (including toolmodel extensions) into a Tool struct.
func FromMCPJSON ¶
FromMCPJSON deserializes an MCP Tool JSON into a Tool struct. The Namespace and Version fields will be empty after this call.
func (*Tool) Clone ¶ added in v0.2.0
Clone creates a deep copy of the Tool. The returned Tool is independent of the original.
Example ¶
package main
import (
"fmt"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
original := &model.Tool{
Namespace: "demo",
Tool: mcp.Tool{
Name: "original_tool",
Description: "Original description",
InputSchema: map[string]any{"type": "object"},
},
Version: "1.0.0",
}
clone := original.Clone()
clone.Name = "cloned_tool"
clone.Version = "2.0.0"
fmt.Println("Original:", original.Name, original.Version)
fmt.Println("Clone:", clone.Name, clone.Version)
}
Output: Original: original_tool 1.0.0 Clone: cloned_tool 2.0.0
func (*Tool) ParsedVersion ¶ added in v0.2.0
ParsedVersion returns the Tool's version as a structured version.Version. Returns an error if the version string is empty or cannot be parsed.
func (*Tool) ToMCPJSON ¶
ToMCPJSON serializes the Tool to JSON that is compatible with the MCP Tool spec. This strips toolmodel-specific fields (Namespace, Version) and returns only the standard MCP Tool fields.
func (*Tool) ToolID ¶
ToolID returns the canonical identifier for a tool. Format: "namespace:name:version" when namespace+version are present, "namespace:name" when namespace is present without version, otherwise just "name".
func (*Tool) Validate ¶
Validate checks basic invariants of Tool required by toolmodel consumers. It does not validate JSON schemas; use SchemaValidator for that.
Example ¶
package main
import (
"fmt"
"log"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
tool := model.Tool{
Tool: mcp.Tool{
Name: "my_tool",
Description: "A valid tool",
InputSchema: map[string]any{
"type": "object",
},
},
}
if err := tool.Validate(); err != nil {
log.Fatal(err)
}
fmt.Println("Tool is valid")
}
Output: Tool is valid
type ToolBackend ¶
type ToolBackend struct {
Kind BackendKind `json:"kind"`
MCP *MCPBackend `json:"mcp,omitempty"`
Provider *ProviderBackend `json:"provider,omitempty"`
Local *LocalBackend `json:"local,omitempty"`
}
ToolBackend defines the binding information for a tool's execution. A tool can have multiple backends, but typically one active one.
func NewLocalBackend ¶ added in v0.2.0
func NewLocalBackend(name string) ToolBackend
NewLocalBackend creates a ToolBackend for local execution.
Example ¶
package main
import (
"fmt"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
backend := model.NewLocalBackend("search-handler")
fmt.Println("Kind:", backend.Kind)
fmt.Println("Handler:", backend.Local.Name)
}
Output: Kind: local Handler: search-handler
func NewMCPBackend ¶ added in v0.2.0
func NewMCPBackend(serverName string) ToolBackend
NewMCPBackend creates a ToolBackend for an MCP server.
Example ¶
package main
import (
"fmt"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
backend := model.NewMCPBackend("my-mcp-server")
fmt.Println("Kind:", backend.Kind)
fmt.Println("Server:", backend.MCP.ServerName)
}
Output: Kind: mcp Server: my-mcp-server
func NewProviderBackend ¶ added in v0.2.0
func NewProviderBackend(providerID, toolID string) ToolBackend
NewProviderBackend creates a ToolBackend for an external provider.
Example ¶
package main
import (
"fmt"
"github.com/jonwraymond/toolfoundation/model"
)
func main() {
backend := model.NewProviderBackend("openai", "gpt-4-turbo")
fmt.Println("Kind:", backend.Kind)
fmt.Println("Provider:", backend.Provider.ProviderID)
fmt.Println("Tool:", backend.Provider.ToolID)
}
Output: Kind: provider Provider: openai Tool: gpt-4-turbo
func (ToolBackend) Validate ¶
func (b ToolBackend) Validate() error
Validate checks basic invariants of ToolBackend.
type ToolBuilder ¶ added in v0.2.0
type ToolBuilder struct {
// contains filtered or unexported fields
}
ToolBuilder provides a fluent API for constructing Tool instances. Use NewTool to create a builder, chain methods, and call Build() or MustBuild().
func NewTool ¶ added in v0.2.0
func NewTool(name string) *ToolBuilder
NewTool creates a new ToolBuilder with the given tool name. The name is required and must follow tool naming conventions.
func (*ToolBuilder) Annotations ¶ added in v0.2.0
func (b *ToolBuilder) Annotations(annotations *mcp.ToolAnnotations) *ToolBuilder
Annotations sets the tool's MCP annotations.
func (*ToolBuilder) Build ¶ added in v0.2.0
func (b *ToolBuilder) Build() (*Tool, error)
Build validates and returns the constructed Tool. Returns an error if validation fails.
func (*ToolBuilder) Description ¶ added in v0.2.0
func (b *ToolBuilder) Description(desc string) *ToolBuilder
Description sets the tool's description.
func (*ToolBuilder) Destructive ¶ added in v0.2.0
func (b *ToolBuilder) Destructive() *ToolBuilder
Destructive marks the tool as destructive via annotations.
func (*ToolBuilder) Icons ¶ added in v0.2.0
func (b *ToolBuilder) Icons(icons ...mcp.Icon) *ToolBuilder
Icons sets the tool's icons for display.
func (*ToolBuilder) Idempotent ¶ added in v0.2.0
func (b *ToolBuilder) Idempotent() *ToolBuilder
Idempotent marks the tool as idempotent via annotations.
func (*ToolBuilder) InputSchema ¶ added in v0.2.0
func (b *ToolBuilder) InputSchema(schema map[string]any) *ToolBuilder
InputSchema sets the tool's input schema. The schema should be a JSON Schema compliant map.
func (*ToolBuilder) Meta ¶ added in v0.2.0
func (b *ToolBuilder) Meta(meta mcp.Meta) *ToolBuilder
Meta sets the tool's metadata.
func (*ToolBuilder) MustBuild ¶ added in v0.2.0
func (b *ToolBuilder) MustBuild() *Tool
MustBuild validates and returns the constructed Tool, panicking on error. Use only in tests or when the builder configuration is known to be valid.
func (*ToolBuilder) Namespace ¶ added in v0.2.0
func (b *ToolBuilder) Namespace(ns string) *ToolBuilder
Namespace sets the tool's namespace for scoped identification.
func (*ToolBuilder) NonDestructive ¶ added in v0.2.0
func (b *ToolBuilder) NonDestructive() *ToolBuilder
NonDestructive explicitly marks the tool as non-destructive via annotations.
func (*ToolBuilder) OpenWorld ¶ added in v0.2.0
func (b *ToolBuilder) OpenWorld() *ToolBuilder
OpenWorld marks the tool as potentially interacting with external world.
func (*ToolBuilder) OutputSchema ¶ added in v0.2.0
func (b *ToolBuilder) OutputSchema(schema map[string]any) *ToolBuilder
OutputSchema sets the tool's output schema. The schema should be a JSON Schema compliant map.
func (*ToolBuilder) ReadOnly ¶ added in v0.2.0
func (b *ToolBuilder) ReadOnly() *ToolBuilder
ReadOnly marks the tool as read-only via annotations.
func (*ToolBuilder) Tags ¶ added in v0.2.0
func (b *ToolBuilder) Tags(tags ...string) *ToolBuilder
Tags sets the tool's discovery tags. Tags are normalized during Build().
func (*ToolBuilder) Title ¶ added in v0.2.0
func (b *ToolBuilder) Title(title string) *ToolBuilder
Title sets the tool's display title.
func (*ToolBuilder) Version ¶ added in v0.2.0
func (b *ToolBuilder) Version(v string) *ToolBuilder
Version sets the tool's version string.