format

package
v0.1.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package format provides output format conversion for MCP tool call results. Supported formats: TOON (Token-Oriented Object Notation), CSV, JSON, and text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(data any, formatName string) (string, error)

Format converts a parsed JSON value to the specified output format. Supported formats: "json" (compact), "toon" (TOON v3.0), "csv" (RFC 4180), "text" (passthrough). Returns an error for unsupported formats or conversion failures.

func ToCSV

func ToCSV(data any) (string, error)

ToCSV converts a parsed JSON value to CSV format. The input must be an array of objects ([]any of map[string]any). Headers are derived from the first object's keys in sorted order. Returns an error if the data is not tabular.

func ToTOON

func ToTOON(data any) (string, error)

ToTOON converts a parsed JSON value to TOON v3.0 notation. TOON is a compact, LLM-readable format that reduces token consumption compared to JSON while preserving structural information.

Types

This section is empty.

Jump to

Keyboard shortcuts

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