@aashari/boilerplate-mcp-server
Version:
TypeScript MCP server boilerplate with STDIO and HTTP transport support, CLI tools, and extensible architecture
32 lines (31 loc) • 1.19 kB
TypeScript
/**
* Convert data to TOON format with JSON fallback.
*
* TOON (Token-Oriented Object Notation) is 30-60% more token-efficient than JSON
* for tabular data, making it ideal for LLM responses.
*
* @param data - The data to convert
* @param jsonFallback - JSON string to return if TOON encoding fails
* @returns TOON formatted string, or JSON fallback on failure
*
* @example
* const json = JSON.stringify(data, null, 2);
* const output = await toToonOrJson(data, json);
*/
export declare function toToonOrJson(data: unknown, jsonFallback: string): Promise<string>;
/**
* Synchronous TOON conversion with JSON fallback.
*
* Uses cached encoder if available, otherwise returns JSON fallback.
* Prefer toToonOrJson for first-time conversion.
*
* @param data - The data to convert
* @param jsonFallback - The JSON string to return if TOON is unavailable
* @returns TOON formatted string, or JSON fallback
*/
export declare function toToonOrJsonSync(data: unknown, jsonFallback: string): string;
/**
* Pre-load the TOON encoder for synchronous usage later.
* Call this during server initialization.
*/
export declare function preloadToonEncoder(): Promise<boolean>;