mcpserver

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var (
	ErrConfirmationInvalid  = errors.New("confirmation state is invalid")
	ErrConfirmationExpired  = errors.New("confirmation state has expired")
	ErrConfirmationReplayed = errors.New("confirmation state was already consumed")
)

Functions

func BearerMiddleware

func BearerMiddleware(token string) (func(http.Handler) http.Handler, error)

BearerMiddleware returns independent HTTP bearer authentication middleware. It never forwards the bearer credential to DeviceService.

func ClearResources added in v1.0.6

func ClearResources(server *mcp.Server)

ClearResources is used only by the application owner behind its dispatch gate.

func NewHTTPServer added in v1.0.6

func NewHTTPServer(protocol *mcp.Server, config HTTPConfig) (*http.Server, error)

NewHTTPServer retains one protocol endpoint across stateless requests so configuration activation and tools/list_changed have a single authority.

Types

type AutomationService

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

func (s *Server) ProtocolServer() *mcp.Server

ProtocolServer creates the shared protocol endpoint used by the application reconfiguration owner. Install runs only behind that owner's dispatch gate.

func (*Server) RunStdio

func (s *Server) RunStdio(ctx context.Context) error

RunStdio serves MCP over process stdin/stdout until the peer disconnects or ctx is canceled. Callers must keep stdout exclusively reserved for MCP.

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)
}

Jump to

Keyboard shortcuts

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