Overview of Parsing Utilities (`utils/parsing`)
mainThe @cyanheads/mcp-ts-core/utils module provides a suite of Tier 3 parsers for common data formats. These parsers are lazy-loaded on first call to minimize initial bundle size.
Common Behaviors
- Async by default: All methods are
asyncunless explicitly noted as synchronous. - Automatic
<think>stripping: Parsers automatically strip<think>...</think>blocks from the start of input and log them atdebuglevel (exceptdateParserandpdfParser). - Optional Context: The
context?parameter is optional and accepts either aContexthandler or aRequestContextbag. - Input Budgets: Parsers are unbounded by default. To prevent memory issues, pass
maxBytesto reject inputs exceeding the limit. This throws aValidationErrorwithreason: 'parser_input_too_large'. UseDEFAULT_TEXT_PARSER_MAX_BYTES(1 MiB) orDEFAULT_BINARY_PARSER_MAX_BYTES(25 MiB) as reference values. - Error Handling: Errors throw
McpError. The error message follows the pattern<summary>: <library message>. Thedatafield contains{ reason }, while the original stack and input sample are preserved on thecauseproperty.
import { yamlParser, xmlParser, csvParser, jsonParser, pdfParser, dateParser, frontmatterParser } from '@cyanheads/mcp-ts-core/utils';