topicschema

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package topicschema holds MCP event definitions, in the MCP events/list format. A Catalog is built once at startup from the definitions, and is immutable afterwards, so it is safe for concurrent reads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument struct {
	Name string
	// Types is a sorted, non-empty subset of string, number, integer, boolean.
	Types []string
}

Argument describes one subscription argument: a top-level payload property matched by equality.

type Catalog

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

Catalog is the immutable, compiled set of event definitions. It is safe for concurrent use: nothing in it changes after NewCatalog returns, and validating against a compiled schema doesn't modify it. Returned schemas and events share the catalog's memory and must not be modified.

func NewCatalog

func NewCatalog(topics []string, defs Definitions) (*Catalog, error)

NewCatalog validates defs and compiles their schemas. When topics, the TOPICS list, is not empty, every event must be in it. The problems found are reported at once in a *ConfigError, up to 100 of them.

func (*Catalog) Event

func (c *Catalog) Event(name string) (*Event, bool)

Event returns the precomputed events/list entry for name.

func (*Catalog) Events

func (c *Catalog) Events() []*Event

Events returns the events/list entries in configured order.

func (*Catalog) ValidateArguments

func (c *Catalog) ValidateArguments(name string, args []byte) []string

ValidateArguments validates subscription arguments against the event's inputSchema, and refuses any argument it doesn't list. It returns nil when they are valid. Empty args mean no arguments.

type ConfigError

type ConfigError struct {
	Problems []string
}

ConfigError aggregates every problem found in event definition configuration, so a startup failure reports all of them at once.

func (*ConfigError) Error

func (e *ConfigError) Error() string

type Definition

type Definition struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	// InputSchema is a JSON Schema 2020-12 object describing the
	// subscription arguments. Empty means every scalar top-level payload
	// property is an optional argument.
	InputSchema json.RawMessage `json:"inputSchema,omitempty"`
	// PayloadSchema is a JSON Schema 2020-12 document for the event data.
	PayloadSchema json.RawMessage `json:"payloadSchema,omitempty"`
	// Delivery lists the delivery modes; empty means unspecified.
	Delivery []string        `json:"delivery,omitempty"`
	Meta     json.RawMessage `json:"_meta,omitempty"`
}

Definition is one event's definition, as an entry of an events/list result.

type Definitions

type Definitions []Definition

Definitions are the event definitions in configured order.

func ParseDefinitions

func ParseDefinitions(data []byte) (Definitions, error)

ParseDefinitions parses event definitions in the MCP events/list format, a YAML or JSON object with an events list, from a file. Unknown fields and duplicate keys are errors. Schemas are kept as compact JSON in document order. Errors are a *ConfigError naming the event and the JSON pointer of each problem.

func ParseDefinitionsJSON

func ParseDefinitionsJSON(data []byte) (Definitions, error)

ParseDefinitionsJSON parses event definitions from a JSON document, as ParseDefinitions does for YAML.

func ParseDefinitionsNode

func ParseDefinitionsNode(n *yaml.Node) (Definitions, error)

ParseDefinitionsNode parses event definitions from a YAML node, as ParseDefinitions does. Scalars follow the YAML 1.2 core schema, so dates and other timestamps stay strings.

type Event

type Event struct {
	Name        string
	Description string
	InputSchema json.RawMessage
	// PayloadSchema is the payload schema as configured.
	PayloadSchema json.RawMessage
	// JSON is the full entry: name, description, delivery, inputSchema,
	// payloadSchema and _meta.
	JSON json.RawMessage
}

Event is one precomputed events/list entry.

Jump to

Keyboard shortcuts

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