Skip to main content

Crate gcf

Crate gcf 

Source
Expand description

GCF (Graph Compact Format) encoder and decoder for Rust.

GCF is a compact, text-only, graph-native wire format designed for MCP tool responses. It exploits referential identity (local IDs), graph topology (edges as references), and hierarchical grouping (distance-based sections) to achieve significant token savings over JSON while remaining human-readable.

Specification: https://github.com/blackwell-systems/gcf

§Quick Start

use gcf::{Payload, Symbol, Edge, encode, decode};

let p = Payload {
    tool: "context_for_task".to_string(),
    token_budget: 5000,
    tokens_used: 1847,
    pack_root: String::new(),
    symbols: vec![
        Symbol {
            qualified_name: "pkg.AuthMiddleware".to_string(),
            kind: "function".to_string(),
            score: 0.78,
            provenance: "lsp_resolved".to_string(),
            distance: 0,
            signature: String::new(),
            components: Default::default(),
        },
    ],
    edges: vec![],
};

let output = encode(&p);
let decoded = decode(&output).unwrap();
assert_eq!(decoded.tool, "context_for_task");

Re-exports§

pub use decode::decode;
pub use decode::DecodeError;
pub use decode_generic::decode_generic;
pub use delta::encode_delta;
pub use encode::encode;
pub use generic::encode_generic;
pub use session::encode_with_session;
pub use session::Session;
pub use stream::StreamEncoder;
pub use stream::StreamOptions;
pub use stream_generic::GenericStreamEncoder;
pub use types::Components;
pub use types::DeltaPayload;
pub use types::Edge;
pub use types::Payload;
pub use types::Symbol;

Modules§

decode
decode_generic
delta
encode
generic
session
stream
stream_generic
types

Functions§

kind_abbrev
Returns the GCF abbreviation for a kind, or the original string if no abbreviation exists.
kind_expand
Returns the expanded kind for a GCF abbreviation, or the original string if not recognized.