Local Worker MCP
Local Worker MCP
Lokaler, client-unabhängiger MCP. Frontier plant, delegiert und überprüft. Local erledigt die schwere, mechanische und überprüfbare Arbeit.
Ziel ist es, den Tokenverbrauch kostenpflichtiger KI zu reduzieren, ohne die Rohdaten in deren Kontext zu laden.
Codex / Claude / Gemini / Grok
│
▼
Local Worker MCP
│
┌──────┴───────────────┐
▼ ▼
Gemma 4 12B QAT arquivos / PDF
via Ollama extração + evidências
│
▼
resultado compacto e verificável
│
▼
Frontier revisaDies ersetzt nicht die Haupt-KI und ist kein Model-Router. Es handelt sich um echte Arbeitsdelegation.
LOCAL DISPONÍVEL? NÃO
│ │
▼ ▼
DELEGA NÃO INSISTE
│ │
▼ ▼
COMPRIME FRONTIER ASSUME
│
▼
FRONTIER REVISAGemma ist eine Optimierung. Sie darf niemals zum Single Point of Failure werden.
Prinzip
Delegieren, wenn die Aufgabe mechanisch, repetitiv, überprüfbar oder kontextintensiv ist: PDF, Logs, CSV, Code, Extraktion, Klassifikation, Zusammenfassung.
In der Frontier belassen: Architekturentscheidungen, Sicherheit, kritische Änderungen, subjektive Beurteilung, mehrdeutige Anforderungen.
Wenn der lokale Worker offline ist, arbeitet die Frontier weiter. Der MCP gibt schnell unavailable zurück und empfiehlt einen Fallback. Der Client kann protokollieren:
Worker local indisponível; executei diretamente.Erfordert keinen Benutzereingriff.
Related MCP server: ollama-handoff
Anforderungen
Python 3.10+
Ollama auf demselben PC oder einem anderen im LAN
Ein lokales Modell (empfohlen: Gemma 4 12B QAT)
Installation
git clone https://github.com/CaioAllgayer/Local-Worker-MCP.git
cd Local-Worker-MCP
python -m pip install -e ".[dev]"
copy .env.example .envOllama + Gemma
Ollama installieren und starten.
Modell herunterladen. Der Name ist nicht fest codiert — verwenden Sie den tatsächlichen Namen in Ihrem
ollama list:
ollama list
ollama pull <nome-real-do-gemma>Wenn
LOCAL_LLM_MODELleer bleibt, versucht der Worker, ein Modell zu erkennen, dessen Namegemmaenthält. Andernfalls wird das erste gelistete Modell verwendet.Endpunkt testen:
curl http://127.0.0.1:11434/api/tags
local-worker statusMCP starten:
local-worker-mcpGleicher PC
LOCAL_LLM_PROVIDER=ollama
LOCAL_LLM_BASE_URL=http://127.0.0.1:11434
LOCAL_LLM_MODEL=local vs. lan wird anhand des Hostnamens erkannt. 127.0.0.1, localhost und ::1 sind lokal.
Notebook mit Desktop
Der Worker geht nicht von localhost aus. Das Backend kann sich auf einem anderen PC im LAN befinden.
Auf dem Notebook:
LOCAL_LLM_PROVIDER=ollama
LOCAL_LLM_BASE_URL=http://192.168.x.x:11434Ersetzen Sie 192.168.x.x durch die aktuelle IP des Desktops (ipconfig unter Windows, ip a unter Linux). Es gibt keine feste IP im Projekt.
Das Verhalten ist dasselbe: Fail-Fast, Circuit Breaker, Cache, Komprimierung.
Auf dem Desktop muss Ollama Verbindungen aus dem LAN akzeptieren (Variable OLLAMA_HOST=0.0.0.0 und Firewall, die Port 11434 freigibt).
OpenAI-kompatibel
LM Studio, llama.cpp server, vLLM und ähnliche:
LOCAL_LLM_PROVIDER=openai_compatible
LOCAL_LLM_BASE_URL=http://127.0.0.1:1234/v1
LOCAL_LLM_MODEL=...
LOCAL_LLM_API_KEY=Fail-Fast und Circuit Breaker
Standardeinstellungen:
LOCAL_LLM_CONNECT_TIMEOUT_SECONDS=2
LOCAL_LLM_REQUEST_TIMEOUT_SECONDS=45
LOCAL_LLM_MAX_RETRIES=0
LOCAL_LLM_CIRCUIT_BREAKER_FAILURES=2
LOCAL_LLM_CIRCUIT_BREAKER_COOLDOWN_SECONDS=60Verweigerte Verbindung wird nicht wiederholt. Nach N Fehlern öffnet sich der Stromkreis und die nächsten Aufrufe geben sofort unavailable zurück. Nach der Abkühlphase ist ein Versuch erlaubt.
{
"status": "unavailable",
"fallback_recommended": true,
"reason": "Local LLM endpoint unreachable"
}MCP-Tools
Tool | Funktion |
| Provider, Endpunkt, lokal/LAN, Latenz, Modell, Circuit Breaker, Cache |
| generische Aufgabe → kompaktes JSON |
| unabhängige Aufgaben parallel ( |
| TXT, Markdown, CSV, JSON, Code, Logs |
| Extraktion pro Seite, Chunking, hierarchische Synthese, Belege |
| Größe, Einträge, Treffer, Fehltreffer, Trefferquote, Abgelaufen |
| GC jetzt (TTL → nicht wiederverwendet → LRU) |
| löscht verwertbare Einträge |
Der rohe Dateiinhalt muss nicht in den Kontext der kostenpflichtigen KI gelangen. Der Worker liest, komprimiert und gibt überprüfbare Belege zurück (Seite, Zeile, Ausschnitt).
Sicherheit
Standard: SECURITY_MODE=READ_ONLY, ENABLE_SHELL=false.
SECURITY_MODE=READ_ONLY
ALLOWED_PATHS=C:\Projects,D:\Research
ENABLE_SHELL=falseREAD_ONLY— nur Lesen in autorisierten Pfaden; Schreiben und Shell blockiertWORKSPACE_WRITE— Lesen/Schreiben in autorisierten Pfaden; Shell nur wennENABLE_SHELL=trueFULL_LOCAL— großzügiger; blockiert dennoch destruktive Befehle
Path Traversal wird blockiert. rm, del, format usw. werden abgelehnt.
Cache und Logs
Persistenter Cache in ~/.local-worker-mcp/cache, selbstreinigend:
CACHE_TTL_DAYS=30
CACHE_MAX_SIZE_GB=10
CACHE_CLEANUP_THRESHOLD_PERCENT=90
CACHE_TARGET_USAGE_PERCENT=80
CACHE_CLEANUP_INTERVAL_HOURS=6Einträge sind standardmäßig verwertbar. persistent=true bewahrt wichtige Artefakte.
Logs rotieren und verfallen:
LOG_RETENTION_DAYS=14
LOG_MAX_SIZE_MB=250Das Log speichert nicht den vollständigen Dateiinhalt.
Benchmark
local-worker benchmark arquivo.pdfAusgabe:
Arquivo: arquivo.pdf
Worker: gemma4:12b-qat
Backend: ollama
Endpoint: LAN/local
Tamanho: ...
Tokens originais estimados: ...
Tokens processados localmente: ...
Resultado para frontier: ...
Compressão: ...
Tempo: ...
Cache: HIT/MISSCodex
~/.codex/config.toml oder das JSON des Clients:
{
"mcpServers": {
"local-worker": {
"command": "local-worker-mcp",
"env": {
"LOCAL_LLM_PROVIDER": "ollama",
"LOCAL_LLM_BASE_URL": "http://127.0.0.1:11434",
"ALLOWED_PATHS": "C:\\Projects"
}
}
}
}Siehe examples/codex.json.
Claude Code
claude mcp add local-worker --scope user -- local-worker-mcpOder fügen Sie examples/claude_code.json in ~/.claude.json ein.
In der CLAUDE.md / AGENTS.md des Projekts lehren Sie die Richtlinie:
Mechanische Aufgaben und das Lesen großer Dateien gehen an
delegate_pdf/delegate_file/delegate_task. Wennlocal_statusoder das Toolunavailablezurückgibt, führen Sie direkt aus und machen Sie weiter.
Andere MCP-Clients
Jeder stdio-Client funktioniert. Generisches Beispiel in examples/generic.json:
{
"mcpServers": {
"local-worker": {
"command": "local-worker-mcp",
"env": {
"LOCAL_LLM_PROVIDER": "ollama",
"LOCAL_LLM_BASE_URL": "http://127.0.0.1:11434"
}
}
}
}Beispiele
examples/pdf.md— Paper / langes PDFexamples/code.md— Erstes Lesen eines Repositorysexamples/logs.md— Fehlerextraktion
Tests
python -m pip install -e ".[dev]"
pytest
ruff check src testsDie Suite hängt nicht von echten Ollama/Gemma ab. Alles wird gemockt.
Was nicht in dieses MVP gehört
Windows-GUI-Automatisierung, Playwright, komplexer Multi-Agent, vektorielles RAG, Dashboard, Kubernetes, ML-Router.
Die Architektur lässt Platz für delegate_repo, delegate_git, delegate_browser usw. in der nächsten Phase.
Lizenz
MIT.
Available Tools
8 toolscache_cleanupA
Run cache garbage collection now (TTL, unused, then LRU).
Inputs: no named parameters.
cache_clearA
Delete disposable cache entries. Persistent artifacts stay unless include_persistent=true.
Inputs: include_persistent.
cache_statsB
Cache size, entry count, hits, misses, hit rate, and expired entries.
Inputs: no named parameters.
delegate_batchB
Run independent local tasks in parallel. One failure does not cancel the batch.
Inputs: tasks (required).
delegate_fileC
Have the local worker read a file (txt/md/csv/json/code/log) without loading it into frontier context.
Inputs: path (required), objective (required), persistent, output_mode, +1 more.
delegate_pdfC
Extract, chunk, and analyze a PDF locally. Returns compact findings with page evidence.
Inputs: path (required), objective (required), persistent, output_mode, +1 more.
delegate_taskC
Delegate a mechanical task to the local worker. Returns compact structured output.
Inputs: objective (required), context, persistent, force_refresh, +2 more.
local_statusA
Check local worker health: provider, endpoint, model, circuit breaker, cache.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clear, distinct purpose: health check, task delegation, batch processing, file reading, PDF analysis, cache statistics, cleanup, and clearing. There is no overlap in functionality, making it easy for an agent to select the appropriate tool.
All tool names follow a consistent verb_noun pattern (e.g., local_status, delegate_task, cache_stats). The naming is predictable and clear, with verbs like 'delegate' and 'cache' used consistently to indicate the action and domain.
With 8 tools, the count is appropriate for the server's purpose of managing a local worker and its cache. The scope is well-defined without being too thin or overly broad.
The tool surface covers the key operations: health checks, task delegation (including batch and file processing), and cache management (stats, cleanup, clear). A minor gap is the lack of a tool to update or cancel a delegated task, but the core workflows are well supported.
Maintenance
Related MCP Connectors
Reduces AI Agent token usage by 40% via three-stage SOP workflow.
Up to 90% fewer tokens: deterministic, declared tool calls, each with a receipt and an audit trail.
Deterministic AI agent microtools, no accounts/API keys. fetch_extract: 98% token cut. 47 tools.
Shared task layer for AI agents: tasks, handoffs and decisions that persist across tools.
Related MCP Servers
- AlicenseAqualityDmaintenanceOptimizes token costs by intelligently delegating low-complexity tasks to local LLMs via LiteLLM, enabling cost-effective development workflows.31MIT
- AlicenseAqualityBmaintenanceOffloads cheap work from cloud LLM agents to a local Ollama model, reducing costs and keeping frontier models focused on complex tasks.894 PyPI3MIT
- AlicenseBqualityDmaintenanceEnables coding agents like Claude Code and Codex to offload boilerplate generation, summarization, and other bounded text tasks to local or cheap cloud LLMs, keeping the frontier agent in charge of judgment and code edits.93MIT
- AlicenseNot gradedqualityBmaintenanceEnables Claude Code to hand off bulk, mechanical, read-heavy tasks to a local model, including agentic loops that can read, write, and run commands sandboxed at zero cloud token cost.MIT