Documentation
¶
Overview ¶
Package mcpserver adapts the JetKVM domain services to the Model Context Protocol. It owns MCP schemas and transports, but no device lifecycle state.
Index ¶
- Variables
- func BearerMiddleware(token string) (func(http.Handler) http.Handler, error)
- func ClearResources(server *mcp.Server)
- func NewHTTPServer(protocol *mcp.Server, config HTTPConfig) (*http.Server, error)
- type AutomationService
- type ConfirmationIssuer
- type ConfirmationRequest
- type HTTPConfig
- type Observer
- type Options
- type Server
- type SetupService
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func BearerMiddleware ¶
BearerMiddleware returns independent HTTP bearer authentication middleware. It never forwards the bearer credential to DeviceService.
func ClearResources ¶ added in v1.0.6
ClearResources is used only by the application owner behind its dispatch gate.
func NewHTTPServer ¶ added in v1.0.6
NewHTTPServer retains one protocol endpoint across stateless requests so configuration activation and tools/list_changed have a single authority.
Types ¶
type AutomationService ¶
type AutomationService interface {
PrepareOpenControl(automation.OpenControlRequest) (automation.ConfirmationPlan, error)
OpenControl(context.Context, automation.OpenControlRequest) (control.Handle, error)
GetControl(context.Context, automation.ControlRequest) (control.Snapshot, error)
CloseControl(context.Context, automation.ControlRequest) (control.Handle, error)
RunActions(context.Context, automation.RunActionsRequest) (automation.RunActionsResult, error)
PrepareRunActions(automation.RunActionsRequest) (automation.ConfirmationPlan, error)
GetPowerState(context.Context, automation.ControlRequest) (automation.PowerState, error)
PowerAction(context.Context, automation.PowerActionRequest) (operation.Receipt, error)
PreparePowerAction(automation.PowerActionRequest) (automation.ConfirmationPlan, error)
}
AutomationService is the sole control-plane dependency of MCP handlers. The concrete automation.Service retains policy, actor, session, input and operation-ledger authority.
type ConfirmationIssuer ¶
type ConfirmationIssuer interface {
Issue(context.Context, ConfirmationRequest) (string, error)
Confirm(context.Context, string, ConfirmationRequest) (context.Context, error)
}
ConfirmationIssuer seals request state and atomically consumes its nonce. Confirm returns a context carrying the verified proof for downstream authorizers; callers must use that returned context for execution.
func NewConfirmationIssuer ¶
func NewConfirmationIssuer(key []byte, ttl time.Duration, terminal ...*coreconfirmation.Authority) (ConfirmationIssuer, error)
NewConfirmationIssuer constructs the process authority used by stdio and the first-release single-instance loopback HTTP server. Restarting the process invalidates outstanding states and therefore fails closed.
type ConfirmationRequest ¶
type ConfirmationRequest struct {
Principal string
DeviceID domain.DeviceID
ControlHandle control.HandleID
Generation uint64
OperationKind string
ArgumentsDigest string
ObservationID string
PolicyRevision string
Binding coreconfirmation.Binding
}
ConfirmationRequest is the complete authority-bound identity of one confirmation round. ArgumentsDigest must cover the canonical tool input.
type HTTPConfig ¶
type HTTPConfig struct {
ListenAddress string
BearerToken string
Endpoint string
MaxRequestBodyBytes int64
}
HTTPConfig configures the loopback-only stateless Streamable HTTP server.
type Observer ¶ added in v1.0.2
type Observer interface {
Observe(context.Context, automation.ObserveRequest) (automation.ScreenObservation, error)
}
Observer is separate from the control-only automation dependency.
type Options ¶
type Options struct {
Name string
Version string
AllowedTools map[string]bool
Automation AutomationService
ConfirmationIssuer ConfirmationIssuer
PolicyRevision string
Scope policy.Scope
DecoderAvailable bool
Setup SetupService
}
Options identifies this MCP server implementation to clients.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the stateless MCP adapter over a DeviceService.
Each transport gets an MCP server instance with the same immutable feature inventory. Stateful device ownership remains behind DeviceService.
func New ¶
func New(devices domain.DeviceService, options Options) (*Server, error)
New constructs an MCP adapter. It performs all configuration validation that is independent of a concrete transport.
func (*Server) Install ¶ added in v1.0.6
func (s *Server) Install(server *mcp.Server, setup SetupService)
func (*Server) NewStatelessHTTPServer ¶
func (s *Server) NewStatelessHTTPServer(config HTTPConfig) (*http.Server, error)
NewStatelessHTTPServer constructs a loopback-only HTTP server. The returned server is not started; callers retain shutdown and listener ownership.
func (*Server) ProtocolServer ¶ added in v1.0.6
ProtocolServer creates the shared protocol endpoint used by the application reconfiguration owner. Install runs only behind that owner's dispatch gate.
type SetupService ¶ added in v1.0.6
type SetupService interface {
Begin(onboarding.Draft) (onboarding.Progress, error)
Status(string) (onboarding.Progress, error)
Settings() (onboarding.Settings, error)
BeginUpdate(onboarding.SettingsPatch) (onboarding.Progress, error)
}