framework

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package framework provides a lightweight scenario runner used by the integration tests to launch the example server and exercise MCP scenarios.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SupportsCLI

func SupportsCLI() bool

SupportsCLI reports whether CLI-based scenarios can run.

func SupportsServer

func SupportsServer() bool

SupportsServer reports whether the integration framework can reach a server.

Types

type Defaults

type Defaults struct {
	Client     string            `yaml:"client"`      // e.g., "jsonrpc.mcp_assistant" (hint to pick generated client)
	Headers    map[string]string `yaml:"headers"`     // default headers for all steps
	ClientMode string            `yaml:"client_mode"` // http | cli (optional)
}

Defaults apply to steps when not explicitly set in a step.

type Expect

type Expect struct {
	Status string         `yaml:"status"` // success | error | no_response
	Error  *ExpectedError `yaml:"error"`
	Result map[string]any `yaml:"result"`
}

Expect describes non-streaming expectations.

type ExpectRetry

type ExpectRetry struct {
	PromptContains string   `yaml:"prompt_contains"`
	Contains       []string `yaml:"contains"`
}

ExpectRetry describes retry expectations for generated client mode

type ExpectedError

type ExpectedError struct {
	Code    int    `yaml:"code"`
	Message string `yaml:"message"`
}

ExpectedError captures expected JSON-RPC error.

type Pre

type Pre struct {
	AutoInitialize *bool `yaml:"auto_initialize"` // default true
}

Pre controls scenario-level behavior (e.g., auto-initialize handshake).

type Runner

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

Runner runs scenarios against the generated example server.

func NewRunner

func NewRunner() *Runner

NewRunner creates a new runner with fixed timeout.

func (*Runner) Run

func (r *Runner) Run(t *testing.T, scenarios []Scenario) error

Run executes the scenarios in a single managed-server session.

type Scenario

type Scenario struct {
	Name     string    `yaml:"name"`
	Defaults *Defaults `yaml:"defaults"`
	Pre      *Pre      `yaml:"pre"`
	Steps    []Step    `yaml:"steps"`
}

Scenario models a test scenario (new multi-step form only).

func LoadScenarios

func LoadScenarios(path string) ([]Scenario, error)

LoadScenarios loads scenarios from a YAML file path.

type Step

type Step struct {
	Name         string            `yaml:"name"`
	Client       string            `yaml:"client"`       // overrides defaults.client
	Op           string            `yaml:"op"`           // generated endpoint method name, e.g., "ToolsCall"
	Input        map[string]any    `yaml:"input"`        // maps to payload fields
	Headers      map[string]string `yaml:"headers"`      // per-step headers (e.g., Accept)
	Notification bool              `yaml:"notification"` // send as JSON-RPC notification (no id)
	Expect       *Expect           `yaml:"expect"`
	StreamExpect *StreamExpect     `yaml:"stream_expect"`
	ExpectRetry  *ExpectRetry      `yaml:"expect_retry"` // generated client retry expectation
}

Step defines a single operation invocation using a generated client.

type StreamEventExp

type StreamEventExp struct {
	Event string         `yaml:"event"`
	Data  map[string]any `yaml:"data"`
}

StreamEventExp matches SSE event/data partially.

type StreamExpect

type StreamExpect struct {
	MinEvents int              `yaml:"min_events"`
	TimeoutMS int              `yaml:"timeout_ms"`
	Events    []StreamEventExp `yaml:"events"`
}

StreamExpect describes streaming expectations.

Jump to

Keyboard shortcuts

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