Skip to main content
Glama
Guffy MCP Server

Guffy MCP Server

by r33n3
README.md
<div align="center">
  <img src="docs/assets/guffy-banner.png" alt="Guffy — Dissect. Trace. Understand." width="100%">

  <h3>Open model reverse engineering &amp; dynamic debugging</h3>

  <a href="https://github.com/r33n3/Guffy/actions/workflows/test.yml"><img src="https://github.com/r33n3/Guffy/actions/workflows/test.yml/badge.svg" alt="Linux toolkit CI"></a>
  <a href="https://github.com/r33n3/Guffy/releases"><img src="https://img.shields.io/github/v/release/r33n3/Guffy?color=00a8b5" alt="Latest release"></a>
  <a href="pyproject.toml"><img src="https://img.shields.io/badge/Python-3.11%2B-09283a" alt="Python 3.11+"></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-f29329" alt="Apache 2.0"></a>

  <p><a href="#install">Install</a> · <a href="#first-investigation">First investigation</a> · <a href="#connect-an-ai-agent">MCP</a> · <a href="#documentation">Documentation</a></p>
</div>

Guffy brings the exploratory workflow of a reverse-engineering debugger to GGUF models. Inspect an unfamiliar artifact, find something interesting, select a tensor, observe real computations, stop generation at a token boundary, and preserve your findings.

**Linux / WSL2 · GGUF · llama.cpp / GGML · CPU · CLI, REPL & MCP**

## Install

The release installer includes the native worker. Requires **Linux x86_64 with AVX2/FMA/F16C/BMI2 and Python 3.11+**. On Ubuntu 24.04 / WSL Ubuntu, install prerequisites once:

```bash
sudo apt-get install python3-venv curl libgomp1
```

Then install Guffy without root:

```bash
curl -fsSL https://raw.githubusercontent.com/r33n3/Guffy/v0.3.0/scripts/install.sh -o install-guffy.sh
bash install-guffy.sh
guffy --help
```

The installer verifies the release checksum, creates `~/.local/share/guffy/0.3.0` and links `~/.local/bin/guffy`. Add `~/.local/bin` to PATH if prompted. Existing environments and unrelated commands are preserved. **No models are downloaded or included.** Python dependencies come from your configured package index.

Installation displays a read-only system check. Before loading a model, estimate its debugging costs:

```bash
guffy doctor
guffy --context 256 doctor /models/model.gguf --tokens 4
```

The report covers available RAM/cgroup limits, disk, CPU/worker setup, estimated context memory and full-logit trace storage. It distinguishes estimates from guaranteed fit; the 8 GiB default worker ceiling is not reserved RAM. See [resource planning and small-model examples](docs/resources.md).

