Help us shape the future of Go! Take the 2026 Go Developer Survey

wire

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package wire preserves JSON field order and JavaScript's printable JSON format at tap's CLI and MCP boundaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capture

func Capture(ctx context.Context) (context.Context, *json.RawMessage)

Capture gives one SDK request a slot for its unmodified response JSON.

func Decode

func Decode(data []byte) (any, error)

Decode parses JSON while retaining object property order. Well-formed JSON is read in one pass; anything that pass is not sure of, malformed input included, is read by encoding/json instead, so values and errors are the ones encoding/json gives.

func DecodeExact

func DecodeExact(data []byte) (any, error)

DecodeExact preserves numeric JSON spelling for tool arguments and retained/inline results. Configuration and gateway control fields continue to use Decode's float64 values.

func DecodeExactOwned

func DecodeExactOwned(data []byte) (any, error)

DecodeExactOwned is DecodeExact for data the caller owns and will not change: the strings of the value it returns share data's memory instead of being copied out of it.

func ForwardMeta

func ForwardMeta(meta mcp.Meta) mcp.Meta

ForwardMeta keeps application metadata but removes protocol identity and progress tokens that belong to the current hop; tap does not relay progress notifications.

func JSON

func JSON(value any, pretty bool) ([]byte, error)

JSON encodes JSON without HTML escapes, with optional two-space indentation. Values made of objects, arrays, strings, numbers, booleans and null are written in one pass; any other value is encoded by encoding/json, whose output the pass matches byte for byte.

func Number

func Number(s string) float64

Number parses CLI numbers with JavaScript's whitespace, radix and NaN behavior.

func String

func String(v any) string

String returns JavaScript's String(value) for config interpolation.

func Take

Take is Capture for a response the caller reads only from the slot. The SDK is handed an empty result in its place, so a large one is not decoded a second time into types nobody reads. A slot left empty means the transport does not capture, and the SDK's result is whole.

Types

type Field

type Field struct {
	Name  string
	Value any
}

Field is one named value in an Object.

type Object

type Object []Field

Object retains JavaScript property order: integer keys first, then insertion order.

func (*Object) Delete

func (o *Object) Delete(name string)

Delete removes a property without reordering the remaining properties.

func (Object) Get

func (o Object) Get(name string) any

Get returns a property, or nil when it is absent.

func (Object) Has

func (o Object) Has(name string) bool

Has reports whether a property is present, including a null value.

func (Object) MarshalJSON

func (o Object) MarshalJSON() ([]byte, error)

MarshalJSON encodes an object without sorting its keys, for encoding/json.

func (*Object) Set

func (o *Object) Set(name string, value any)

Set replaces a property in place or inserts it in JavaScript property order.

type Result

type Result struct {
	mcp.ResultBase
	Value any
}

Result carries an already-shaped JSON result through SDK middleware unchanged.

func (*Result) MarshalJSON

func (r *Result) MarshalJSON() ([]byte, error)

MarshalJSON preserves the result's field order and explicit false/null values.

type Transport

type Transport struct{ Base mcp.Transport }

Transport decorates an SDK transport to retain raw responses alongside decoding. It leaves framing, initialization, cancellation and shutdown to the SDK.

func (*Transport) Connect

func (t *Transport) Connect(ctx context.Context) (mcp.Connection, error)

Connect opens the underlying transport and wraps its connection.

Jump to

Keyboard shortcuts

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