Documentation
¶
Index ¶
- Variables
- func FormatOperationResult(operation, resourceType string, affected bool) string
- func GetRequiredScopeForTool(toolName string, registry []*object.ScopeItem) string
- func GetScopesFromClaims(claims *object.Claims) []string
- func GetToolsForScopes(grantedScopes []string, registry []*object.ScopeItem) map[string]bool
- type AddApplicationArgs
- type DeleteApplicationArgs
- type GetApplicationArgs
- type GetApplicationsArgs
- type McpCallToolParams
- type McpCallToolResult
- type McpController
- func (c *McpController) ClearUserSession()
- func (c *McpController) GetAcceptLanguage() string
- func (c *McpController) GetClaimsFromToken() *object.Claims
- func (c *McpController) GetSessionData() *SessionData
- func (c *McpController) GetSessionUsername() string
- func (c *McpController) GetTokenFromRequest() string
- func (c *McpController) HandleMcp()
- func (c *McpController) IsGlobalAdmin() bool
- func (c *McpController) McpResponseError(id interface{}, code int, message string, data interface{})
- func (c *McpController) McpResponseOk(id interface{}, result interface{})
- func (c *McpController) Prepare()
- func (c *McpController) SendToolErrorResult(id interface{}, errorMsg string)
- func (c *McpController) SendToolResult(id interface{}, text string)
- type McpError
- type McpImplementation
- type McpInitializeParams
- type McpInitializeResult
- type McpListToolsResult
- type McpRequest
- type McpResponse
- type McpServerCapabilities
- type McpTool
- type SessionData
- type TextContent
- type UpdateApplicationArgs
Constants ¶
This section is empty.
Variables ¶
var BuiltinScopes = []*object.ScopeItem{ { Name: "application:read", DisplayName: "Read Applications", Description: "View application list and details", Tools: []string{"get_applications", "get_application"}, }, { Name: "application:write", DisplayName: "Manage Applications", Description: "Create, update, and delete applications", Tools: []string{"add_application", "update_application", "delete_application"}, }, { Name: "user:read", DisplayName: "Read Users", Description: "View user list and details", Tools: []string{"get_users", "get_user"}, }, { Name: "user:write", DisplayName: "Manage Users", Description: "Create, update, and delete users", Tools: []string{"add_user", "update_user", "delete_user"}, }, { Name: "organization:read", DisplayName: "Read Organizations", Description: "View organization list and details", Tools: []string{"get_organizations", "get_organization"}, }, { Name: "organization:write", DisplayName: "Manage Organizations", Description: "Create, update, and delete organizations", Tools: []string{"add_organization", "update_organization", "delete_organization"}, }, { Name: "permission:read", DisplayName: "Read Permissions", Description: "View permission list and details", Tools: []string{"get_permissions", "get_permission"}, }, { Name: "permission:write", DisplayName: "Manage Permissions", Description: "Create, update, and delete permissions", Tools: []string{"add_permission", "update_permission", "delete_permission"}, }, { Name: "role:read", DisplayName: "Read Roles", Description: "View role list and details", Tools: []string{"get_roles", "get_role"}, }, { Name: "role:write", DisplayName: "Manage Roles", Description: "Create, update, and delete roles", Tools: []string{"add_role", "update_role", "delete_role"}, }, { Name: "provider:read", DisplayName: "Read Providers", Description: "View provider list and details", Tools: []string{"get_providers", "get_provider"}, }, { Name: "provider:write", DisplayName: "Manage Providers", Description: "Create, update, and delete providers", Tools: []string{"add_provider", "update_provider", "delete_provider"}, }, { Name: "token:read", DisplayName: "Read Tokens", Description: "View token list and details", Tools: []string{"get_tokens", "get_token"}, }, { Name: "token:write", DisplayName: "Manage Tokens", Description: "Delete tokens", Tools: []string{"delete_token"}, }, }
BuiltinScopes defines the default scope-to-tool mappings for the IAM MCP server
var ConvenienceScopes = map[string][]string{
"read": {"application:read", "user:read", "organization:read", "permission:read", "role:read", "provider:read", "token:read"},
"write": {"application:write", "user:write", "organization:write", "permission:write", "role:write", "provider:write", "token:write"},
"admin": {"application:read", "application:write", "user:read", "user:write", "organization:read", "organization:write", "permission:read", "permission:write", "role:read", "role:write", "provider:read", "provider:write", "token:read", "token:write"},
}
ConvenienceScopes defines alias scopes that expand to multiple resource scopes
Functions ¶
func FormatOperationResult ¶
FormatOperationResult formats the result of CRUD operations in a clear, descriptive way
func GetRequiredScopeForTool ¶
GetRequiredScopeForTool returns the first scope that provides access to the given tool Returns an empty string if no scope is found for the tool
func GetScopesFromClaims ¶
GetScopesFromClaims extracts the scopes from JWT claims and returns them as a slice
func GetToolsForScopes ¶
GetToolsForScopes returns a map of tools allowed by the given scopes The grantedScopes are the scopes present in the token The registry contains the scope-to-tool mappings (either BuiltinScopes or Application.Scopes)
Types ¶
type AddApplicationArgs ¶
type AddApplicationArgs struct {
Application object.Application `json:"application"`
}
type DeleteApplicationArgs ¶
type DeleteApplicationArgs struct {
Application object.Application `json:"application"`
}
type GetApplicationArgs ¶
type GetApplicationArgs struct {
Id string `json:"id"`
}
type GetApplicationsArgs ¶
type GetApplicationsArgs struct {
Owner string `json:"owner"`
}
Tool-specific argument structs
type McpCallToolParams ¶
type McpCallToolParams struct {
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments,omitempty"`
}
type McpCallToolResult ¶
type McpCallToolResult struct {
Content []TextContent `json:"content"`
IsError bool `json:"isError,omitempty"`
}
type McpController ¶
type McpController struct {
web.Controller
}
MCPController handles MCP protocol requests
func (*McpController) ClearUserSession ¶
func (c *McpController) ClearUserSession()
ClearUserSession clears the user session
func (*McpController) GetAcceptLanguage ¶
func (c *McpController) GetAcceptLanguage() string
GetAcceptLanguage returns the Accept-Language header value
func (*McpController) GetClaimsFromToken ¶
func (c *McpController) GetClaimsFromToken() *object.Claims
GetClaimsFromToken parses and validates the JWT token and returns the claims Returns nil if no token is present or if token is invalid
func (*McpController) GetSessionData ¶
func (c *McpController) GetSessionData() *SessionData
GetSessionData retrieves session data
func (*McpController) GetSessionUsername ¶
func (c *McpController) GetSessionUsername() string
GetSessionUsername returns the username from session or ctx
func (*McpController) GetTokenFromRequest ¶
func (c *McpController) GetTokenFromRequest() string
GetTokenFromRequest extracts the Bearer token from the Authorization header
func (*McpController) HandleMcp ¶
func (c *McpController) HandleMcp()
HandleMcp handles MCP protocol requests @Title HandleMcp @Tag MCP API @Description handle MCP (Model Context Protocol) requests @Success 200 {object} McpResponse The Response object @router /mcp [post]
func (*McpController) IsGlobalAdmin ¶
func (c *McpController) IsGlobalAdmin() bool
IsGlobalAdmin checks if the current user is a global admin
func (*McpController) McpResponseError ¶
func (c *McpController) McpResponseError(id interface{}, code int, message string, data interface{})
func (*McpController) McpResponseOk ¶
func (c *McpController) McpResponseOk(id interface{}, result interface{})
func (*McpController) Prepare ¶
func (c *McpController) Prepare()
func (*McpController) SendToolErrorResult ¶
func (c *McpController) SendToolErrorResult(id interface{}, errorMsg string)
SendToolErrorResult sends a tool execution error result
func (*McpController) SendToolResult ¶
func (c *McpController) SendToolResult(id interface{}, text string)
SendToolResult sends a successful tool execution result
type McpImplementation ¶
type McpInitializeParams ¶
type McpInitializeParams struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities map[string]interface{} `json:"capabilities"`
ClientInfo McpImplementation `json:"clientInfo"`
}
type McpInitializeResult ¶
type McpInitializeResult struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities McpServerCapabilities `json:"capabilities"`
ServerInfo McpImplementation `json:"serverInfo"`
}
type McpListToolsResult ¶
type McpListToolsResult struct {
Tools []McpTool `json:"tools"`
}
type McpRequest ¶
type McpRequest struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
MCP JSON-RPC 2.0 structures
type McpResponse ¶
type McpResponse struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id"`
Result interface{} `json:"result,omitempty"`
Error *McpError `json:"error,omitempty"`
}
func BuildMcpResponse ¶
func BuildMcpResponse(id interface{}, result interface{}, err *McpError) McpResponse
GetMcpResponse returns a McpResponse object
type McpServerCapabilities ¶
type McpServerCapabilities struct {
Tools map[string]interface{} `json:"tools,omitempty"`
}
type SessionData ¶
type SessionData struct {
ExpireTime int64
}
SessionData represents session metadata
type TextContent ¶
type UpdateApplicationArgs ¶
type UpdateApplicationArgs struct {
Id string `json:"id"`
Application object.Application `json:"application"`
}