chunk-your-tools 2.0.3

MCP tool schema decomposition and recomposition
Documentation
# Examples

Two independent example tracks live under `examples/`:

| Track | Purpose | Entry point |
| --- | --- | --- |
| **CLI decompose/recompose** | Split MCP tool schemas into chunks and rebuild pruned definitions | `decompose.sh`, `recompose.sh` (below) |
| **Go SDK git smoke** | Verify the Go SDK links from a git tag checkout outside the monorepo | [`go-git-smoke/`]go-git-smoke/ — see [go-git-smoke/README.md]go-git-smoke/README.md |

---

## CLI: decompose and recompose

Runnable scripts and fixtures for the `chunk-your-tools` CLI.

### Quick start

From the repo root (or from `examples/`):

```bash
./examples/decompose.sh    # build catalog under examples/catalog/
./examples/recompose.sh    # write pruned tools under examples/output/
```

Both scripts use a release `chunk-your-tools` binary when available (`cargo install`
or `target/release/chunk-your-tools`), otherwise they build the CLI from source.

### `decompose.sh`

Splits `examples/input/tools.json` into addressable chunks under
`examples/catalog/schemas/decomposed/`:

- one JSON file per tool (`Agent.json`, `mcp__github__create_issue.json`, …)
- optional property chunks per tool (`Agent/model.json`, …)
- enum value chunks as Markdown (`opus.md`, `haiku.md`, …)
- `metadata.json` with catalog index

Equivalent CLI:

```bash
chunk-your-tools decompose \
  --input examples/input/tools.json \
  --output examples/catalog
```

### `recompose.sh`

Requires a prior `decompose.sh` run. Reads survivor lists and writes several
recomposed tool JSON files to `examples/output/`:

| Output | What it demonstrates |
| --- | --- |
| `named.json` | Semantic survivors (`survivors-named.json`) + on-disk catalog |
| `agent-only.json` | Subset of tools/properties/enums |
| `legacy.json` | Legacy `{json, md}` chunk lists (`survivors-legacy.json`) |
| `legacy-with-policies.json` | Legacy survivors + `--system-policy` / `--mcp-policy` / `--tool-policy` |
| `named-from-input.json` | In-memory decompose via `--input` (no catalog dir) |
| `legacy-all-mcp.json` | Force all tools to MCP type + policies |
| `legacy-all-system.json` | Force all tools to system type + policies |

Equivalent CLI (catalog-based):

```bash
chunk-your-tools recompose \
  --catalog-dir examples/catalog \
  --survivors examples/input/survivors-named.json \
  --output examples/output/named.json
```

In-memory recompose (no catalog directory):

```bash
chunk-your-tools recompose \
  --input examples/input/tools.json \
  --survivors examples/input/survivors-named.json \
  --output examples/output/named-from-input.json
```

### Survivors format

### Semantic names (recommended)

```json
{
  "tools": ["mcp__github__create_issue", "Agent"],
  "properties": {
    "Agent": ["model", "optional_field"],
    "mcp__github__create_issue": ["title"]
  },
  "enums": ["opus", "haiku", "Bash"]
}
```

- `tools` — tool IDs/names to keep (omitted tools are dropped)
- `properties` — per-tool optional property names (required properties always survive;
  use dotted paths for nested optionals, e.g. `"config.timeout"`)
- `enums` — enum value names to keep

See `examples/input/survivors-named.json` for the fixture used by `recompose.sh`.

### Legacy chunk lists

`examples/input/survivors-legacy.json` uses `{json, md}` file-path lists compatible with
[clear-your-tools](https://github.com/qdrddr/clear-your-tools) pruners.

### Input fixtures

| Path | Purpose |
| --- | --- |
| `input/tools.json` | Small MCP + system tool sample |
| `input/tools-large.json` | Larger fixture for stress tests |
| `input/survivors-named.json` | Semantic survivor list |
| `input/survivors-legacy.json` | Legacy chunk survivor list |
| `catalog/` | Decomposed catalog (generated by `decompose.sh`) |
| `output/` | Recomposed tool JSON (generated by `recompose.sh`) |

Go SDK git smoke test: [go-git-smoke/README.md](go-git-smoke/README.md).

---

## Library usage (Rust)

```rust
use chunk_your_tools::{
    NamedSurvivors, PolicyContext, build_catalog_from_tools, recompose_tools_from_names,
};
use serde_json::json;

let tools = vec![/* MCP tool definitions */];
let survivors = NamedSurvivors::from_value(&json!({
    "tools": ["Agent"],
    "properties": { "Agent": ["model"] },
    "enums": ["opus"]
})).unwrap();
let ctx = PolicyContext::new();
let recomposed = recompose_tools_from_names(&tools, &survivors, &ctx);
```

Language SDKs: see the [SDK table](../README.md#sdks) in the root README.