Documentation
¶
Index ¶
- type AuthorizationConfig
- type CheckPermissionTool
- type Config
- type ConfigResource
- type MCPError
- type MCPRequest
- type MCPResponse
- type Mode
- type Plugin
- func (p *Plugin) GetServer() *Server
- func (p *Plugin) ID() string
- func (p *Plugin) Init(auth core.Authsome) error
- func (p *Plugin) Migrate() error
- func (p *Plugin) RegisterHooks(hooks *hooks.HookRegistry) error
- func (p *Plugin) RegisterRoutes(router forge.Router) error
- func (p *Plugin) RegisterServiceDecorators(services *registry.ServiceRegistry) error
- func (p *Plugin) Start(ctx context.Context) error
- func (p *Plugin) Stop(ctx context.Context) error
- type PluginOption
- type QueryUserTool
- type RateLimitConfig
- type Resource
- type ResourceDescription
- type ResourceRegistry
- type RoutesResource
- type SchemaResource
- type SecurityLayer
- type Server
- type Tool
- type ToolDescription
- type ToolRegistry
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthorizationConfig ¶
type AuthorizationConfig struct {
// RequireAPIKey enforces API key authentication
RequireAPIKey bool `json:"require_api_key" yaml:"require_api_key"`
// AllowedOperations lists permitted read-only operations
AllowedOperations []string `json:"allowed_operations" yaml:"allowed_operations"`
// AdminOperations require admin role (only in admin/development mode)
AdminOperations []string `json:"admin_operations" yaml:"admin_operations"`
}
AuthorizationConfig defines authorization requirements
type CheckPermissionTool ¶
type CheckPermissionTool struct{}
CheckPermissionTool verifies RBAC permissions
func (*CheckPermissionTool) Describe ¶
func (t *CheckPermissionTool) Describe() ToolDescription
func (*CheckPermissionTool) RequiresAdmin ¶
func (t *CheckPermissionTool) RequiresAdmin() bool
func (*CheckPermissionTool) RequiresAuth ¶
func (t *CheckPermissionTool) RequiresAuth() bool
type Config ¶
type Config struct {
// Enabled determines if MCP plugin is active
Enabled bool `json:"enabled" yaml:"enabled"`
// Mode controls what operations are allowed
Mode Mode `json:"mode" yaml:"mode"`
// Transport specifies communication method
Transport Transport `json:"transport" yaml:"transport"`
// Port for HTTP transport (default: 9090)
Port int `json:"port" yaml:"port"`
// ExposeSecrets determines if secrets are exposed (dev only)
ExposeSecrets bool `json:"expose_secrets" yaml:"expose_secrets"`
// Authorization settings
Authorization AuthorizationConfig `json:"authorization" yaml:"authorization"`
// RateLimit settings
RateLimit RateLimitConfig `json:"rate_limit" yaml:"rate_limit"`
}
Config defines the MCP plugin configuration
type ConfigResource ¶
type ConfigResource struct{}
ConfigResource exposes sanitized configuration
func (*ConfigResource) Describe ¶
func (r *ConfigResource) Describe() ResourceDescription
type MCPError ¶
type MCPError struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
MCPError represents an MCP error
type MCPRequest ¶
type MCPRequest struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id"`
Method string `json:"method"`
Params interface{} `json:"params,omitempty"`
}
MCPRequest represents an MCP JSON-RPC request
type MCPResponse ¶
type MCPResponse struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id"`
Result interface{} `json:"result,omitempty"`
Error *MCPError `json:"error,omitempty"`
}
MCPResponse represents an MCP JSON-RPC response
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements the MCP (Model Context Protocol) server Exposes AuthSome data and operations to AI assistants
func NewPlugin ¶
func NewPlugin(opts ...PluginOption) *Plugin
NewPlugin creates a new MCP plugin with optional configuration
func (*Plugin) RegisterHooks ¶
func (p *Plugin) RegisterHooks(hooks *hooks.HookRegistry) error
RegisterHooks registers plugin hooks (none needed for MCP)
func (*Plugin) RegisterRoutes ¶
RegisterRoutes registers HTTP endpoints if HTTP transport is enabled
func (*Plugin) RegisterServiceDecorators ¶
func (p *Plugin) RegisterServiceDecorators(services *registry.ServiceRegistry) error
RegisterServiceDecorators allows service decoration (none needed for MCP)
type PluginOption ¶
type PluginOption func(*Plugin)
PluginOption is a functional option for configuring the MCP plugin
func WithDefaultConfig ¶
func WithDefaultConfig(cfg Config) PluginOption
WithDefaultConfig sets the default configuration for the plugin
func WithEnabled ¶
func WithEnabled(enabled bool) PluginOption
WithEnabled sets whether MCP is enabled
func WithExposeSecrets ¶
func WithExposeSecrets(expose bool) PluginOption
WithExposeSecrets sets whether to expose secrets (dev only)
func WithTransport ¶
func WithTransport(transport string) PluginOption
WithTransport sets the MCP transport type
type QueryUserTool ¶
type QueryUserTool struct{}
QueryUserTool finds users by email/ID/username
func (*QueryUserTool) Describe ¶
func (t *QueryUserTool) Describe() ToolDescription
func (*QueryUserTool) RequiresAdmin ¶
func (t *QueryUserTool) RequiresAdmin() bool
func (*QueryUserTool) RequiresAuth ¶
func (t *QueryUserTool) RequiresAuth() bool
type RateLimitConfig ¶
type RateLimitConfig struct {
// RequestsPerMinute limits MCP requests
RequestsPerMinute int `json:"requests_per_minute" yaml:"requests_per_minute"`
}
RateLimitConfig defines rate limiting
type Resource ¶
type Resource interface {
Read(ctx context.Context, uri string, plugin *Plugin) (string, error)
Describe() ResourceDescription
}
Resource defines the interface for MCP resources
type ResourceDescription ¶
type ResourceDescription struct {
URI string `json:"uri"`
Name string `json:"name"`
Description string `json:"description"`
MimeType string `json:"mimeType"`
}
ResourceDescription describes a resource for MCP clients
type ResourceRegistry ¶
type ResourceRegistry struct {
// contains filtered or unexported fields
}
ResourceRegistry manages available resources
func NewResourceRegistry ¶
func NewResourceRegistry() *ResourceRegistry
NewResourceRegistry creates a new resource registry
func (*ResourceRegistry) List ¶
func (r *ResourceRegistry) List() []ResourceDescription
List returns descriptions of all resources
func (*ResourceRegistry) Register ¶
func (r *ResourceRegistry) Register(uri string, resource Resource)
Register registers a resource handler
type RoutesResource ¶
type RoutesResource struct{}
RoutesResource exposes registered API routes
func (*RoutesResource) Describe ¶
func (r *RoutesResource) Describe() ResourceDescription
type SchemaResource ¶
type SchemaResource struct{}
SchemaResource exposes database schema information
func (*SchemaResource) Describe ¶
func (r *SchemaResource) Describe() ResourceDescription
type SecurityLayer ¶
type SecurityLayer struct {
// contains filtered or unexported fields
}
SecurityLayer handles authorization and data sanitization for MCP
func NewSecurityLayer ¶
func NewSecurityLayer(config Config, db *bun.DB) *SecurityLayer
NewSecurityLayer creates a new security layer
func (*SecurityLayer) AuthorizeRequest ¶
func (s *SecurityLayer) AuthorizeRequest(ctx context.Context, operation string, apiKey string) error
AuthorizeRequest checks if a request is authorized
func (*SecurityLayer) CheckOperationAllowed ¶
func (s *SecurityLayer) CheckOperationAllowed(operation string) error
CheckOperationAllowed checks if operation is allowed in current mode
func (*SecurityLayer) SanitizeData ¶
func (s *SecurityLayer) SanitizeData(data interface{}, dataType string) interface{}
SanitizeData removes sensitive information from data
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements the MCP (Model Context Protocol) server
type Tool ¶
type Tool interface {
Execute(ctx context.Context, arguments map[string]interface{}, plugin *Plugin) (string, error)
Describe() ToolDescription
RequiresAuth() bool
RequiresAdmin() bool
}
Tool defines the interface for MCP tools
type ToolDescription ¶
type ToolDescription struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]interface{} `json:"inputSchema"`
}
ToolDescription describes a tool for MCP clients
type ToolRegistry ¶
type ToolRegistry struct {
// contains filtered or unexported fields
}
ToolRegistry manages available tools
func NewToolRegistry ¶
func NewToolRegistry() *ToolRegistry
NewToolRegistry creates a new tool registry
func (*ToolRegistry) Execute ¶
func (r *ToolRegistry) Execute(ctx context.Context, name string, arguments map[string]interface{}, plugin *Plugin) (string, error)
Execute executes a tool by name
func (*ToolRegistry) List ¶
func (r *ToolRegistry) List(mode Mode) []ToolDescription
List returns descriptions of all tools (filtered by mode)
func (*ToolRegistry) Register ¶
func (r *ToolRegistry) Register(name string, tool Tool)
Register registers a tool handler