invocation

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 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(invocationType string, data json.RawMessage, primitive mcpfile.Primitive) error

func RegisterFactory

func RegisterFactory(invocationType string, factory InvokerFactory)

func RegisterParser

func RegisterParser(invocationType string, parser InvocationConfigParser)

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 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
}

func ParseInvocation

func ParseInvocation(invocationType string, data json.RawMessage, tool *mcpfile.Tool) (InvocationConfig, error)

func ParsePromptInvocation

func ParsePromptInvocation(invocationType string, data json.RawMessage, prompt *mcpfile.Prompt) (InvocationConfig, error)

func ParseResourceInvocation

func ParseResourceInvocation(invocationType string, data json.RawMessage, resource *mcpfile.Resource) (InvocationConfig, error)

func ParseResourceTemplateInvocation

func ParseResourceTemplateInvocation(invocationType string, data json.RawMessage, resourceTemplate *mcpfile.ResourceTemplate) (InvocationConfig, error)

type InvocationConfigParser

type InvocationConfigParser interface {
	Parse(data json.RawMessage, tool *mcpfile.Tool) (InvocationConfig, error)
	ParsePrompt(data json.RawMessage, prompt *mcpfile.Prompt) (InvocationConfig, error)
	ParseResource(data json.RawMessage, resource *mcpfile.Resource) (InvocationConfig, error)
	ParseResourceTemplate(data json.RawMessage, resourceTemplate *mcpfile.ResourceTemplate) (InvocationConfig, 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(tool *mcpfile.Tool) (Invoker, error)

func CreatePromptInvoker

func CreatePromptInvoker(prompt *mcpfile.Prompt) (Invoker, error)

func CreateResourceInvoker

func CreateResourceInvoker(resource *mcpfile.Resource) (Invoker, error)

func CreateResourceTemplateInvoker

func CreateResourceTemplateInvoker(resourceTemplate *mcpfile.ResourceTemplate) (Invoker, error)

type InvokerFactory

type InvokerFactory interface {
	CreateInvoker(config InvocationConfig, schema *jsonschema.Resolved) (Invoker, error)
}

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