Documentation
¶
Index ¶
- Constants
- type CliInvocationConfig
- type CliInvocationData
- type CliInvoker
- func (ci *CliInvoker) Invoke(ctx context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error)
- func (ci *CliInvoker) InvokePrompt(ctx context.Context, req *mcp.GetPromptRequest) (*mcp.GetPromptResult, error)
- func (ci *CliInvoker) InvokeResource(ctx context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)
- func (ci *CliInvoker) InvokeResourceTemplate(ctx context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)
- type DummyFormatter
- type Formatter
- type InvokerFactory
- type Parser
- func (p *Parser) Parse(data json.RawMessage, tool *mcpfile.Tool) (invocation.InvocationConfig, error)
- func (p *Parser) ParsePrompt(data json.RawMessage, prompt *mcpfile.Prompt) (invocation.InvocationConfig, error)
- func (p *Parser) ParseResource(data json.RawMessage, resource *mcpfile.Resource) (invocation.InvocationConfig, error)
- func (p *Parser) ParseResourceTemplate(data json.RawMessage, resourceTemplate *mcpfile.ResourceTemplate) (invocation.InvocationConfig, error)
- type TemplateVariable
Constants ¶
View Source
const (
InvocationType = "cli"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CliInvocationConfig ¶
type CliInvocationConfig struct {
// The command-line string to be executed. It can contain placeholders in the form of '%' which correspond to parameters defined in the input schema.
Command string `json:"command" jsonschema:"required"`
// Defines how input parameters are formatted into the command string.
// The map key corresponds to the parameter name from the input schema.
TemplateVariables map[string]*TemplateVariable `json:"templateVariables,omitempty" jsonschema:"optional"`
// ParameterIndices maps parameter names to their positional index in the command template.
// This field is for internal use and is not part of the JSON schema.
ParameterIndices map[string]int `json:"-"`
// MCP URI template (for resource templates only)
URITemplate string `json:"-"`
}
Configuration for executing a command-line tool.
func (*CliInvocationConfig) Validate ¶
func (c *CliInvocationConfig) Validate() error
type CliInvocationData ¶
type CliInvocationData struct {
// Detailed CLI invocation configuration.
Http CliInvocationConfig `json:"cli" jsonschema:"required"`
}
The structure for CLI invocation configuration.
type CliInvoker ¶
type CliInvoker struct {
CommandTemplate string // template string for the command to execute
ArgumentIndices map[string]int // map to where each argument should go in the command
ArgumentFormatters map[string]Formatter // map to the functions to format each variable
InputSchema *jsonschema.Resolved // InputSchema for the tool
URITemplate string // MCP URI template (for resource templates only)
}
func (*CliInvoker) Invoke ¶
func (ci *CliInvoker) Invoke(ctx context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error)
func (*CliInvoker) InvokePrompt ¶
func (ci *CliInvoker) InvokePrompt(ctx context.Context, req *mcp.GetPromptRequest) (*mcp.GetPromptResult, error)
func (*CliInvoker) InvokeResource ¶
func (ci *CliInvoker) InvokeResource(ctx context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)
func (*CliInvoker) InvokeResourceTemplate ¶
func (ci *CliInvoker) InvokeResourceTemplate(ctx context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)
type DummyFormatter ¶
type DummyFormatter struct {
// contains filtered or unexported fields
}
func NewDummyFormatter ¶
func NewDummyFormatter(paramName string, schema *jsonschema.Schema) (*DummyFormatter, error)
func (*DummyFormatter) FormatValue ¶
func (df *DummyFormatter) FormatValue(v any) string
type InvokerFactory ¶
type InvokerFactory struct{}
func (*InvokerFactory) CreateInvoker ¶
func (f *InvokerFactory) CreateInvoker(config invocation.InvocationConfig, schema *jsonschema.Resolved) (invocation.Invoker, error)
type Parser ¶
type Parser struct{}
func (*Parser) Parse ¶
func (p *Parser) Parse(data json.RawMessage, tool *mcpfile.Tool) (invocation.InvocationConfig, error)
func (*Parser) ParsePrompt ¶
func (p *Parser) ParsePrompt(data json.RawMessage, prompt *mcpfile.Prompt) (invocation.InvocationConfig, error)
func (*Parser) ParseResource ¶
func (p *Parser) ParseResource(data json.RawMessage, resource *mcpfile.Resource) (invocation.InvocationConfig, error)
func (*Parser) ParseResourceTemplate ¶
func (p *Parser) ParseResourceTemplate(data json.RawMessage, resourceTemplate *mcpfile.ResourceTemplate) (invocation.InvocationConfig, error)
type TemplateVariable ¶
type TemplateVariable struct {
// Template is the format string for the variable. It can be a simple string or a Go format string containing a verb like '%s', '%d', etc.
// For example, "--user=%s" or "--verbose".
Template string `json:"format" jsonschema:"required"`
// OmitIfFalse, if true, causes the template to be omitted entirely if the input
// value is a boolean `false`. This is useful for optional flags like "--force".
OmitIfFalse bool `json:"omitIfFalse,omitempty" jsonschema:"optional"`
// contains filtered or unexported fields
}
The formatting for a single parameter in the command template
func (*TemplateVariable) FormatValue ¶
func (tv *TemplateVariable) FormatValue(value any) string
Click to show internal directories.
Click to hide internal directories.