Skip to main content
Glama

理脈 limai

Rika and Ritsu's shared nervous system — an independent organ extracted from the character based on first principles.

First-Principles Derivation

As seen in the character

Essence

Module

MCP Tools

Heartbeat polling + error backoff (on_idle.mjs)

Rhythm

heartbeat.mjs

heartbeat_now・vitals_latest・vitals_history

Screenshot/window/clipboard (screenshot.mjs)

Vision

vision.mjs

screen_capture(returns image)・list_windows・read_clipboard

todo-tasks.json + weighted heartbeat fusion

Intent

todo.mjs

todo_add・todo_list・todo_update

Long-term memory (name × keyword × content)

Memory

memory.mjs

memory_add・memory_search・memory_list・memory_forget

o-pi six file tools

File actions

filesys.mjs

fs_ls/read/write/edit/find/grep

o-pi websearch/webfetch

Web actions

web.mjs

web_search・web_fetch

Discarded: the character's LLM task prompts (personality not carried over), the JS eval trigger in memory (security). Retained essence: weighted random scheduling idea → heartbeat backoff; STALE_READ guard; SSRF protection; bounded reads.

Related MCP server: exobrain-mcp

Startup

npm install
npm run start          # ① stdio → Claude Desktop / Cursor 等本地客戶端
npm run serve:http     # ② HTTP MCP → GPT 客戶端 / 區網 / 遠端
npm run tick           # ③ 手動跑一次心跳(驗證感知層)

CLI Designed for AI Agents

limai shot                       # → {"file":...,"width":1920,"height":1080,"bytes":...}
limai win                        # → {"foreground":...,"windows":[{process,title},…]}
limai clip [--json]              # 剪貼簿原文走 stdout(利於管線)
limai tick                       # 心跳一次,生命徵象 JSON
limai web search <q>             # → [{title,url,snippet},…]
limai web fetch <url>            # 正文走 stdout、中繼 stderr;--json 得全包裝
limai fs ls|read|write|edit|find|grep …
limai mem … / limai todo …       # 同前

