Documentation
¶
Index ¶
- Constants
- func InvocationValidator(primitive Primitive) error
- func RegisterFactory(invocationType string, factory InvokerFactory)
- type Builder
- type ConfigMetadata
- type DynamicJson
- type InvocationConfig
- type InvocationConfigWrapper
- func (w InvocationConfigWrapper) GetConfig() InvocationConfig
- func (w InvocationConfigWrapper) GetType() string
- func (w InvocationConfigWrapper) JSONSchema() *invopopschema.Schema
- func (w InvocationConfigWrapper) MarshalJSON() ([]byte, error)
- func (w *InvocationConfigWrapper) UnmarshalJSON(data []byte) error
- type Invoker
- type InvokerFactory
- type Primitive
- type Registry
Constants ¶
const ( JsonSchemaTypeObject = "object" JsonSchemaTypeNumber = "number" JsonSchemaTypeInteger = "integer" JsonSchemaTypeString = "string" JsonSchemaTypeArray = "array" JsonSchemaTypeBoolean = "boolean" JsonSchemaTypeNull = "null" )
Variables ¶
This section is empty.
Functions ¶
func InvocationValidator ¶
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 (w InvocationConfigWrapper) GetConfig() InvocationConfig
func (InvocationConfigWrapper) GetType ¶ added in v0.1.1
func (w InvocationConfigWrapper) GetType() string
func (InvocationConfigWrapper) JSONSchema ¶ added in v0.1.1
func (w InvocationConfigWrapper) JSONSchema() *invopopschema.Schema
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 CreatePromptInvoker ¶
func CreateResourceInvoker ¶
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
}