Local Worker MCP
Uses a local Ollama instance (e.g., Gemma 4 12B QAT) to process files, PDFs, logs, and generic tasks, returning compact, verifiable results to reduce token consumption by frontier AIs.
Supports OpenAI-compatible backends (LM Studio, llama.cpp server, vLLM) as the local worker provider, enabling the same delegation and fallback behavior.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Local Worker MCP extract the key data from this PDF report and summarize findings"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Local Worker MCP
Client-agnostic local MCP. Frontier plans, delegates, and reviews. Local does the heavy, mechanical, and verifiable work.
The goal is to reduce token consumption from paid AIs without dumping raw content into their context.
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 revisaThis does not replace the main AI and is not a model router. It is real task delegation.
LOCAL DISPONÍVEL? NÃO
│ │
▼ ▼
DELEGA NÃO INSISTE
│ │
▼ ▼
COMPRIME FRONTIER ASSUME
│
▼
FRONTIER REVISAGemma is an optimization. It must never become a single point of failure.
Principle
Delegate when the task is mechanical, repetitive, verifiable, or context-intensive: PDF, logs, CSV, code, extraction, classification, summarization.
Keep on the frontier: architectural decisions, security, critical changes, subjective judgment, ambiguous requirements.
If the local worker is offline, the frontier continues. The MCP returns unavailable quickly and recommends a fallback. The client can log:
Worker local indisponível; executei diretamente.Does not require user intervention.
Related MCP server: ollama-handoff
Requirements
Python 3.10+
Ollama on the same PC or another on the LAN
A local model (recommended: 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
Install and start Ollama.
Download the model. The name is not hardcoded — use the actual name from your
ollama list:
ollama list
ollama pull <nome-real-do-gemma>If
LOCAL_LLM_MODELis empty, the worker tries to detect a model whose name containsgemma. Otherwise, it uses the first listed model.Test the endpoint:
curl http://127.0.0.1:11434/api/tags
local-worker statusStart the MCP:
local-worker-mcpSame PC
LOCAL_LLM_PROVIDER=ollama
LOCAL_LLM_BASE_URL=http://127.0.0.1:11434
LOCAL_LLM_MODEL=local vs lan is detected by hostname. 127.0.0.1, localhost, and ::1 are local.
Laptop using the desktop
The worker does not assume localhost. The backend can be on another PC on the LAN.
On the laptop:
LOCAL_LLM_PROVIDER=ollama
LOCAL_LLM_BASE_URL=http://192.168.x.x:11434Replace 192.168.x.x with the current IP of the desktop (ipconfig on Windows, ip a on Linux). There is no fixed IP in the project.
The behavior is the same: fail-fast, circuit breaker, cache, compression.
On the desktop, Ollama must accept connections from the LAN (OLLAMA_HOST=0.0.0.0 environment variable and firewall allowing port 11434).
OpenAI-compatible
LM Studio, llama.cpp server, vLLM, and similar:
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 and circuit breaker
Defaults:
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=60Connection refused does not retry. After N failures the circuit opens and subsequent calls return unavailable immediately. After the cooldown, one attempt is allowed.
{
"status": "unavailable",
"fallback_recommended": true,
"reason": "Local LLM endpoint unreachable"
}MCP Tools
Tool | Function |
| provider, endpoint, local/LAN, latency, model, circuit breaker, cache |
| generic task → compact JSON |
| independent tasks in parallel ( |
| TXT, Markdown, CSV, JSON, code, logs |
| extraction by page, chunking, hierarchical synthesis, evidence |
| size, entries, hits, misses, hit rate, expired |
| GC now (TTL → not reused → LRU) |
| delete disposable entries |
The raw file content does not need to enter the paid AI's context. The worker reads, compresses, and returns verifiable evidence (page, line, snippet).
Security
Default: SECURITY_MODE=READ_ONLY, ENABLE_SHELL=false.
SECURITY_MODE=READ_ONLY
ALLOWED_PATHS=C:\Projects,D:\Research
ENABLE_SHELL=falseREAD_ONLY— read-only on authorized paths; write and shell blockedWORKSPACE_WRITE— read/write on authorized paths; shell only ifENABLE_SHELL=trueFULL_LOCAL— more permissive; still blocks destructive commands
Path traversal is blocked. rm, del, format, etc. are refused.
Cache and logs
Persistent cache in ~/.local-worker-mcp/cache, self-cleaning:
CACHE_TTL_DAYS=30
CACHE_MAX_SIZE_GB=10
CACHE_CLEANUP_THRESHOLD_PERCENT=90
CACHE_TARGET_USAGE_PERCENT=80
CACHE_CLEANUP_INTERVAL_HOURS=6Entries are disposable by default. persistent=true preserves important artifacts.
Logs rotate and expire:
LOG_RETENTION_DAYS=14
LOG_MAX_SIZE_MB=250The log does not store the full file content.
Benchmark
local-worker benchmark arquivo.pdfOutput:
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 or the client's JSON:
{
"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"
}
}
}
}See examples/codex.json.
Claude Code
claude mcp add local-worker --scope user -- local-worker-mcpOr paste examples/claude_code.json into ~/.claude.json.
In the project's CLAUDE.md / AGENTS.md, teach the policy:
Mechanical tasks and reading large files go to
delegate_pdf/delegate_file/delegate_task. Iflocal_statusor the tool returnsunavailable, execute directly and move on.
Other MCP clients
Any stdio client works. Generic example 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"
}
}
}
}Examples
examples/pdf.md— long paper / PDFexamples/code.md— initial repository readingexamples/logs.md— error extraction
Tests
python -m pip install -e ".[dev]"
pytest
ruff check src testsThe suite does not depend on real Ollama/Gemma. Everything is mocked.
What is not included in this MVP
Windows GUI automation, Playwright, complex multi-agent, vector RAG, dashboard, Kubernetes, ML router.
The architecture leaves room for delegate_repo, delegate_git, delegate_browser, etc. in the next phase.
License
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