invocation

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	JsonSchemaTypeObject  = "object"
	JsonSchemaTypeNumber  = "number"
	JsonSchemaTypeInteger = "integer"
	JsonSchemaTypeString  = "string"
	JsonSchemaTypeArray   = "array"
	JsonSchemaTypeBoolean = "boolean"
	JsonSchemaTypeNull    = "null"
)

Variables

This section is empty.

Functions

func InvocationValidator

func InvocationValidator(primitive Primitive) error

func RegisterFactory

func RegisterFactory(invocationType string, factory InvokerFactory)

Types

type Builder

type Builder interface {
	// SetField provides the builder with the parsed value, as well as the json dot separated path where the value comes from
	SetField(path string, value any)

	// GetResult returns the final builder resulting object
	GetResult() (any, error)
}

Builder is an interface used to build any objects needed to invoke a tool as the request JSON is parsed. This avoids extra allocations/passes through the parsed map[string]any, which possibly contains nested maps

type ConfigMetadata added in v0.1.1

type ConfigMetadata interface {
	NewConfig() InvocationConfig
}

type DynamicJson

type DynamicJson struct {
	Builders []Builder
}

func (*DynamicJson) ParseJson

func (dj *DynamicJson) ParseJson(data []byte, schema *jsonschema.Schema) (map[string]any, error)

type InvocationConfig

type InvocationConfig interface {
	Validate() error
	DeepCopy() InvocationConfig
}

type InvocationConfigWrapper added in v0.1.1

type InvocationConfigWrapper struct {
	Type   string           `json:"-"`
	Config InvocationConfig `json:"-"`
}

InvocationConfigWrapper wraps an invocation configuration with its type. In JSON, this is represented as an object with a single key indicating the type (one of "http", "cli", or "extends") and the value being the configuration. Example: {"http": {...}} or {"cli": {...}} or {"extends": {...}}

func (InvocationConfigWrapper) GetConfig added in v0.1.1

func (InvocationConfigWrapper) GetType added in v0.1.1

func (w InvocationConfigWrapper) GetType() string

func (InvocationConfigWrapper) JSONSchema added in v0.1.1

JSONSchema provides a custom JSON Schema for InvocationConfigWrapper. This defines it as a oneOf discriminated union where exactly one invocation type key must be present.

func (InvocationConfigWrapper) MarshalJSON added in v0.1.1

func (w InvocationConfigWrapper) MarshalJSON() ([]byte, error)

func (*InvocationConfigWrapper) UnmarshalJSON added in v0.1.1

func (w *InvocationConfigWrapper) UnmarshalJSON(data []byte) error

type Invoker

type Invoker interface {
	Invoke(ctx context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error)
	InvokePrompt(ctx context.Context, req *mcp.GetPromptRequest) (*mcp.GetPromptResult, error)
	InvokeResource(ctx context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)
	InvokeResourceTemplate(ctx context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)
}

func CreateInvoker

func CreateInvoker(primitive Primitive) (Invoker, error)

func CreatePromptInvoker

func CreatePromptInvoker(primitive Primitive) (Invoker, error)

func CreateResourceInvoker

func CreateResourceInvoker(primitive Primitive) (Invoker, error)

func CreateResourceTemplateInvoker

func CreateResourceTemplateInvoker(primitive Primitive) (Invoker, error)

type InvokerFactory

type InvokerFactory interface {
	NewConfig() InvocationConfig
	CreateInvoker(config InvocationConfig, primitive Primitive) (Invoker, error)
}

func GetFactory added in v0.1.1

func GetFactory(invocationType string) (InvokerFactory, bool)

type Primitive added in v0.1.1

type Primitive interface {
	GetName() string
	GetDescription() string
	GetInputSchema() *jsonschema.Schema
	GetOutputSchema() *jsonschema.Schema
	GetInvocationConfig() InvocationConfig
	GetInvocationType() string
	GetRequiredScopes() []string
	GetResolvedInputSchema() *jsonschema.Resolved
	GetURITemplate() string
	PrimitiveType() string
}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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