Prefer manual installation? Download the [Linux bundle and SHA256SUMS](https://github.com/r33n3/Guffy/releases), verify the checksum, extract, then run `bash install.sh /new/environment/path`. A Python wheel alone needs the native worker separately for inference. See [installation details](docs/installation.md) for source builds, offline bundles, upgrades and troubleshooting.

## First investigation

<img src="docs/assets/guffy-icon.png" alt="Guffy pufferfish debugger mascot" align="right" width="130">

Bring a local GGUF and launch the debugger:

```bash
guffy inspect /models/model.gguf
guffy --output-dir research debug /models/model.gguf
```

```text
guffy> strings search "system"
guffy> tensors search "attn"
guffy> select 1
guffy> break token 2
guffy> trace layer 3
guffy> run "Hello world" --tokens 4
guffy> inspect state
guffy> graph --layer 3
guffy> trace summary
guffy> continue
guffy> note "An observation worth revisiting"
guffy> export findings
```

These are commands to run, not fabricated runtime output. The model needs a layer 3 for this trace filter. Token indices start at **1**; a token breakpoint pauses after input evaluation, **before sampling and emitting that token**. Graphs come from actual inference; static GGUF metadata does not contain a complete executable graph.

## What you can investigate

| Workflow | Capabilities |
|---|---|
| **Dissect** | Defensive GGUF parsing, metadata/tokenizer/tensor inspection, streamed hashes, ASCII/UTF-8 and hex search, signature candidates, entropy and region maps |
| **Navigate** | Current selection, history, bookmarks, real runtime operations, inputs/consumers, focused graph traversal, DOT/JSON export |
| **Trace** | Layer/tensor/op/token filters; min/max, mean, standard deviation, L2, NaN/Inf; optional bounded logical values; full vocabulary logits |
| **Control** | Genuine token breakpoints, token stepping, continue, termination and independent repeat runs with greedy or seeded sampling |
| **Intervene** | Force the next token; set/add/mask a current logit while paused; inspect raw/effective logits; reset pending edits; replay recorded interventions from a fresh context |
| **Compare** | Earliest observed divergence, numeric tolerances, compatibility checks and explicit distinction between statistics and captured values |
| **Preserve** | Local investigations, notes, trace configuration, execution provenance and reproducible exports with SHA-256 inventories |

## Connect an AI agent

Guffy's official Python MCP server exposes the same services as the CLI over **stdio**:

```bash
GUFFY_MODEL_DIRS=/models GUFFY_OUTPUT_DIR=/research guffy mcp serve
```

Use explicit model/output allowlists. [Codex and other client configurations](examples/mcp-clients.md) cover inspection, selection, tracing, token breakpoints, execution and export. No shell tool or unauthenticated network listener is exposed.

## Validation and boundaries

Real CPU CLI/MCP workflows have been exercised with **TinyStories, SmolLM2-135M, GPT-2 and Qwen2.5-0.5B**, including multiple quantizations, different vocabularies, paused-state inspection, multi-batch prompts and exports. [Measured evidence](docs/release-readiness.md) records the models, hashes, requests and results. CI runs Python 3.11/3.12, native, installer and containment tests; release validation additionally downloads explicitly pinned small HF fixtures.

Token-boundary sampling interventions and fresh-context replay work. Layer/operation observation works. Layer/operation suspension, arbitrary operation stepping, activation/weight mutation, live KV checkpoints, GPU execution and additional model formats remain unsupported. See [intervention workflows](docs/interventions.md) and the [scope matrix](docs/toolkit-status.md).

At a token pause, for example:

```text
guffy> logits --view raw --top 10
guffy> patch logit 42 add 10
guffy> logits --view effective --top 10
guffy> patch reset
guffy> force token 42
guffy> step
```

IDs are model-specific. Edits affect the current prediction only and are recorded alongside actual sampling decisions. The source GGUF stays read-only. `replay TRACE.jsonl` starts a fresh compatible execution; `diff BASELINE MODIFIED --mode intervention` explicitly compares experimental runs.

For optional worker filesystem/network restrictions, install `bubblewrap` and use `guffy --isolation bubblewrap debug /models/model.gguf`. Isolation fails closed and does not replace a disposable VM for suspicious artifacts. Read [SECURITY.md](SECURITY.md).

## Build from source

Requires Python 3.11+, Git, CMake 3.20+, Ninja and a C++17 compiler:

```bash
git clone https://github.com/r33n3/Guffy.git
cd Guffy
bash scripts/bootstrap.sh
source .venv/bin/activate
guffy --help
```

The bootstrap script fetches the pinned llama.cpp **source dependency**, builds the native worker, and installs Python dependencies. It acquires no models. On Windows, run inside WSL Ubuntu.

## Documentation

[Installation](docs/installation.md) · [Command reference](docs/usage.md) · [Architecture](ARCHITECTURE.md) · [Upstream instrumentation](docs/upstream.md) · [Release validation](docs/github-release.md) · [MCP examples](examples/mcp-clients.md) · [Brand assets](docs/assets/README.md)

Guffy source is **Apache-2.0**. Dependencies and model weights retain their own licenses; see [THIRD_PARTY.md](THIRD_PARTY.md). Models, research output and local build artifacts are excluded from the repository.