
Model Shunt
io.github.yasmanycastilloPublished by GitHub account yasmanycastillov1.2.1Updated Oct 24, 2026
Model routing for AI agents: delegate bulk reads & boilerplate to cheap worker models.
The publisher's own server: model.tools — Zero-Auth Agent Utilities
Overview
A local MCP server that routes token-heavy file reading and boilerplate code generation from a coding agent to cheaper or local worker models.
- What you can do
- Discover available worker models and get reader/writer recommendations for a provider, with built-in fallbacks when discovery fails or is unsupported (get_available_models). Read large or multiple files and return concise structured bullets with exact line citations, using map-reduce chunking for oversized corpora (bulk_read). Generate code from a specification and a reference file, either returning it or writing it to a target path and overwriting an existing file (code_write).
- When to use it
- Use it when a coding agent burns context on bulk file reading or repetitive boilerplate such as tests, mocks, stubs and configs, and you want that work delegated to a fast, cheap or local model while the main context stays clean.
- Requirements
- Runs locally over stdio as a Python 3 package (uvx or pip) or via an npm launcher that needs local Python 3. A worker provider must be configured through environment variables such as SHUNT_PROVIDER plus a provider key (GEMINI_API_KEY, GROQ_API_KEY, DEEPSEEK_API_KEY or SHUNT_API_KEY), or a local endpoint such as Ollama via SHUNT_BASE_URL. Network access to the provider is needed unless it is local.
Installation
In SourceWeft
- Open Model Shunt in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
Model-Shunt 🔀
[CI Test Suite] [License: MIT] [Python 3.9+] [Dependencies: 0] [Website Live] [M8ven Score]
A decoupled, zero-dependency, universal implementation of the Shunt model-routing pattern (originally conceived by Spotify Engineering).
Model-Shunt allows AI coding agents (Antigravity, Cursor, Windsurf, Claude Code, Aider, OpenHands, etc.) to delegate token-heavy I/O (bulk file reading/code analysis) and repetitive boilerplate generation (tests, mocks, stubs, configs) to fast, economical, or local worker models (Gemini 2.5 Flash, Groq/Llama, Ollama, DeepSeek, GPT-4o-mini). This cuts primary agent token consumption by up to 90% while keeping the main context window clean.
⚡ Key Highlights
- Zero External Dependencies: Built with pure Python 3 standard library (
urllib,json,re,argparse). Nopip install, no virtual environment, and nonpmrequired. - Agent-Agnostic: Works transparently across any AI coding agent via standard MCP (Model Context Protocol), standalone CLI scripts, or PreToolUse lifecycle hooks.
- Dynamic Model Discovery & Auto-Routing: Queries the worker endpoint in real time to discover available models and automatically routes to the best model for the task:
- Reader Mode (Bulk I/O): Prioritizes massive context windows and ultra-low cost (e.g.,
gemini-2.5-flash,llama-3.3-70b-versatile,gpt-4o-mini). - Writer Mode (Code Generation): Prioritizes specialized coding models (e.g.,
qwen2.5-coder:latest,gemini-2.5-flash,deepseek-chat).
- Reader Mode (Bulk I/O): Prioritizes massive context windows and ultra-low cost (e.g.,
- Bypasses Linux
ARG_MAXLimits: Unlike naive implementations that pass file contents as CLI arguments (capped at ~128 KB on Linux), Model-Shunt streams corpus data overstdin, allowing analysis of hundreds of thousands of lines without buffer overflows. - Deterministic Line Numbering (
N|): Automatically prefixes every line in file blocks with its 1-based index, forcing worker models to cite verifiable, exact line numbers instead of hallucinating locations. - Binary File Protection: Inspects byte headers to reject binary files (PDFs, images, compiled objects) before sending them to the LLM.
- Network Resilience: Automatic exponential backoff retries for rate limits (HTTP 429) and transient server errors (HTTP 503/502), with configurable timeouts and token limits.
- Map-Reduce for Oversized Corpora: When a
bulk_readpayload exceeds the direct limit (SHUNT_MAX_DIRECT_TOKENS, default ~200k tokens), Model-Shunt automatically splits the corpus into chunks, maps the question over each chunk (preserving absoluteN|line numbers), and reduces the extracts into one cited answer. Giant single-line files (minified JSON/JS) are sliced by characters with explicit position markers. Rate-limit pacing waits out provider quota windows instead of failing.
📁 Repository Structure
⚙️ Configuration
Configure your worker model via environment variables or a config.json file (placed in ~/.config/model-shunt/config.json or in the project root):
Using config.json
Tip: Setting
"model": "auto"(or passing--auto-modelin the CLI) will automatically inspect the provider's active models and pick the optimal one for reading vs writing.
Security: Do not put your API key in
config.json— use environment variables instead (e.g.GEMINI_API_KEY,GROQ_API_KEY, orSHUNT_API_KEY). Anapi_keyfield exists as a last-resort fallback, but keeping secrets out of files is strongly recommended.
Using Environment Variables
🛠️ Usage Modes
Mode 1: Universal MCP Server (Recommended)
Model-Shunt provides a standard stdio MCP server exposing three tools:
get_available_models(provider?): Queries the provider endpoint and recommends reader and writer models. If discovery fails or is unsupported, returns built-in recommendations whose current availability is not verified.bulk_read(question, file_paths, model?, provider?): Reads large or multiple files and outputs concise, structured bullets with exact line citations. A citationname (N|k)is dropped when source linekdoes not contain that name.code_write(spec, reference_path, target_path?, model?, provider?): Generates code using a specification and reference file. Returns the code whentarget_pathis omitted; otherwise creates missing parent directories and writes the code, overwriting an existing target file.
bulk_read sends the selected files and question to the configured worker provider; code_write sends the specification and reference file. The provider can be remote or local (such as Ollama). Token savings depend on the input and response.
The MCP server runs locally over stdio. Set provider credentials through environment variables. File access follows resolved paths, so symlinks pointing outside the allowed workspace roots are rejected. Invalid requests return structured errors and leave the server available for subsequent calls.
Installation
MCP Registry name: mcp-name: io.github.yasmanycastillo/model-shunt
Universal one-liner (detects uv / pip / pipx / npm, installs the model-shunt command, and registers it with Claude Code if present):
Manual alternatives:
Any MCP client (Cursor, Windsurf, Antigravity, Claude Desktop, etc.) — add to its MCP settings. No clone, no absolute paths:
Fallback (offline / no uv / no npx): run straight from a clone with Python 3.9+ — replace
"command"/"args"with"command": "python3", "args": ["/absolute/path/to/model-shunt/src/model_shunt/server.py"].
Security: by default
bulk_read/code_writeonly operate on files inside the server's working directory (the agent workspace). SetSHUNT_ALLOWED_ROOTS(PATH-style list) to expand the sandbox.
Map-Reduce Tuning (optional)
Mode 2: PreToolUse Interceptor Hooks
For agents supporting pre-execution hooks (e.g., Claude Code, custom agent loops):
- File Read Interceptor (
check-file-size):- If the agent attempts a whole-file read on a file exceeding the threshold (default: 350 lines, configurable via
SHUNT_MIN_LINES), the hook blocks the call and instructs the agent to delegate tobulk-read. - Targeted reads with
offsetandlimitare allowed, preserving surgical context for code editing.
- If the agent attempts a whole-file read on a file exceeding the threshold (default: 350 lines, configurable via
- Terminal Guard (
check-bash-read):- Prevents agents from bypassing the read hook by executing commands like
cat,less, ormoreon large files directly in the terminal context.
- Prevents agents from bypassing the read hook by executing commands like
Mode 3: Standalone CLI & Scripts
You can also use Model-Shunt directly from the command line or from agent bash sessions:
Discover Available Models & Recommendations
Run Bulk Reading Analysis
Generate Boilerplate Directly to Disk
🧪 Verification
Run the built-in test suite to verify your environment:
The test suite validates:
- Configuration resolution, fallback cascades, and model selection.
- Binary file detection and rejection.
- Hook decisions (surgical reads allowed, large file reads blocked, bash flag parsing).
- MCP stdio protocol compliance and tool execution.
- CLI discovery flags.
📄 License
MIT. Inspired by Spotify Engineering's Shunt architecture.
🔒 Privacy
See PRIVACY.md for filesystem scope, provider data handling, and credential practices.
Source: README.md at commit 8cf822d
Tools
0Version history
2- v1.2.1LatestSep 24, 2026
- v1.1.1Sep 23, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts
Other Model integrations

model.tools — Zero-Auth Agent Utilities
tools.modelOfficial publisher
Zero-auth remote utility server giving agents disposable email OTP reading, durable checkpoints, webhook bins, wake timers, receipts and page-to-Markdown…
NLP.COM.AI Open Model Catalog
ai.com.nlpOfficial publisher
NLP.COM.AI Open Model Catalog's hosted MCP server, published by nlp.com.ai; no sign-in required; Streamable HTTP; 3 tools.

Hologram Model Hub
foundation.uor.hubOfficial publisher
A remote MCP server that lets an assistant search an index of open models and get verified download links with SHA-256 checksums.

ModelLens
Published by GitHub account Greatbeing
Probes OpenAI-compatible model gateways, ranks models by measured latency and success, and recommends which model to use.

Bedrock Multi-Model
Published by GitHub account Sagargupta16
Local MCP server that puts AWS Bedrock's text, image, video and embedding models behind nine tools so an assistant can ask, compare and judge models.