Skip to content

Add GCF as an optional output format alongside TOON #3

Description

@blackwell-systems

Hi 👋 I'm Dayna, creator of GCF (Graph Compact Format). pb_mcp_server already supports MCP_OUTPUT_FORMAT=toon|json, so you clearly care about token cost on tool responses. I'd like to propose GCF as a third opt-in format, and I'm happy to send the PR.

It's a minimal, additive change in src/core/services/output-formatter.ts: extend OutputFormat to "json" | "toon" | "gcf" and add one case that calls encodeGeneric(data). Nothing else changes; JSON stays the default.

I pre-screened GCF against your actual encoders on canonical PocketBase list-records shapes (30 records), measured with cl100k_base, vs the real @toon-format/toon v2 encoder and your pretty-printed JSON default:

Payload JSON default TOON GCF
Flat records 4078 2250 2291
Nested (?expand=category,supplier) 6678 5179 3049
  • Flat lists: GCF and TOON are equivalent (~44% under JSON). No meaningful difference.
  • Expanded relations: GCF is ~41% smaller than TOON and ~54% smaller than JSON. TOON only reaches ~22% under JSON on nested data because it re-declares the nested structure on every row; GCF flattens nested objects into path columns. Since agents expand relations constantly to get context in one call, this is the common case.

Both round-trip losslessly on this data.

For precedent, the official Chrome DevTools MCP server recently added the same default | toon | gcf opt-in (ChromeDevTools/chrome-devtools-mcp).

GCF is MIT, zero runtime dependencies: https://github.com/blackwell-systems/gcf. If you're open to it I'll open a PR against output-formatter.ts. Either way, thanks for building this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions