server

package
v0.0.0-...-629ae5f Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package server wires dependencies and builds the HTTP handler container.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMCPTool

func CreateMCPTool(t m.MCPTool) mcp.Tool

CreateMCPTool constructs an mcp-go Tool from a DB tool record.

func ReadJSON

func ReadJSON[T any](w http.ResponseWriter, r *http.Request, dst *T) bool

ReadJSON ...

func WriteJSON

func WriteJSON(w http.ResponseWriter, code int, v any)

WriteJSON ...

Types

type Config

type Config struct {
	Middlewares []func(http.Handler) http.Handler
	MCPMount    string
	AdminPrefix string
}

Config holds HTTP wiring configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults.

type Deps

type Deps struct {
	Logger              *slog.Logger
	Tools               *tool.Service
	Hubs                *mcphub.Service
	Virtual             *virtualmcp.Service
	Catalog             *catalog.Service
	Encrypter           *encryptor.AESEncrypter
	UserService         *usersvc.Service
	McphubOrchestrator  *mcphubOrchestrator.Orchestrator
	CatalogOrchestrator *catalogOrchestrator.Orchestrator
	AppConfig           *cfgpkg.Config
}

Deps enumerates dependencies required to assemble the server.

type Option

type Option func(*Deps)

Option configures dependencies for the server.

func WithAppConfig

func WithAppConfig(c *cfgpkg.Config) Option

WithAppConfig ...

func WithCatalog

func WithCatalog(s *catalog.Service) Option

WithCatalog ...

func WithCatalogOrchestrator

func WithCatalogOrchestrator(o *catalogOrchestrator.Orchestrator) Option

WithCatalogOrchestrator ...

func WithEncrypter

func WithEncrypter(e *encryptor.AESEncrypter) Option

WithEncrypter ...

func WithHubs

func WithHubs(s *mcphub.Service) Option

WithHubs ...

func WithLogger

func WithLogger(l *slog.Logger) Option

WithLogger ...

func WithMcphubOrchestrator

func WithMcphubOrchestrator(o *mcphubOrchestrator.Orchestrator) Option

WithMcphubOrchestrator ...

func WithTools

func WithTools(s *tool.Service) Option

WithTools ...

func WithUserService

func WithUserService(s *usersvc.Service) Option

WithUserService ...

func WithVirtual

func WithVirtual(s *virtualmcp.Service) Option

WithVirtual ...

type Server

type Server struct {
	Handler http.Handler
}

Server holds the final HTTP handler for the app.

func New

func New(cfg Config, opts ...Option) *Server

New builds a Server with the given configuration and dependency options.

Jump to

Keyboard shortcuts

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