43 lines
1.4 KiB
Go
43 lines
1.4 KiB
Go
// Package mcp is the MCP edge for the cart's promotion engine: a Model Context
|
|
// Protocol server exposing the promotion Store and evaluator as tools so an
|
|
// agent can list, create, update, status-toggle and delete the promotions the
|
|
// cart actually applies (e.g. Volymrabatt), plus preview the discount a cart
|
|
// total would receive.
|
|
//
|
|
// Transport/dispatch and the schema/result helpers live in platform/mcp; this
|
|
// package defines the promotion tools (full set via New, read-only via NewPublic)
|
|
// and the admin tools (AdminTools) that backoffice merges into the CMS MCP.
|
|
package mcp
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.k6n.net/mats/go-cart-actor/pkg/promotions"
|
|
pmcp "git.k6n.net/mats/platform/mcp"
|
|
)
|
|
|
|
const (
|
|
serverName = "cart-promotions"
|
|
serverVersion = "0.1.0"
|
|
)
|
|
|
|
// Server is the MCP edge over the shared promotion Store and evaluator.
|
|
type Server struct {
|
|
store *promotions.Store
|
|
eval *promotions.PromotionService
|
|
mcp *pmcp.Server
|
|
}
|
|
|
|
// New builds an MCP server exposing the full promotion tool set.
|
|
func New(store *promotions.Store, eval *promotions.PromotionService) *Server {
|
|
if eval == nil {
|
|
eval = promotions.NewPromotionService(nil)
|
|
}
|
|
s := &Server{store: store, eval: eval}
|
|
s.mcp = pmcp.NewServer(pmcp.Info{Name: serverName, Version: serverVersion}, s.buildTools()...)
|
|
return s
|
|
}
|
|
|
|
// Handler returns the streamable-HTTP handler to mount (e.g. at /mcp).
|
|
func (s *Server) Handler() http.Handler { return s.mcp.Handler() }
|