explaingit

moorethreads/mtclaw

13PythonAudience · developerComplexity · 4/5ActiveSetup · moderate

TLDR

Local OpenAI-compatible proxy that intercepts agent requests, runs matched user-defined tools directly, and passes everything else through to an upstream model.

Mindmap

mindmap
  root((MTClaw))
    Inputs
      OpenAI API calls
      functions jsonl
      Wrapper scripts
    Outputs
      Tool results
      Upstream model replies
    Use Cases
      Speed up repeat agent tasks
      Route to internal APIs
      Wrap systemctl as a tool
    Tech Stack
      Python
      Shell
      JSON

Things people build with this

USE CASE 1

Speed up an OpenClaw or OpenCode workflow by routing repeat tasks to local tools

USE CASE 2

Expose an internal company API to an AI agent as a named function tool

USE CASE 3

Wrap systemctl status checks as a tool the agent can call directly

USE CASE 4

Run a strict-mode router that keeps 100% Pass@1 while cutting latency 5x

Tech stack

PythonShellJSON

Getting it running

Difficulty · moderate Time to first run · 30min

Install script needs two LLM endpoints (a tool-calling routing model and an upstream model) plus API keys before the router will start.

In plain English

OpenClaw Function Router is a local proxy that sits between an AI agent or coding assistant and the large language model the agent normally talks to. It speaks the same API as OpenAI's, so any tool that already supports an OpenAI-compatible base URL (such as OpenClaw, OpenCode, Hermes, or other agent frameworks and IDEs) can point at the router instead of the model and not change anything else. The README's argument is that for narrow, repeating jobs (file operations, business APIs, internal company workflows, system control), going through a full large model on every call is slow. The router lets you wrap those jobs as named tools. When a user request matches one of your tools, the router runs the tool directly. When it does not match, the request is passed through to the upstream model as if the router were not there. The benchmark numbers given are a 6.85x speed-up in a permissive mode and a 4.99x speed-up in a strict mode that keeps a 100 percent Pass@1 score, both on a 50-task system control benchmark. Inside the router, several specialised sub-agents do different jobs: a routing sub-agent decides whether a request should go to a tool or pass through to the upstream model, builtin and user-defined tool executors run the matched actions, an optional completion-check sub-agent decides whether the result is final or needs the upstream model to phrase the answer, and the upstream provider handles open-ended reasoning. The quick start asks the user to clone the repo, run pip install ., then a shell install script that prompts for two LLM endpoints: a routing model that supports tool calling and an upstream model used for general replies. It also asks for API keys, a base directory for tool scripts, and the path to an openclaw.json file so the router can register itself with OpenClaw. There are restart scripts for the router alone and for the full service stack. The rest of the README explains how to add your own tools. Each tool is a JSON line in functions.jsonl plus a matching wrapper script under ~/.function-router/scripts/. The wrapper reads JSON on standard input and writes JSON on standard output, returning exit code 0 on success. The README gives three worked examples: a weather lookup using a public API, an internal shipment status query, and a service status check that delegates to systemctl.

Copy-paste prompts

Prompt 1
Walk me through cloning MTClaw, running pip install ., and the shell install script
Prompt 2
Show me a functions.jsonl entry plus a wrapper script that returns the current weather for a city
Prompt 3
Explain when the router passes through to the upstream model versus running a tool locally
Prompt 4
How do I point an existing OpenAI-compatible IDE at the MTClaw router base URL
Prompt 5
Give me a worked example of a tool wrapper that delegates to systemctl and returns JSON
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.