Local Worker MCP
Local Worker MCP
MCP local, agnóstico de cliente. Frontier planeja, delega e revisa. Local executa o trabalho pesado, mecânico e verificável.
O objetivo é reduzir o consumo de tokens das IAs pagas sem jogar o conteúdo bruto no contexto delas.
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 revisaIsso não substitui a IA principal e não é um model router. É delegação real de trabalho.
LOCAL DISPONÍVEL? NÃO
│ │
▼ ▼
DELEGA NÃO INSISTE
│ │
▼ ▼
COMPRIME FRONTIER ASSUME
│
▼
FRONTIER REVISAA Gemma é uma otimização. Ela jamais pode virar ponto único de falha.
Princípio
Delegar quando a tarefa for mecânica, repetitiva, verificável ou intensiva em contexto: PDF, logs, CSV, código, extração, classificação, resumo.
Manter na frontier: decisões arquiteturais, segurança, mudanças críticas, julgamento subjetivo, requisitos ambíguos.
Se o worker local estiver offline, a frontier continua. O MCP devolve unavailable rápido e recomenda fallback. O cliente pode registrar:
Worker local indisponível; executei diretamente.Não exige intervenção do usuário.
Related MCP server: ollama-handoff
Requisitos
Python 3.10+
Ollama no mesmo PC ou em outro da LAN
Um modelo local (recomendado: Gemma 4 12B QAT)
Instalação
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
Instale e inicie o Ollama.
Baixe o modelo. O nome não é hardcoded — use o nome real no seu
ollama list:
ollama list
ollama pull <nome-real-do-gemma>Se
LOCAL_LLM_MODELficar vazio, o worker tenta detectar um modelo cujo nome contémgemma. Senão, usa o primeiro modelo listado.Teste o endpoint:
curl http://127.0.0.1:11434/api/tags
local-worker statusSuba o MCP:
local-worker-mcpMesmo PC
LOCAL_LLM_PROVIDER=ollama
LOCAL_LLM_BASE_URL=http://127.0.0.1:11434
LOCAL_LLM_MODEL=local vs lan é detectado pelo hostname. 127.0.0.1, localhost e ::1 são locais.
Notebook usando o desktop
O worker não assume localhost. O backend pode estar em outro PC da LAN.
No notebook:
LOCAL_LLM_PROVIDER=ollama
LOCAL_LLM_BASE_URL=http://192.168.x.x:11434Troque 192.168.x.x pelo IP atual do desktop (ipconfig no Windows, ip a no Linux). Não há IP fixo no projeto.
O comportamento é o mesmo: fail-fast, circuit breaker, cache, compressão.
No desktop, o Ollama precisa aceitar conexões da LAN (variável OLLAMA_HOST=0.0.0.0 e firewall liberando a porta 11434).
OpenAI-compatible
LM Studio, llama.cpp server, vLLM e similares:
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 e 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=60Conexão recusada não entra em retry. Depois de N falhas o circuito abre e as próximas chamadas devolvem unavailable imediatamente. Após o cooldown, uma tentativa é permitida.
{
"status": "unavailable",
"fallback_recommended": true,
"reason": "Local LLM endpoint unreachable"
}Ferramentas MCP
Ferramenta | Função |
| provider, endpoint, local/LAN, latência, modelo, circuit breaker, cache |
| tarefa genérica → JSON compacto |
| tarefas independentes em paralelo ( |
| TXT, Markdown, CSV, JSON, código, logs |
| extração por página, chunking, síntese hierárquica, evidências |
| tamanho, entradas, hits, misses, hit rate, expirados |
| GC agora (TTL → não reutilizados → LRU) |
| apaga entradas descartáveis |
O conteúdo bruto do arquivo não precisa entrar no contexto da IA paga. O worker lê, comprime e devolve evidências verificáveis (página, linha, trecho).
Segurança
Default: SECURITY_MODE=READ_ONLY, ENABLE_SHELL=false.
SECURITY_MODE=READ_ONLY
ALLOWED_PATHS=C:\Projects,D:\Research
ENABLE_SHELL=falseREAD_ONLY— só leitura nos paths autorizados; escrita e shell bloqueadosWORKSPACE_WRITE— leitura/escrita nos paths autorizados; shell só seENABLE_SHELL=trueFULL_LOCAL— mais permissivo; ainda bloqueia comandos destrutivos
Path traversal é bloqueado. rm, del, format etc. são recusados.
Cache e logs
Cache persistente em ~/.local-worker-mcp/cache, autolimpante:
CACHE_TTL_DAYS=30
CACHE_MAX_SIZE_GB=10
CACHE_CLEANUP_THRESHOLD_PERCENT=90
CACHE_TARGET_USAGE_PERCENT=80
CACHE_CLEANUP_INTERVAL_HOURS=6Entradas são descartáveis por padrão. persistent=true preserva artefatos importantes.
Logs rotacionam e expiram:
LOG_RETENTION_DAYS=14
LOG_MAX_SIZE_MB=250O log não guarda o conteúdo completo dos arquivos.
Benchmark
local-worker benchmark arquivo.pdfSaída:
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 ou o JSON do cliente:
{
"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"
}
}
}
}Ver examples/codex.json.
Claude Code
claude mcp add local-worker --scope user -- local-worker-mcpOu cole examples/claude_code.json em ~/.claude.json.
No CLAUDE.md / AGENTS.md do projeto, ensine a política:
Tarefas mecânicas e leitura de arquivos grandes vão para
delegate_pdf/delegate_file/delegate_task. Selocal_statusou a ferramenta devolverunavailable, execute diretamente e siga em frente.
Outros clientes MCP
Qualquer cliente stdio funciona. Exemplo genérico em 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"
}
}
}
}Exemplos
examples/pdf.md— paper / PDF longoexamples/code.md— leitura inicial de repositórioexamples/logs.md— extração de erros
Testes
python -m pip install -e ".[dev]"
pytest
ruff check src testsA suíte não depende de Ollama/Gemma reais. Tudo é mockado.
O que não entra neste MVP
Automação de GUI Windows, Playwright, multiagente complexo, RAG vetorial, dashboard, Kubernetes, roteador ML.
A arquitetura deixa espaço para delegate_repo, delegate_git, delegate_browser etc. na próxima fase.
Licença
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