Documentation
¶
Overview ¶
Package rpc contains opt-in JSON-RPC integration. Its resolver must run the host's ordinary authentication/policy; wrapping an unauthenticated handler does not inherit the wrapped handler's private authorization callbacks.
Index ¶
- Variables
- func DecodeHeaderValue(value string) (string, error)
- func EncodeHeaderValue(value string) string
- func HeadersFromContext(ctx context.Context) http.Header
- func ValidRequestID(id any) bool
- func ValidRequestMetadata(params json.RawMessage) bool
- func WithNotificationSink(ctx context.Context, notify func(context.Context, *jsonrpc.Notification) error) context.Context
- type Caller
- type CallerFunc
- type ConsumerError
- type ContextNotifier
- type DecideTool
- type Decision
- type HTTPCaller
- type HTTPHandler
- type Handler
- type OwnerResolver
- type Request
- type SerialNotifier
- type StreamCaller
- type SubscriptionOptions
- type TransportCaller
Constants ¶
This section is empty.
Variables ¶
var ErrStreamProtocol = errors.New("invalid MCP subscription stream")
Functions ¶
func DecodeHeaderValue ¶
func EncodeHeaderValue ¶
EncodeHeaderValue implements the July header sentinel, including escaping a literal sentinel-shaped value. The JSON body remains the source of truth.
func ValidRequestID ¶
ValidRequestID accepts MCP string/integer request IDs without admitting null, booleans, objects or fractional JSON numbers into execution/control routing.
func ValidRequestMetadata ¶
func ValidRequestMetadata(params json.RawMessage) bool
ValidRequestMetadata checks required protocol/capability metadata. ClientInfo is optional in July core and must never serve as authenticated authority. Host decorators must validate it before admitting task-augmented execution.
Types ¶
type CallerFunc ¶
func (CallerFunc) Call ¶
func (f CallerFunc) Call(ctx context.Context, request Request) (json.RawMessage, error)
type ConsumerError ¶
type ConsumerError struct{ Cause error }
func (*ConsumerError) Error ¶
func (e *ConsumerError) Error() string
func (*ConsumerError) Unwrap ¶
func (e *ConsumerError) Unwrap() error
type ContextNotifier ¶
type ContextNotifier struct{}
func (ContextNotifier) Notify ¶
func (ContextNotifier) Notify(ctx context.Context, notification *jsonrpc.Notification) error
type DecideTool ¶
DecideTool is pure planning/policy. It must never start execution. Schedule through the canonical runtime only after its owned task creation is durable.
type Decision ¶
type Decision struct {
Create *tasks.CreateOptions
Required bool
}
type HTTPCaller ¶
type HTTPCaller struct {
HeaderProvider func(context.Context) (http.Header, error)
// contains filtered or unexported fields
}
HTTPCaller is a bounded JSON/SSE request adapter, with no retries or redirects. Configure host authentication through Client.Transport or HeaderProvider.
func NewHTTPCaller ¶
func NewHTTPCaller(endpoint string, client *http.Client) (*HTTPCaller, error)
func (*HTTPCaller) Call ¶
func (c *HTTPCaller) Call(ctx context.Context, request Request) (json.RawMessage, error)
func (*HTTPCaller) Listen ¶
func (c *HTTPCaller) Listen(ctx context.Context, request Request, notify func(json.RawMessage) error) (json.RawMessage, error)
type HTTPHandler ¶
type HTTPHandler struct {
Build func(context.Context, transport.Notifier) transport.Handler
// Present Origin headers are denied by default. Hosts may explicitly admit
// approved web origins; this does not replace request authentication.
AllowOrigin func(string) bool
}
HTTPHandler is a bounded stateless July JSON-RPC/SSE adapter. Host middleware must install authenticated request context before Owner is consulted. Build receives a request-scoped notifier, just like viant/mcp's transport handler factory. Normal methods may delegate to the host's existing handler.
func (HTTPHandler) ServeHTTP ¶
func (h HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Handler ¶
type Handler struct {
Next transport.Handler
Service tasks.Backend
Owner OwnerResolver
Decide DecideTool
Notifier transport.Notifier
Subscriptions *SubscriptionOptions
// contains filtered or unexported fields
}
func (*Handler) OnNotification ¶
func (h *Handler) OnNotification(ctx context.Context, notification *jsonrpc.Notification)
type OwnerResolver ¶
type SerialNotifier ¶
type SerialNotifier struct {
NotifyFunc func(context.Context, *jsonrpc.Notification) error
// contains filtered or unexported fields
}
SerialNotifier prevents interleaved writes when one host transport is shared.
func (*SerialNotifier) Notify ¶
func (s *SerialNotifier) Notify(ctx context.Context, n *jsonrpc.Notification) error
type StreamCaller ¶
type StreamCaller interface {
Listen(context.Context, Request, func(json.RawMessage) error) (json.RawMessage, error)
}
StreamCaller keeps subscriptions/listen open and reports only notifications. A nil error means a correlated graceful complete response was received.
type SubscriptionOptions ¶
type SubscriptionOptions struct {
ReconcileInterval time.Duration
MaxDuration time.Duration
MaxConcurrent int
}
SubscriptionOptions enables the actual notification transport. Nil on Handler means unsupported. ReconcileInterval bounds loss/overflow recovery; MaxDuration bounds resource lifetime and ends with a graceful correlated result.
type TransportCaller ¶
type TransportCaller struct {
Transport transport.Transport
// contains filtered or unexported fields
}
TransportCaller uses a supplied MCP transport. For HTTP, its header provider must consume HeadersFromContext; stdio needs no routing headers. It adds no retry policy and does not change the transport's authentication context.
func (*TransportCaller) Call ¶
func (c *TransportCaller) Call(ctx context.Context, request Request) (json.RawMessage, error)