Documentation
¶
Index ¶
- Variables
- type APISpec
- type ConfigInterface
- type LoggerInterface
- type MCPHandler
- func (h *MCPHandler) AddSpec(specID string, spec *APISpec)
- func (h *MCPHandler) DeleteSpec(specID string) error
- func (h *MCPHandler) GetSpec(w http.ResponseWriter, r *http.Request)
- func (h *MCPHandler) GetSpecs() map[string]*APISpec
- func (h *MCPHandler) HandleMCPRequest(ctx context.Context, req *MCPRequest) (*MCPResponse, error)
- func (h *MCPHandler) ListEndpoints(w http.ResponseWriter, r *http.Request)
- func (h *MCPHandler) LoadOpenAPISpec(ctx context.Context, specURL string) (*openapi3.T, error)
- func (h *MCPHandler) RegisterSpec(w http.ResponseWriter, r *http.Request)
- func (h *MCPHandler) SaveSpec(specID string, spec *APISpec) error
- type MCPRequest
- type MCPResponse
- type Server
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("not found") ErrInvalidURL = errors.New("invalid URL") ErrInvalidSpec = errors.New("invalid OpenAPI spec") ErrFileOperation = errors.New("file operation failed") )
Common error types for consistent error handling
var ( ErrServerCreation = errors.New("failed to create server") ErrServerStart = errors.New("failed to start server") )
Common errors for server operations
var SpecsDir string
SpecsDir is the directory where specs are stored
Functions ¶
This section is empty.
Types ¶
type ConfigInterface ¶
type ConfigInterface interface {
GetGitHubToken() string
GetSpecs() []string
ShouldUpdateConfig() bool
HasSpec(url string) bool
AddSpec(url string)
RemoveSpec(url string)
Save() error
}
ConfigInterface defines the required config methods
var Config ConfigInterface
Config is the global configuration
type LoggerInterface ¶
type LoggerInterface interface {
Debugw(msg string, keysAndValues ...interface{})
Infow(msg string, keysAndValues ...interface{})
Warnw(msg string, keysAndValues ...interface{})
Errorw(msg string, keysAndValues ...interface{})
Fatalw(msg string, keysAndValues ...interface{})
}
LoggerInterface defines the required logging methods
var Logger LoggerInterface
Logger is the global logger
type MCPHandler ¶
type MCPHandler struct {
// contains filtered or unexported fields
}
MCPHandler handles OpenAPI specs for the MCP server
func NewHandler ¶
func NewHandler(specsDir string, logger LoggerInterface, config ConfigInterface) *MCPHandler
NewHandler creates a new MCPHandler
func (*MCPHandler) AddSpec ¶
func (h *MCPHandler) AddSpec(specID string, spec *APISpec)
AddSpec adds a spec to the handler
func (*MCPHandler) DeleteSpec ¶
func (h *MCPHandler) DeleteSpec(specID string) error
DeleteSpec removes a spec from memory and deletes its file
func (*MCPHandler) GetSpec ¶
func (h *MCPHandler) GetSpec(w http.ResponseWriter, r *http.Request)
GetSpec gets a registered OpenAPI specification via HTTP
func (*MCPHandler) GetSpecs ¶
func (h *MCPHandler) GetSpecs() map[string]*APISpec
GetSpecs returns a copy of the loaded specs map
func (*MCPHandler) HandleMCPRequest ¶
func (h *MCPHandler) HandleMCPRequest(ctx context.Context, req *MCPRequest) (*MCPResponse, error)
HandleMCPRequest handles MCP requests
func (*MCPHandler) ListEndpoints ¶
func (h *MCPHandler) ListEndpoints(w http.ResponseWriter, r *http.Request)
ListEndpoints lists all endpoints in a registered OpenAPI specification via HTTP
func (*MCPHandler) LoadOpenAPISpec ¶
LoadOpenAPISpec loads an OpenAPI specification from a URL
func (*MCPHandler) RegisterSpec ¶
func (h *MCPHandler) RegisterSpec(w http.ResponseWriter, r *http.Request)
RegisterSpec registers a new OpenAPI specification via HTTP
type MCPRequest ¶
type MCPRequest struct {
Query string `json:"query"`
}
MCPRequest represents an MCP request
type MCPResponse ¶
type MCPResponse struct {
Context string `json:"context"`
}
MCPResponse represents an MCP response
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the OpenAPI Explorer server
func CreateServer ¶
func CreateServer(specsDir string, logger LoggerInterface, config ConfigInterface) (*Server, error)
CreateServer creates a new Server instance
func (*Server) GetHandler ¶
func (s *Server) GetHandler() *MCPHandler
GetHandler returns the MCPHandler
func (*Server) GetMCPServer ¶
GetMCPServer returns the MCPServer