chunk-invariance — Claude Code MCP server: setup and checks
Tests streaming filters for secrets split across chunks and can create a pytest regression test when a split breaks the result.
claude mcp add chunk-invariance -- uvx chunk-invarianceWhat chunk-invariance 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.
What it helps with
- 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 for the agent
- Check whether
redact_streaminmyapp/filters.pyleaks 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.
How to install chunk-invariance
Platform CLI
claude mcp add chunk-invariance -- uvx chunk-invarianceuvx runs the command named after the package; if the README names another one, use uvx --from chunk-invariance <command>
Platform CLI
codex mcp add chunk-invariance -- uvx chunk-invarianceuvx runs the command named after the package; if the README names another one, use uvx --from chunk-invariance <command>
Config file
{
"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>
Config file
{
"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>
Platform CLI
gemini mcp add chunk-invariance uvx chunk-invarianceuvx runs the command named after the package; if the README names another one, use uvx --from chunk-invariance <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about chunk-invariance
How do I install chunk-invariance in Claude Code?
Run claude mcp add chunk-invariance -- uvx chunk-invariance.
What does chunk-invariance do?
It tests a streaming filter against different input splits and compares the joined stream with whole-input processing. A failure includes the split that caused the mismatch.
Does it test a running gateway?
No. The server calls an in-process function and does not exercise an upstream model, network path, or SSE parser.