Documentation
¶
Overview ¶
Package openapi provides OpenAPI integration for the upstream service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewOpenAPIUpstream ¶
NewOpenAPIUpstream creates a new instance of OpenAPIUpstream. It initializes a cache for storing parsed OpenAPI documents to avoid redundant parsing.
Types ¶
type McpOperation ¶
type McpOperation struct {
OperationID string
Summary string
Description string
Method string // e.g., GET, POST
Path string
// Simplified schema representation for request body
// Key: content type (e.g., "application/json")
// Value: schema reference
RequestBodySchema map[string]*openapi3.SchemaRef
// Simplified schema representation for responses
// Key: status code (e.g., "200")
// Value: map of content type to schema reference
ResponseSchemas map[string]map[string]*openapi3.SchemaRef
Parameters openapi3.Parameters // Store operation parameters (query, path, header, cookie)
}
McpOperation provides a simplified, MCP-centric representation of an OpenAPI operation. It contains the essential details needed to convert an API endpoint into an executable tool.
type OpenAPIUpstream ¶
type OpenAPIUpstream struct {
// contains filtered or unexported fields
}
OpenAPIUpstream implements the upstream.Upstream interface for services that are defined by an OpenAPI specification. It parses the spec, discovers the available operations, and registers them as tools.
func (*OpenAPIUpstream) Register ¶
func (u *OpenAPIUpstream) Register( ctx context.Context, serviceConfig *configv1.UpstreamServiceConfig, toolManager tool.ManagerInterface, promptManager prompt.ManagerInterface, resourceManager resource.ManagerInterface, isReload bool, ) (string, []*configv1.ToolDefinition, []*configv1.ResourceDefinition, error)
Register processes an OpenAPI service configuration. It parses the OpenAPI specification, extracts the operations, converts them into tools, and registers them with the tool manager.