bootstrap

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 26 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 AddOpenAIClientToContext added in v0.3.1

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

AddOpenAIClientToContext adds an OpenAI client to the context using environment variables

func AddOpenAIClientToContextWithCreds added in v0.3.1

func AddOpenAIClientToContextWithCreds(ctx context.Context, creds *OpenAICredentials) (context.Context, error)

AddOpenAIClientToContextWithCreds adds an OpenAI client to the context using provided credentials

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, openaiCreds *OpenAICredentials, permissionsConfigPath string) server.ToolHandlerMiddleware

func CreateOpenAIClient added in v0.3.1

func CreateOpenAIClient(creds *OpenAICredentials) (*openai.Client, error)

CreateOpenAIClient creates an OpenAI client from credentials

func CreateOpenAIWrapper added in v0.3.1

func CreateOpenAIWrapper(creds *OpenAICredentials) (*utils.OpenAIWrapper, error)

CreateOpenAIWrapper creates an OpenAI wrapper from credentials

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, openaiCreds *OpenAICredentials, 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

func ValidateTheHiveClient added in v0.3.1

func ValidateTheHiveClient(client *thehive.APIClient, ctx context.Context) error

Types

type OpenAICredentials added in v0.3.1

type OpenAICredentials struct {
	APIKey    string
	BaseURL   string
	Model     string
	MaxTokens int
}

OpenAICredentials holds authentication and configuration information for OpenAI

func LoadOpenAICredentialsFromEnv added in v0.3.1

func LoadOpenAICredentialsFromEnv() (*OpenAICredentials, error)

LoadOpenAICredentialsFromEnv loads OpenAI credentials from environment variables

func (*OpenAICredentials) Validate added in v0.3.1

func (c *OpenAICredentials) Validate() error

Validate validates the OpenAI credentials

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