limai
This server is a multimodal MCP assistant backend that gives AI agents local sensing (screen/window/clipboard), heartbeat vitals, long-term memory, todo management, web access, and file operations.
Screen & system awareness: capture a full-screen PNG, list foreground/all window titles, read clipboard text.
Heartbeat/vitals: trigger an immediate heartbeat, get the latest snapshot, or view recent history (foreground window, idle seconds, clipboard changes, todo counts).
Long-term memory: add/search/list/forget named memories with keywords.
Todo management: add open todos, list by status, and mark done/reopen/remove.
Web tools: search the web via DuckDuckGo or configured providers, and fetch public web pages in readable/source mode with SSRF protection and size limits.
Filesystem tools: list directories, read text/PDF files (with PDF page rendering), write files, precise guarded edits, glob-find paths, and regex-grep file contents.
Safety contract: file access is confined to allowed roots, edits require prior reads (STALE_READ guard), and network requests block local/private addresses.
Provides web search through DuckDuckGo as a zero-key fallback search provider in the server's web search capability.
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., "@limai what's on my screen and clipboard right now?"
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.
理脈 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 failurefs editfollows the same strict contract as MCP: mustfs readfirst; observation state persists infs-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 writealso 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.comFill 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
allowedRootsinconfig.json;.gitpermanently blocked;fs_editmustfs_readfirst (STALE_READ version guard); old text must be uniqueNetwork: 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_capturecalls
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-providerremains the zero-key fallback path — Limai's extraction is still faithful.New capability:
readsupports PDF page images (d762209): Limai has aligned its implementation —fs_readadds apagesparameter (N / N-M / N-), returning MCP image content blocks of page PNGs; CLI usesfs 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 WinRTWindows.Data.Pdfwhen 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 → returnsliteral_fallbackwarning; 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 toolsfs_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.
memory_search記憶搜尋C
依關鍵字/名稱/內容搜尋記憶。
Inputs: query (required).
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.
web_search網頁搜尋A
DuckDuckGo 公開網頁搜尋,回傳標題/URL/摘要。不執行 JS、不讀結果頁正文。
Inputs: query (required), limit.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 21 tools
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.
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.
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.
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
Related MCP Connectors
Private-by-default, local-first memory/context/task orchestrator for MCP apps and agents.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Shared memory for your AI tools: tasks, notes and context every tool can read and write over MCP.
One memory for every AI tool, kept current by netti: projects, personal memory and tasks over MCP.
Related MCP Servers
- FlicenseAqualityDmaintenanceProvides persistent memory for MCP-compatible agents (like Copilot CLI) to save and recall knowledge across sessions, plus long-running monitoring tools.9-
- AlicenseNot gradedqualityFmaintenancePersonal AI cognitive exobrain server providing long-term, emotionally-tagged memory and task management for LLMs via MCP.1MIT
- AlicenseBqualityDmaintenanceAn 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.37MIT
- AlicenseNot gradedqualityCmaintenanceLocal-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