Skip to main content

Overview

Response adapters parse non-standard MCP tool output into structured rows for Parquet staging. They are used with fetch_mode: mcp_client when a tool returns output that isn’t plain JSON, CSV, or NDJSON. Adapters are selected via the response_adapter field in binding.yaml:

Built-in Formats vs Adapters

There are two tiers of response handling: Tier 1: Built-in formats (response_format) — generic, well-defined grammars: Tier 2: Tool-specific adapters (response_adapter) — registered parsers for non-standard output: response_format and response_adapter are mutually exclusive.

The TabularText Adapter

The tabular_text adapter handles vendor Query output, which returns human-readable text rather than structured data. It auto-detects between two output formats:

Format A: Pipe-delimited

  • Columns: line defines pipe-separated header names
  • --- separator marks the start of data rows
  • Each data row uses | as the delimiter

Format B: Python-list literals

  • Column Names: line defines comma-separated header names
  • Row N: lines contain Python-style list literals
  • Quoted values handle commas ('Doe, Jane') and escaped quotes ('O\'Brien')
Format detection: If any line starts with Column Names:, format B is used. Otherwise, format A.

Binding example

Writing a Custom Adapter

Function signature

  • text — the raw response body from the MCP tool
  • fields — column metadata from the contract (source name, column name, type)
  • Returns a slice of row maps (column name → value) or an error

Registration

Register your adapter in internal/loaders/response_adapters.go:

Registration API

Guidelines

  1. Return source field names — the staging layer handles field_map remapping. Your adapter should return keys matching the raw tool output, not the contract column names.
  2. All values as strings are fine — the Parquet writer coerces types based on the contract’s column type definitions.
  3. Return clear errors — include enough context to diagnose the problem (e.g., “tabular_text: could not find column headers”).
  4. Test both happy path and malformed input — adapters are the boundary between unpredictable tool output and the structured staging layer.

Interaction with Pagination

Response adapters work with offset-mode pagination. Each page is parsed independently through the adapter. Cursor-mode pagination is incompatible with adapters — cursor extraction requires a JSON envelope, which adapter-parsed responses don’t provide. Configuring pagination.mode: cursor with a response_adapter produces an error at runtime.

Interaction with Fetch Modes

Only mcp_client uses response_format and response_adapter. Other fetch modes ignore these fields.