Agent contract:

  • Outputs JSON by default, error codes prefixed into stderr messages (STALE_READ: …), non-zero exit code indicates failure

  • fs edit follows the same strict contract as MCP: must fs read first; observation state persists in fs-state.json, so the "read session → edit session" flow still holds across calls, and external changes are always intercepted (--force can bypass)

  • A successful fs write also establishes an observation and can be followed by edit (same as o-pi's "immediately after successful write" rule)

Architecturally, MCP is just one interface above the core modules: the same vision/web/filesys/memory/todo/heartbeat set serves both CLI subcommands and MCP tool calls, and both interfaces share the same data and the same security contract.`

First run automatically creates ~/.limai/ (config.json・memory.json・todo.json・vitals.*・screenshots/) and prints the token.

Client Integration

Local (stdio)

// claude_desktop_config.json
{ "mcpServers": { "limai": { "command": "node", "args": ["F:\\fount開發項目\\理脈\\src\\cli.mjs", "serve", "--stdio"] } } }

LAN / Same-Machine GPT Clients (Cherry Studio, LobeChat, OpenWebUI…)

node src/cli.mjs serve --http                # 預設 127.0.0.1:8931
# 對區網開放:--host 0.0.0.0 --token <強密碼>
{ "type": "http", "url": "http://192.168.x.x:8931/mcp",
  "headers": { "Authorization": "Bearer <token>" } }

Cloud ChatGPT (Connectors / Developer Mode)

ChatGPT can't reach your localhost — it needs public HTTPS: a one-line tunnel:

cloudflared tunnel --url http://127.0.0.1:8931
# → https://xxxx.trycloudflare.com

Fill the connector URL with https://xxxx.trycloudflare.com/mcp?token=<token> (GPT-type clients mostly can't customize headers, so query-based token passing is supported). Long-term options: Tailscale Funnel (no port opening) or Caddy reverse proxy on your own domain.

Security Boundary

  • Files: locked to allowedRoots in config.json; .git permanently blocked; fs_edit must fs_read first (STALE_READ version guard); old text must be unique

  • Network: rejects localhost/private/link-local (SSRF), per-hop redirect re-check, 2MB cap, 30-second timeout

  • Auth: Bearer/query-token throughout HTTP; binds to 127.0.0.1 by default

  • Privacy: heartbeat only records window titles + clipboard hashes (stores a 60-character preview on change); pixel screenshots only on explicit screen_capture calls

Heartbeat Semantics (Inherited from Rika)

One beat every 15 minutes (adjustable via heartbeat.intervalMin). Each beat collects: foreground window・window list (top 8)・idle seconds・clipboard changes・open todo count. On failure the interval ×2 (cap 8×), reset on success. Logs append to vitals.ndjson.

Upstream Sync (o-pi)

  • 2026-08-23 check: that day's upstream commits were internal refactoring (file-tools/web-tools/filesystem/lsp simplification); the behavior contracts of the six tools plus two web tools are unchanged; duckduckgo-html-provider remains the zero-key fallback path — Limai's extraction is still faithful.

  • New capability: read supports PDF page images (d762209): Limai has aligned its implementation — fs_read adds a pages parameter (N / N-M / N-), returning MCP image content blocks of page PNGs; CLI uses fs read <pdf> --pages "1-5". Primary path: PDF.js (pdfjs-dist legacy) + @napi-rs/canvas for cross-platform rendering; on Windows, auto-falls back to the built-in WinRT Windows.Data.Pdf when dependencies can't load. Default cap of 20 pages per call, including total page count and resume position.

  • skill URI / bash tools / approval gate are Pi-host-specific and outside the extraction scope.

  • Second check same day (d795f92 new approval UI): only touches src/approval/* and the TUI; file-tools/web-tools have zero changes. Grep contract alignment completed accordingly: invalid regex degrades to an exact literal — on a hit → returns literal_fallback warning; zero hits → INVALID_REGEX, no faking empty results. Tested and passing.

License & Attribution

This project is released under the GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later); full terms in LICENSE.

Code source attribution:

  • File tools (src/core/filesys.mjs: ls/read/write/edit/find/grep) and web tools (src/core/web.mjs: web_search/web_fetch) have behavior contracts and design derived from Orion-zhen/o-pi (Pi Agent's file-tools and web-tools design docs, AGPL-3.0 licensed). Limai is an independent zero-dependency Node.js implementation of their essence, not code copying, open-sourced back under the same AGPL terms.

  • The extraction blueprint for capability primitives such as heartbeat/todo/memory/vision comes from the "Rika" character's capability design in the steve02081504/fount ecosystem (MIT licensed). Only its architectural ideas were referenced (idle polling backoff, weighted tasks, name × keyword × content memory); no code was copied.

  • MCP protocol implementation is based on the official @modelcontextprotocol/sdk.

  • PDF rendering depends on pdf.js (Apache-2.0) and @napi-rs/canvas (MIT).

Available Tools

21 tools
fs_edit精確編輯A

對既有檔案做精確替換。須先 fs_read;old 必須唯一(多處命中需 replace_all 或更多上下文)。

Inputs: file (required), edits (required), force.

fs_find找路徑A

glob 路徑模糊搜尋(跳過 .git/node_modules;不搜尋內容)。

Inputs: glob, root, limit.

fs_grep搜內容A

正則逐行搜尋檔案內容(跳過 .git/node_modules 與 >1MB 檔)。非法正則時降級為精確字面量:有命中回 literal_fallback 警告,零命中才報 INVALID_REGEX。

Inputs: query (required), root, limit.

fs_ls列目錄B

列出目錄直屬成員(不遞迴、不讀內容)。

Inputs: dir.

fs_read讀檔案A

讀取檔案。文字檔用行範圍;PDF 用 pages 參數(如 "1-5"、"3"),回傳頁面 PNG 圖像內容(預設單次上限 20 頁,含總頁數與續讀位置);fs_edit 前必讀以建立觀測狀態。

Inputs: file (required), pages, maxLines, offsetLine.

fs_write寫檔案A

建立新檔或完整覆蓋(自動建父目錄)。不做局部合併。

Inputs: file (required), content (required).

heartbeat_now立即心跳A

立即執行一次心跳:收集前景視窗/閒置秒數/剪貼簿變化/todo 數量,寫入 vitals。

Inputs: no named parameters.

list_windows視窗清單A

列出前景視窗與所有有標題的視窗(行程名+標題)。輕量了解使用者正在做什麼。

Inputs: no named parameters.

memory_add記憶寫入B

新增或更新長期記憶。名稱唯一;keywords 供日後檢索觸發。內容應簡潔、去修辭、客觀(角色記憶規範)。

Inputs: name (required), content (required), keywords.

memory_forget遺忘C

依名稱刪除一條記憶。

Inputs: name (required).

memory_list記憶清單B

列出全部長期記憶。

Inputs: no named parameters.

read_clipboard讀剪貼簿A

讀取目前剪貼簿文字(上限 2 萬字元)。

Inputs: no named parameters.

screen_capture螢幕截圖A

擷取本機全螢幕畫面。回傳 PNG 圖片(多模態客戶端可直接看見畫面內容)。僅在明確需要時呼叫。

Inputs: no named parameters.

todo_add新增待辦C

新增待辦任務(open 狀態;同名 open 任務會拒絕重複)。

Inputs: name (required), weight, content.

todo_list待辦清單A

列待辦;status 可選 open/done,省略則全部。

Inputs: status.

todo_update更新待辦C

標記完成(done)/重開(reopen)/刪除(remove)。id 接受 id 或 name。

Inputs: id (required), action (required).

vitals_history徵象歷史C

最近 N 筆心跳歷史。

Inputs: n.

vitals_latest最新徵象B

最近一次心跳快照。

Inputs: no named parameters.

web_fetch抓取網頁A

讀取公開 HTTP(S) URL。readable=抽正文、source=原文;offset/limit 有界分頁;拒絕本機與私網位址。

Inputs: url (required), mode, limit, offset.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 21 tools

    Disambiguation5/5

    Each tool targets a distinct resource and action—monitoring (screen, windows, clipboard, heartbeat), memory (add/search/list/forget), todo (add/list/update), web (search/fetch), and filesystem (ls/read/write/edit/find/grep). There is no meaningful overlap; even fs_write vs fs_edit are clearly separated by create/overwrite vs precise replacement.

    Naming Consistency5/5

    All tool names follow a consistent 'domain_action' pattern with snake_case (e.g., memory_add, web_fetch, fs_grep). The verb is consistently after the domain, and every name is lowercase, making the API predictable and easy to navigate.

    Tool Count4/5

    With 21 tools, the server is slightly above the ideal range but each tool serves a clear purpose across multiple domains (system monitoring, memory, todos, web, filesystem). The count is justified given the broad scope, though a few tools could potentially be consolidated without losing clarity.

    Completeness3/5

    The server covers most core operations for its domains—memory and todo have full CRUD-ish coverage, web has search and fetch, and filesystem has read/write/edit/find/grep. However, the absence of a file deletion tool (e.g., fs_delete) leaves the filesystem incomplete, and there is no explicit tool for renaming or moving files. This gap could cause agent failures when cleanup is required.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Provides persistent memory for MCP-compatible agents (like Copilot CLI) to save and recall knowledge across sessions, plus long-running monitoring tools.
      9
      -
    • A
      license
      B
      quality
      D
      maintenance
      An all-in-one MCP server that enables AI agents with local system capabilities like filesystem navigation, command execution, desktop automation, and a continuity memory suite for persistent cross-session project context.
      37
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Local-first memory MCP server that captures macOS screen and app context into persistent Markdown, enabling any tool-capable LLM agent to query its working history.
      MIT