Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arg ¶
type Arg struct {
Name string `json:"name"`
Position string `json:"position"`
Required bool `json:"required"`
Type string `json:"type"`
Description string `json:"description"`
Default string `json:"default"`
}
Arg represents a tool argument
type AudioHandler ¶
type AudioHandler struct {
BaseHandler
}
AudioHandler is a handler for audio responses
func (*AudioHandler) Handle ¶
func (h *AudioHandler) Handle(resp *http.Response, tool *config.ToolConfig, tmplCtx *template.Context) (*mcp.CallToolResult, error)
type Auth ¶
type Auth struct {
Mode string `json:"mode"`
Header string `json:"header"`
ArgKey string `json:"argKey"`
}
Auth represents authentication configuration
type BaseHandler ¶
type BaseHandler struct {
// contains filtered or unexported fields
}
BaseHandler is a base implementation of the ResponseHandler interface
func (*BaseHandler) HandleNext ¶
func (h *BaseHandler) HandleNext(resp *http.Response, tool *config.ToolConfig, tmplCtx *template.Context) (*mcp.CallToolResult, error)
func (*BaseHandler) SetNext ¶
func (h *BaseHandler) SetNext(handler ResponseHandler)
type ImageHandler ¶
type ImageHandler struct {
BaseHandler
}
ImageHandler is a handler for image responses
func (*ImageHandler) Handle ¶
func (h *ImageHandler) Handle(resp *http.Response, tool *config.ToolConfig, tmplCtx *template.Context) (*mcp.CallToolResult, error)
type ResponseHandler ¶
type ResponseHandler interface {
// CanHandle checks if the handler can process the given response
CanHandle(resp *http.Response) bool
// Handle processes the response and returns the result
Handle(resp *http.Response, tool *config.ToolConfig, tmplCtx *template.Context) (*mcp.CallToolResult, error)
// SetNext sets the next handler in the chain
SetNext(handler ResponseHandler)
}
ResponseHandler is an interface for handling HTTP responses
func CreateResponseHandlerChain ¶
func CreateResponseHandlerChain() ResponseHandler
CreateResponseHandlerChain create a chain of response handlers The first handler is ImageHandler, which handles image responses. The second handler is TextHandler, which handles text responses. default handler is a base handler that can handle any other type of response. If the response is neither, it will return an error.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the MCP server
func NewServer ¶
func NewServer(logger *zap.Logger, port int, store storage.Store, sessionStore session.Store, a auth.Auth) (*Server, error)
NewServer creates a new MCP server
func (*Server) RegisterRoutes ¶
RegisterRoutes registers routes with the given router for MCP servers
func (*Server) ReloadConfigs ¶
type Storage ¶
type Storage interface {
// SaveTool saves a tool configuration
SaveTool(ctx context.Context, tool *Tool) error
// GetTool retrieves a tool configuration
GetTool(ctx context.Context, name string) (*Tool, error)
// ListTools lists all tool configurations
ListTools(ctx context.Context) ([]*Tool, error)
// DeleteTool deletes a tool configuration
DeleteTool(ctx context.Context, name string) error
// SaveServer saves a server configuration
SaveServer(ctx context.Context, server *StoredServer) error
// GetServer retrieves a server configuration
GetServer(ctx context.Context, name string) (*StoredServer, error)
// ListServers lists all server configurations
ListServers(ctx context.Context) ([]*StoredServer, error)
// DeleteServer deletes a server configuration
DeleteServer(ctx context.Context, name string) error
}
Storage defines the interface for storing runtimeUnit data
type StoredServer ¶
type StoredServer struct {
Name string `json:"name"`
Description string `json:"description"`
Auth Auth `json:"auth"`
AllowedTools []string `json:"allowedTools"`
AllowedOrigins []string `json:"allowedOrigins"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
StoredServer represents a server in storage
type TextHandler ¶
type TextHandler struct {
BaseHandler
}
TextHandler is a handler for text responses
func (*TextHandler) Handle ¶
func (h *TextHandler) Handle(resp *http.Response, tool *config.ToolConfig, tmplCtx *template.Context) (*mcp.CallToolResult, error)
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
Method string `json:"method"`
Endpoint string `json:"endpoint"`
Headers map[string]string `json:"headers"`
Args []Arg `json:"args"`
RequestBody string `json:"requestBody"`
ResponseBody string `json:"responseBody"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
Tool represents a tool in storage