http

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: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InvocationType = "http"
)

Variables

This section is empty.

Functions

func IsValidHttpMethod

func IsValidHttpMethod(method string) bool

Types

type HttpInvocationConfig

type HttpInvocationConfig struct {
	// The URL template for the HTTP request. It can contain placeholders in the form of '%' which correspond to parameters from the input schema.
	PathTemplate string `json:"url" jsonschema:"required"`

	// PathIndices maps parameter names to their positional index in the PathTemplate.
	// This field is for internal use and is not part of the JSON schema.
	PathIndices map[string]int `json:"-"`

	// The HTTP method to be used for the request (e.g., "GET", "POST").
	Method string `json:"method" jsonschema:"required,enum=GET,enum=POST,enum=PUT,enum=PATCH,enum=DELETE,enum=HEAD"`

	// MCP URI template (for resource templates only).
	URITemplate string `json:"-"`
}

The configuration for making an HTTP request.

func (*HttpInvocationConfig) Validate

func (hic *HttpInvocationConfig) Validate() error

type HttpInvocationData

type HttpInvocationData struct {
	// Detailed HTTP invocation configuration.
	Http HttpInvocationConfig `json:"http" jsonschema:"required"`
}

The structure for HTTP invocation configuration. It is used to parse the raw JSON data that specifies how to make an HTTP request.

type HttpInvoker

type HttpInvoker struct {
	PathTemplate string               // template string for the request path
	PathIndeces  map[string]int       // map to where each path parameter should go in the path
	Method       string               // Http request method
	InputSchema  *jsonschema.Resolved // InputSchema for the tool
	URITemplate  string               // MCP URI template (for resource templates only)
}

func (*HttpInvoker) Invoke

func (*HttpInvoker) InvokePrompt

func (hi *HttpInvoker) InvokePrompt(ctx context.Context, req *mcp.GetPromptRequest) (*mcp.GetPromptResult, error)

func (*HttpInvoker) InvokeResource

func (hi *HttpInvoker) InvokeResource(ctx context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)

func (*HttpInvoker) InvokeResourceTemplate

func (hi *HttpInvoker) InvokeResourceTemplate(ctx context.Context, req *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error)

type InvokerFactory

type InvokerFactory struct{}

func (*InvokerFactory) CreateInvoker

type Parser

type Parser struct{}

func (*Parser) Parse

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)

Jump to

Keyboard shortcuts

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