bootstrap

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingHiveURL        = errors.New("THEHIVE_URL environment variable is required")
	ErrInvalidHiveURL        = errors.New("invalid TheHive URL format")
	ErrMissingAuthentication = errors.New("either API key or username/password must be provided")
	ErrInvalidAPIKey         = errors.New("API key cannot be empty or 'dummy'")
	ErrMissingCredentials    = errors.New("both username and password are required for basic auth")
)

Common errors

Functions

func AddPermissionsToContext

func AddPermissionsToContext(ctx context.Context, options *types.TheHiveMcpDefaultOptions) (context.Context, error)

AddPermissionsToContext loads permissions and adds them to the context

func AddTheHiveClientToContext

func AddTheHiveClientToContext(ctx context.Context) (context.Context, error)

AddTheHiveClientToContext adds a TheHive client to the context using environment variables

func AddTheHiveClientToContextWithCreds

func AddTheHiveClientToContextWithCreds(ctx context.Context, creds *TheHiveCredentials) (context.Context, error)

AddTheHiveClientToContextWithCreds adds a TheHive client to the context using provided credentials

func AuthMiddleware

func AuthMiddleware(creds *TheHiveCredentials, permissionsConfigPath string) server.ToolHandlerMiddleware

func CreateTheHiveClient

func CreateTheHiveClient(creds *TheHiveCredentials) (*thehive.APIClient, error)

CreateTheHiveClient creates a TheHive client from credentials

func CreateTheHiveConfig

func CreateTheHiveConfig(creds *TheHiveCredentials) (*thehive.Configuration, error)

CreateTheHiveConfig creates a TheHive configuration from credentials

func ExtractBearerToken

func ExtractBearerToken(authHeader string) string

ExtractBearerToken extracts a bearer token from an Authorization header

func GetHTTPAuthContextFunc

func GetHTTPAuthContextFunc(options *types.TheHiveMcpDefaultOptions) func(ctx context.Context, r *http.Request) context.Context

func GetInprocessServer

func GetInprocessServer(creds *TheHiveCredentials, permissionsConfigPath string) *server.MCPServer

func GetMCPServer

func GetMCPServer() *server.MCPServer

func GetMCPServerAndRegisterTools

func GetMCPServerAndRegisterTools() *server.MCPServer

func LoadPermissions

func LoadPermissions(configPath string) (*permissions.Config, error)

LoadPermissions loads permissions configuration from file or uses default Special values: "admin" for full permissions, "read_only" for default read-only permissions Empty string defaults to read-only, otherwise loads from the specified file path

func RegisterToolsToMCPServer

func RegisterToolsToMCPServer(mcpServer *server.MCPServer)

func SafeGetEnv

func SafeGetEnv(key, defaultValue string) string

SafeGetEnv gets an environment variable with optional default value

func StartHTTPServer

func StartHTTPServer(s *server.MCPServer, options *types.TheHiveMcpDefaultOptions) error

StartHTTPServer starts the HTTP server with production-ready configuration

func StartStdioServer

func StartStdioServer(s *server.MCPServer, options *types.TheHiveMcpDefaultOptions) error

StartStdioServer starts the STDIO server with production-ready configuration and error handling

Types

type TheHiveCredentials

type TheHiveCredentials struct {
	URL          string
	APIKey       string
	Username     string
	Password     string
	Organisation string
}

TheHiveCredentials holds authentication information for TheHive

func LoadTheHiveCredentialsFromEnv

func LoadTheHiveCredentialsFromEnv() (*TheHiveCredentials, error)

LoadTheHiveCredentialsFromEnv loads TheHive credentials from environment variables

func (*TheHiveCredentials) Validate

func (c *TheHiveCredentials) Validate() error

Validate validates the credentials

Jump to

Keyboard shortcuts

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