# chunk-invariance

Tests streaming filters for secrets split across chunks and can create a pytest regression test when a split breaks the result.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 13
- Author: ninadphalak
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/ninadphalak/LLM-Shield-Proxy/tree/HEAD/chunk-invariance
- Updated: 2026-10-19
- HTML: https://affpapa.org/en/nevibecode/mcp/chunk-invariance

## What it does

chunk-invariance compares a filter’s whole-input result with the output produced after feeding the same text in chunks. It tries the requested splits, reports the first mismatch, and shows the input, chunk list, expected output, and streamed output. The API handles `str`, `bytes`, and async generator filters.

Its MCP server exposes `check_stream_filter`, `write_regression_test`, and `explain`. It imports a function from your module, runs it in a separate process with a timeout, and can return a pytest file built around `assert_chunk_invariant`. The server makes no network calls and writes no files by itself. Use invented samples only: leaked values and test samples are included in tool results and generated tests, then sent with the conversation to the model provider.

## Requirements
- Needs: Python and uv (commands run via uvx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add chunk-invariance -- uvx chunk-invariance
```
uvx runs the command named after the package; if the README names another one, use uvx --from chunk-invariance <command>

### Codex

**Platform CLI**
```bash
codex mcp add chunk-invariance -- uvx chunk-invariance
```
uvx runs the command named after the package; if the README names another one, use uvx --from chunk-invariance <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "chunk-invariance": {
            "command": "uvx",
            "args": [
                "chunk-invariance"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from chunk-invariance <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "chunk-invariance": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "chunk-invariance"
            ]
        }
    }
}
```
uvx runs the command named after the package; if the README names another one, use uvx --from chunk-invariance <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add chunk-invariance uvx chunk-invariance
```
uvx runs the command named after the package; if the README names another one, use uvx --from chunk-invariance <command>

## When to use it
- detect secrets split between streamed chunks
- compare whole-input and streaming filter output
- catch short carryover buffers and missing end flushes
- generate a regression test for CI

## Example prompts
- Check whether `redact_stream` in `myapp/filters.py` leaks values across chunk boundaries, then create a regression test.
- Run the check on made-up API-key samples for `redact_stream`.
- Explain why filtering each chunk independently can expose a secret.

## Similar
- [test-master](https://affpapa.org/en/nevibecode/skills/test-master.md) — skill · 5300 installs
- [assertion-quality](https://affpapa.org/en/nevibecode/skills/assertion-quality.md) — skill · 3600 installs
- [test-analysis-extensions](https://affpapa.org/en/nevibecode/skills/test-analysis-extensions.md) — skill · 3100 installs
- [deepeval](https://affpapa.org/en/nevibecode/skills/deepeval.md) — skill · 2800 installs
- [ai-test-generation](https://affpapa.org/en/nevibecode/skills/ai-test-generation.md) — skill · 1200 installs
- [unit-testing](https://affpapa.org/en/nevibecode/skills/unit-testing.md) — skill · 1100 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
