mcpself

package
v1.18.2 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

View Source
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

func FormatOperationResult(operation, resourceType string, affected bool) string

FormatOperationResult formats the result of CRUD operations in a clear, descriptive way

func GetRequiredScopeForTool

func GetRequiredScopeForTool(toolName string, registry []*object.ScopeItem) string

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

func GetScopesFromClaims(claims *object.Claims) []string

GetScopesFromClaims extracts the scopes from JWT claims and returns them as a slice

func GetToolsForScopes

func GetToolsForScopes(grantedScopes []string, registry []*object.ScopeItem) map[string]bool

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 McpError

type McpError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

type McpImplementation

type McpImplementation struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

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 McpTool

type McpTool struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	InputSchema map[string]interface{} `json:"inputSchema"`
}

type SessionData

type SessionData struct {
	ExpireTime int64
}

SessionData represents session metadata

type TextContent

type TextContent struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type UpdateApplicationArgs

type UpdateApplicationArgs struct {
	Id          string             `json:"id"`
	Application object.Application `json:"application"`
}

Jump to

Keyboard shortcuts

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