mcp

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepCloneYAML

func DeepCloneYAML(n *yaml.Node) *yaml.Node

DeepCloneYAML creates a full, recursive copy of a yaml.Node.

func FindYAMLReferences

func FindYAMLReferences(docNode *yaml.Node, openAPIRoot *yaml.Node) (*yaml.Node, error)

FindYAMLReferences uses a recursive approach combined with JSONPath to find all references starting from docNode, resolving nested $refs against the provided openAPIRoot (which contains the components/schemas section). It returns a single yaml.MappingNode containing the collected and rewritten schemas.

func GetChildNodeByJSONPath

func GetChildNodeByJSONPath(root *yaml.Node, jsonPath string) (*yaml.Node, error)

GetChildNodeByJSONPath finds a single YAML node within the root node using a JSONPath expression. If no node is found, it returns (nil, nil). If more than one node is found, it returns an error.

func GetChildNodeByJSONPathOrDefault

func GetChildNodeByJSONPathOrDefault(root *yaml.Node, jsonPath string, def *yaml.Node) (*yaml.Node, error)

GetChildNodeByJSONPathOrDefault finds a single YAML node within the root node using a JSONPath expression. If no node is found, it returns the provided default node. If more than one node is found, it returns an error.

func GetChildNodesByJSONPath

func GetChildNodesByJSONPath(root *yaml.Node, jsonPath string) ([]*yaml.Node, error)

GetChildNodesByJSONPath finds all YAML nodes within the root node that match the given JSONPath expression.

func InlineYAMLReferences

func InlineYAMLReferences(docNode *yaml.Node, rootDoc *yaml.Node) (*yaml.Node, error)

InlineYAMLReferences deep clones the document, then performs a single-pass recursive inlining of all references from rootDoc, ensuring no $refs remain and correctly handling cycles.

func JSONPointerToJSONPath added in v1.1.1

func JSONPointerToJSONPath(refPath string) (string, error)

JSONPointerToJSONPath converts a JSON Pointer (like "#/a/b") to a JSONPath expression (like "$['a']['b']"). This correctly handles segments containing special characters like dots (e.g., "$['a.b']"). It also correctly unescapes JSON Pointer's ~0 and ~1 sequences.

func OAS3ToMCPValues

func OAS3ToMCPValues(file string) (mcpValuesMap map[string]any, err error)

func ResolveYAMLReference

func ResolveYAMLReference(refPath string, openAPIRoot *yaml.Node) (*yaml.Node, error)

Types

type AuthServerInfo

type AuthServerInfo struct {
	AuthType         string   `yaml:"type"`
	IssuerURL        string   `yaml:"issuer_url"`
	AuthorizationURL string   `yaml:"authorization_url,omitempty"`
	TokenURL         string   `yaml:"token_url,omitempty"`
	Scopes           []string `yaml:"scopes"`
	Flows            []string `yaml:"flows"`
}

AuthServerInfo holds the consolidated information for a single OAuth2 authorization server.

func (*AuthServerInfo) Type

func (a *AuthServerInfo) Type() string

type AuthorizationServer

type AuthorizationServer interface {
	Type() string
}

AuthorizationServer is an interface representing a generic authorization server.

func SelectAuthorizationServer

func SelectAuthorizationServer(root *yaml.Node) (AuthorizationServer, error)

SelectAuthorizationServer finds the authorization server corresponding to the highest priority security requirement. The selection is prioritized: 1. A requirement defined at the top-level of the document. 2. The requirement that is used most frequently across all operations.

type OIDCAuthServerInfo

type OIDCAuthServerInfo struct {
	AuthType         string `yaml:"type"`
	IssuerURL        string `yaml:"issuer_url"`
	OpenIdConnectUrl string `yaml:"openIdConnectUrl"`
}

OIDCAuthServerInfo holds the consolidated information for a single OpenID Connect server.

func (*OIDCAuthServerInfo) Type

func (o *OIDCAuthServerInfo) Type() string

type SecurityRequirement

type SecurityRequirement struct {
	Name   string
	Scopes []string
}

SecurityRequirement holds a security scheme name and the scopes required.

type Tool

type Tool struct {
	Name         string     `yaml:"name"`
	Title        string     `yaml:"title"`
	Description  string     `yaml:"description"`
	InputSchema  *yaml.Node `yaml:"inputSchema,omitempty"`
	OutputSchema *yaml.Node `yaml:"outputSchema,omitempty"`
}

type ToolTarget

type ToolTarget struct {
	Verb           string     `yaml:"verb"`
	PathSuffix     string     `yaml:"pathSuffix"`
	ContentType    string     `yaml:"contentType"`
	Accept         string     `yaml:"accept"`
	QueryParams    []string   `yaml:"queryParams"`
	HeaderParams   []string   `yaml:"headerParams"`
	PathParams     []string   `yaml:"pathParams"`
	PayloadParam   string     `yaml:"payloadParam"`
	PayloadSchema  *yaml.Node `yaml:"payloadSchema"`
	ResponseSchema *yaml.Node `yaml:"responseSchema"`
}

type ValuesFile

type ValuesFile struct {
	ToolsList    []*Tool                `yaml:"tools_list"`
	ToolsTargets map[string]*ToolTarget `yaml:"tools_targets"`
	AuthServer   AuthorizationServer    `yaml:"auth_server"`
}

Jump to

Keyboard shortcuts

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