events

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package events defines the platform event envelope shared by the MCP gateway, ingest and the processor.

Envelope carries timestamp, trace id, source, event type and a raw JSON payload; NewEnvelope validates required fields. MCPRequest is the typed audit payload for a proxied MCP call.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingFields = errors.New("missing_fields")

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	Timestamp string          `json:"timestamp"`
	TraceID   string          `json:"trace_id,omitempty"`
	Source    string          `json:"source"`
	EventType string          `json:"event_type"`
	Payload   json.RawMessage `json:"payload"`
}

Envelope is the shared platform event transport contract.

func NewEnvelope

func NewEnvelope(source, eventType string, payload any, now time.Time) (Envelope, error)

NewEnvelope builds a transport envelope from a structured payload.

func (*Envelope) EnsureTimestamp

func (e *Envelope) EnsureTimestamp(now time.Time)

EnsureTimestamp fills an empty timestamp with the provided time.

func (*Envelope) SetTraceID

func (e *Envelope) SetTraceID(traceID string)

SetTraceID records the trace ID that can be used to link the stored event row back to the distributed trace.

func (Envelope) TimestampTime

func (e Envelope) TimestampTime(now time.Time) time.Time

TimestampTime parses the transport timestamp, falling back to now on malformed input.

func (Envelope) Validate

func (e Envelope) Validate() error

Validate checks the required event envelope fields.

type MCPRequest

type MCPRequest struct {
	ServerUID               string `json:"server_uid"`
	WouldDeny               bool   `json:"would_deny,omitempty"`
	WouldDenyReason         string `json:"would_deny_reason,omitempty"`
	Idempotency             string `json:"idempotency,omitempty"`
	IdempotencyKeyHash      string `json:"idempotency_key_hash,omitempty"`
	Method                  string `json:"method"`
	Path                    string `json:"path"`
	Status                  int    `json:"status"`
	LatencyMS               int64  `json:"latency_ms"`
	BytesIn                 int64  `json:"bytes_in"`
	BytesOut                int    `json:"bytes_out"`
	Server                  string `json:"server"`
	Namespace               string `json:"namespace"`
	TeamID                  string `json:"team_id"`
	ResourceTeamID          string `json:"resource_team_id"`
	Cluster                 string `json:"cluster"`
	HumanID                 string `json:"human_id"`
	AgentID                 string `json:"agent_id"`
	SubjectTeamID           string `json:"subject_team_id"`
	SessionID               string `json:"session_id"`
	Decision                string `json:"decision"`
	Reason                  string `json:"reason"`
	PolicyVersion           string `json:"policy_version"`
	RPCMethod               string `json:"rpc_method,omitempty"`
	ToolName                string `json:"tool_name,omitempty"`
	AuthDelegation          string `json:"auth_delegation,omitempty"`
	CallerIdentity          string `json:"caller_identity,omitempty"`
	MatchedGrant            string `json:"matched_grant,omitempty"`
	MatchedGrantNamespace   string `json:"matched_grant_namespace,omitempty"`
	MatchedSession          string `json:"matched_session,omitempty"`
	MatchedSessionNamespace string `json:"matched_session_namespace,omitempty"`
	RequiredTrust           string `json:"required_trust,omitempty"`
	RequiredSideEffect      string `json:"required_side_effect,omitempty"`
	RiskLevel               string `json:"risk_level,omitempty"`
	AdminTrust              string `json:"admin_trust,omitempty"`
	ConsentedTrust          string `json:"consented_trust,omitempty"`
	EffectiveTrust          string `json:"effective_trust,omitempty"`
}

MCPRequest is the platform's audit payload for one gateway HTTP exchange. RPCMethod is open to core and extension method names. This is an observation contract, not an MCP protocol message or an implementation of an extension. Deliberately exclude request params, IDs, tokens, queries and raw bodies.

Jump to

Keyboard shortcuts

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