Skip to main content
Glama

理脈 limai

理華と理月の共有神経システム——キャラクターから第一原理で抽出した独立器官。

第一原理による導出

キャラクターでの姿

本質

モジュール

MCP ツール

ハートビートポーリング+エラーバックオフ(on_idle.mjs)

リズム

heartbeat.mjs

heartbeat_now・vitals_latest・vitals_history

スクリーンショット/ウィンドウ/クリップボード(screenshot.mjs)

視覚

vision.mjs

screen_capture(画像を返す)・list_windows・read_clipboard

todo-tasks.json+重み付け融合ハートビート

意図

todo.mjs

todo_add・todo_list・todo_update

長期記憶(名前×キーワード×内容)

記憶

memory.mjs

memory_add・memory_search・memory_list・memory_forget

o-pi の6つのファイルツール

ファイル操作

filesys.mjs

fs_ls/read/write/edit/find/grep

o-pi websearch/webfetch

ネットワーク操作

web.mjs

web_search・web_fetch

捨てたもの:キャラクターのLLMタスクプロンプト(人格は移さない)、記憶のJS evalトリガー(安全)。残した本質:重み付きランダムスケジューリング思想→ハートビートバックオフ;STALE_READガード;SSRF対策;有界読み取り。

Related MCP server: qwen-mcp

起動

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

CLIはAIエージェント向けに設計

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 …       # 同前

エージェント契約:

  • 出力はデフォルトJSON、エラーコードはstderrメッセージに前置(STALE_READ: …)、終了コード非ゼロで失敗を表す

  • fs edit の厳格な契約はMCPと同じ:先に fs read が必要;観測状態は fs-state.json に永続化され、 「readプロセス→editプロセス」の呼び出しをまたいでも成立し、外部変更は必ずブロックされる(--forceで回避可)

  • 成功した fs write も観測を確立し、editに接続可能(o-piの「成功write直後」ルールと同じ)

アーキテクチャ上、MCPはコアモジュールの上にあるインターフェースの1つに過ぎない:同じ vision/web/filesys/memory/todo/heartbeat を CLIサブコマンドとMCPツールの両方から呼び出し、2つのインターフェースは同じデータと同じセキュリティ契約を共有する。`

初回実行時に ~/.limai/(config.json・memory.json・todo.json・vitals.*・screenshots/)を自動作成し、tokenを出力する。

クライアント接続

ローカル(stdio)

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

ローカルネットワーク/同一マシンのGPTクライアント(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>" } }

クラウドChatGPT(Connectors/開発者モード)

ChatGPTはあなたのlocalhostにアクセスできないため、公網HTTPSが必要——一行のトンネル:

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

コネクタURLには https://xxxx.trycloudflare.com/mcp?token=<token> を入力(GPT系クライアントはheaderをカスタマイズできないことが多いため、queryでtokenを渡すことをサポート)。 長期的な解決策:Tailscale Funnel(ポート開放不要)またはCaddyリバースプロキシで自前ドメインを使用。

セキュリティ境界

  • ファイル:config.json の allowedRoots に制限;.git は恒久的にブロック;fs_edit は先に fs_read が必要(STALE_READバージョンガード);oldテキストは一意でなければならない

  • ネットワーク:localhost/プライベートネットワーク/link-localを拒否(SSRF)、リダイレクトはホップごとに再チェック、2MB上限、30秒タイムアウト

  • 認証:HTTP全体でBearer/query-token;デフォルトでは127.0.0.1のみにバインド

  • プライバシー:ハートビートはウィンドウタイトル+クリップボードのハッシュのみ記録(変化時は先頭60文字のプレビューを保存);ピクセルスクリーンショットは明示的なscreen_capture呼び出しのみ

ハートビートのセマンティクス(理華を踏襲)

15分に1回(heartbeat.intervalMinで調整可能)。各跳で収集:前景ウィンドウ・ウィンドウリスト(top8)・アイドル秒数・クリップボード変化・未完了TODO数。失敗時は間隔×2(上限8倍)、成功でリセット。ログは vitals.ndjson にローテーション。

上流同期(o-pi)

  • 2026-08-23 チェック:上流の当日の大量コミットは内部リファクタリング(file-tools/web-tools/filesystem/lspの簡素化)であり、6ツール+2つのウェブツールの動作契約は不変;duckduckgo-html-provider は依然としてゼロキーのフォールバックパス——理脈の抽出は依然として忠実。

  • 新機能 read はPDFページ画像をサポート(d762209):理脈は実装を整合済み——fs_read に pages パラメータ(N / N-M / N-)を追加し、ページPNGのMCP画像コンテンツブロックを返す;CLIでは fs read <pdf> --pages "1-5"。メインルートは PDF.js(pdfjs-dist legacy)+@napi-rs/canvas でクロスプラットフォームレンダリング;Windowsで依存関係が読み込めない場合は内蔵WinRT Windows.Data.Pdf に自動フォールバック。デフォルトでは1回の上限20ページ、総ページ数と続き読み位置を含む。

  • skill URI/bashツール/approval gateはPiホスト専用であり、抽出範囲外。

  • 同日の再チェック(d795f92 new approval UI):src/approval/* とTUIのみ変更、file-tools/web-toolsはゼロ変更。これに基づきgrep契約の整合を完了:不正な正規表現は正確なリテラルにフォールバック——ヒットあり→literal_fallback 警告を返す;ゼロヒット→INVALID_REGEX で空結果を偽装しない。テスト済み。

ライセンスと出典(License & Attribution)

本プロジェクトは GNU Affero General Public License v3.0 またはそれ以降(AGPL-3.0-or-later)で公開され、完全な条項は LICENSE を参照。

コード出典の声明:

  • ファイルツール(src/core/filesys.mjs:ls/read/write/edit/find/grep)とウェブツール(src/core/web.mjs:web_search/web_fetch)の動作契約と設計は、Orion-zhen/o-pi(Pi Agentのfile-toolsとweb-toolsの設計文書、AGPL-3.0ライセンス)に由来する。理脈はその本質を独立したNode.jsのゼロ依存実装として実装したもので、コードの複製ではなく、AGPLの同じ条項でオープンソースに還元する。

  • ハートビート/todo/記憶/視覚などの能力プリミティブの抽出の青写真は、steve02081504/fount エコシステムの「理華」キャラクターの能力設計(MITライセンス)に由来する。そのアーキテクチャ思想(アイドルポーリングバックオフ、重み付きタスク、名前×キーワード×内容の記憶)のみを参考にし、コードは複製していない。

  • MCPプロトコル実装は公式の @modelcontextprotocol/sdk に基づく。

  • PDFレンダリングは pdf.js(Apache-2.0)と @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

    ActivityInactive
    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
    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes MCP tools that give desktop agents durable two-tier memory with recall and graph traversal, project code intelligence (symbol lookup, impact walking, notes search), and web search with page-to-Markdown conversion. It also runs a local model gateway that routes Anthropic- and OpenAI-shaped traffic across providers with usage accounting.
      MIT