server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 22 Imported by: 4

Documentation

Overview

Package server adapts a compiled Datly MCP service to the upstream protocol handler. Transport startup and authorization remain separate concerns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(service Service) (protocolserver.NewHandler, error)

NewHandler creates one upstream handler factory over a compiled Datly service.

func Release

func Release(ctx context.Context)

Release releases a generation pinned by Source.Pin when a caller uses the source directly instead of the protocol handler.

func WithRelease

func WithRelease(ctx context.Context, release func()) context.Context

WithRelease attaches application-generation ownership to one protocol call.

Types

type Config

type Config struct {
	ResourceAuthorizer auth.ResourceAuthorizer
	Service            ServerService
	Source             Source

	Implementation  schema.Implementation
	ProtocolVersion string
	LoggerName      string
	Transport       TransportConfig
	// contains filtered or unexported fields
}

type Handler

type Handler struct {
	*protocolserver.DefaultHandler
	// contains filtered or unexported fields
}

func (*Handler) CallTool

func (*Handler) Complete

func (*Handler) Discover

func (h *Handler) Discover(ctx context.Context, result *schema.DiscoverResult)

func (*Handler) GetPrompt

func (*Handler) GetSkill

func (*Handler) ImplementsContext

func (h *Handler) ImplementsContext(ctx context.Context, method string) bool

ImplementsContext is consumed at the native JSON-RPC ingress after pinning.

func (*Handler) Initialize

func (h *Handler) Initialize(ctx context.Context, input *schema.InitializeRequestParams, result *schema.InitializeResult)

func (*Handler) ListSkills

func (*Handler) ListTools

func (*Handler) OnNotification

func (h *Handler) OnNotification(ctx context.Context, notification *jsonrpc.Notification)

func (*Handler) Subscribe

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) (*Server, error)

func (*Server) HTTP

func (s *Server) HTTP() (*http.Server, error)

func (*Server) Serve

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

func (*Server) Shutdown

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

func (*Server) Stdio

func (s *Server) Stdio(ctx context.Context) (*stdio.Server, error)

type ServerService

type ServerService interface {
	Service
	Authorization() *authorization.Policy
}

type Service

type Service interface {
	Registry() *protocolserver.Registry
	ReadResource(context.Context, *schema.ReadResourceRequest) (*schema.ReadResourceResult, *jsonrpc.Error)
}

Service is the immutable MCP catalog and resource execution surface required by a protocol handler.

type Source

type Source interface {
	Pin(context.Context) (context.Context, ServerService, error)
}

Source pins one immutable service to an invocation context. Repeated calls with that context must return the same service, even after publication.

type TransportConfig

type TransportConfig struct {
	// Zero selects safe listener defaults; negative explicitly disables a deadline.
	ReadHeaderTimeout time.Duration
	IdleTimeout       time.Duration
	Kind              TransportKind
	Address           string
	SSEURI            string
	SSEMessageURI     string
	StreamableURI     string
	RootRedirect      bool
	CORS              *upstream.Cors
}

type TransportKind

type TransportKind string
const (
	TransportStdio      TransportKind = "stdio"
	TransportSSE        TransportKind = "sse"
	TransportStreamable TransportKind = "streamable"
)

Jump to

Keyboard shortcuts

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