MikroClaw
Ultra-lightweight AI agent runtime for MikroTik RouterOS container deployments. Sub-200KB binary, VPN-first, zero local persistence.
Why MikroClaw?
Traditional AI agents are heavy and require cloud connectivity. MikroClaw inverts this.
Sub-200KB Binary
Tiny C runtime with static builds. Runs in 2MB RAM RouterOS containers with zero external dependencies.
VPN-First Security
Your AI agent lives on your internal network. Pairing-token auth, rate limiting, sender allowlists, and encrypted secrets.
memU Cloud Memory
Zero local persistence. Conversational memory via memU cloud with store, recall, and forget primitives.
13 LLM Providers
Provider registry with reliable fallback chains and streaming support. OpenRouter, OpenAI, Anthropic, Ollama, and more.
Multi-Channel
Telegram, Discord, and Slack channels with per-channel sender allowlists. Gateway API for direct integration.
RouterOS Native
REST API automation, firewall-scoped commands, workspace-only file access, and symlink escape prevention.
Quick Start
export BOT_TOKEN="your_telegram_bot_token"
export OPENROUTER_KEY="your_openrouter_key"
export ROUTER_HOST="192.168.88.1"
export ROUTER_USER="admin"
export ROUTER_PASS="your_password"make clean && make./mikroclaw agentcurl http://localhost:18789/healthFunction Tools
14 registered tools with JSON Schema definitions. These are exposed to the LLM via function_register_with_schema() in src/functions.c and follow the OpenAI function-calling format.
LLM Integration: All tool schemas are automatically registered at boot and passed to the provider as available functions. The LLM can invoke any tool via standard function-calling. Responses are routed back through the tool router.
parse_urlNetworkParse URL host/path
{
"type": "object",
"properties": {
"url": {
"type": "string"
}
},
"required": [
"url"
]
}health_checkSystemReturn process health
{
"type": "object",
"properties": {}
}memory_storeMemoryStore key/value memory
{
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"key",
"value"
]
}memory_recallMemoryRecall key memory
{
"type": "object",
"properties": {
"key": {
"type": "string"
}
},
"required": [
"key"
]
}memory_forgetMemoryForget key memory
{
"type": "object",
"properties": {
"key": {
"type": "string"
}
},
"required": [
"key"
]
}web_searchNetworkSearch web documents
{
"type": "object",
"properties": {
"query": {
"type": "string"
}
},
"required": [
"query"
]
}web_scrapeNetworkScrape URL via cloud services
{
"type": "object",
"properties": {
"url": {
"type": "string"
}
},
"required": [
"url"
]
}skill_listSkillsList skills directory entries
{
"type": "object",
"properties": {}
}skill_invokeSkillsInvoke executable skill from skills directory
{
"type": "object",
"properties": {
"skill": {
"type": "string"
},
"params": {
"type": "string"
}
},
"required": [
"skill"
]
}routeros_executeRouterOSExecute RouterOS command from args
{
"type": "object",
"properties": {
"command": {
"type": "string"
}
},
"required": [
"command"
]
}shell_execRouterOSExecute allowed shell command
{
"type": "object",
"properties": {
"command": {
"type": "string"
}
},
"required": [
"command"
]
}file_readFilesystemRead file in workspace
{
"type": "object",
"properties": {
"path": {
"type": "string"
}
},
"required": [
"path"
]
}file_writeFilesystemWrite file in workspace
{
"type": "object",
"properties": {
"path": {
"type": "string"
},
"content": {
"type": "string"
}
},
"required": [
"path",
"content"
]
}composio_callSystemCall Composio-compatible endpoint
{
"type": "object",
"properties": {
"tool": {
"type": "string"
},
"input": {
"type": "string"
}
},
"required": [
"tool",
"input"
]
}Runtime Constraints
shell_execis constrained byALLOWED_SHELL_CMDSfile_read/file_writeenforce workspace checks, forbidden paths, and symlink escape preventionweb_scrapebehavior controlled byWEBSCRAPE_SERVICEScomposio_callrequiresCOMPOSIO_URLandCOMPOSIO_API_KEY
Gateway API
Default port 18789. When PAIRING_REQUIRED=1, bearer token auth is enforced on non-health routes.
/healthReturns component health status for LLM, gateway, RouterOS, and memU.
{"status":"ok","components":{"llm":true,"gateway":true,"routeros":true,"memu":true}}/health/heartbeatLightweight heartbeat probe.
{"heartbeat":"ok"}/pairExchange X-Pairing-Code header for a bearer token.
{"paired":true,"token":"<bearer-token>"}/tasksSubmit a task to the subagent runtime. Requires type in body.
{"task_id":"...","status":"queued"}/tasksList all queued tasks from the subagent.
/tasks/:idGet status and result for a specific task.
/tasks/:idCancel a running or queued task.
{"status":"cancelled"}Architecture
A layered C runtime with clear module boundaries.
Inbound Request (Telegram / Discord / Slack / Direct)
|
v
[Allowlist Check] ---- rejected ----> X
|
v
[Gateway Auth] ---- unauthorized ----> 403
|
v
[Rate Limit] ---- throttled ----> 429
|
v
[LLM Provider] (reliable fallback chain)
|
v
[Tool Router] ----> RouterOS API
| shell_exec
| file_read/write
| web_search/scrape
| memory_*
v
[memU Cloud] <---- persistence
|
v
Response RoutingCore Runtime
Bootstrap, orchestration loop, CLI routing, config validation
main.cmikroclaw.ccli.clog.cLLM + Providers
Chat transport, streaming parser, 13 named providers with fallback
llm.cllm_stream.cprovider_registry.cTooling + Execution
Tool registry, async task dispatch, worker pool, subagent APIs
functions.ctask_queue.cworker_pool.csubagent.cGateway + Security
Socket listener, pairing auth, per-IP throttling, lockout tracking
gateway.cgateway_auth.crate_limit.cChannel Layer
Multi-channel messaging with per-channel sender allowlists
telegram.cdiscord.cslack.callowlist.cCLI Commands
| Command | Description |
|---|---|
./mikroclaw agent | Run the AI agent loop |
./mikroclaw gateway [--port 0] | Start the HTTP gateway |
./mikroclaw daemon | Run as background daemon |
./mikroclaw status | Check runtime status |
./mikroclaw doctor | Diagnose configuration issues |
./mikroclaw channel | Test channel connectivity |
./mikroclaw config --dump | Dump current configuration |
./mikroclaw integrations [list|info <name>] | List or inspect integrations |
./mikroclaw identity [--rotate] | Manage device identity |
./mikroclaw encrypt KEY=VALUE | Encrypt secret values |