LINE Context Relay

LINE Context Relay

A read-only MCP server that connects ChatGPT/Codex to LINE Desktop's local encrypted database to provide private conversation advice without sending messages.

Category
访问服务器

README

LINE Context Relay

LINE Context Relay — Read-only AI Chat Advisor for ChatGPT, Codex and MCP Agents<br> LINE Context Relay — 給 ChatGPT、Codex 與 MCP Agent 使用的唯讀 LINE 聊天顧問

繁體中文 · English · Security · Privacy · MIT License

A local-first, read-only LINE conversation assistant for macOS. It connects ChatGPT/Codex to LINE Desktop's local encrypted database through a narrowly allow-listed MCP server, refreshes the target chat using database evidence, builds private relationship context, and suggests whether and how to reply.

It never sends a LINE message.

Unofficial community project. Not affiliated with, endorsed by, or sponsored by LINE Corporation or OpenAI. Use only with your own account and data, and review the relevant product terms before use.

English

What this project does

LINE Context Relay turns a Mac running LINE Desktop and ChatGPT/Codex into a private conversation-advice workflow:

flowchart LR
    U["User or ChatGPT Remote"] --> C["ChatGPT / Codex on Mac"]
    C --> M["Allow-listed line-readonly MCP"]
    M --> S["Stable DB + WAL + SHM snapshot"]
    S --> R["Bounded chat history"]
    R --> X["Private local relationship context"]
    X --> A["One reply decision or suggestion"]
    A --> C

With ChatGPT Remote enabled in the user's desktop/mobile setup, a request can start from a phone, run on the paired Mac, read the local LINE context, and return a suggestion to ChatGPT. Remote availability, locked-computer behavior, and pairing depend on the installed ChatGPT version and must be verified on the user's own devices. The Mac must be powered on, online, and signed into a usable graphical session for LINE refresh actions.

The project is intentionally an advisor, not a bot that sends messages. Reply text is displayed in ChatGPT/Codex only.

Core features

  • Stable copies of LINE's encrypted main DB and present WAL/SHM sidecars
  • SQLITE_OPEN_READONLY and query_only on the private snapshot only
  • Login Keychain-only database key retrieval
  • Exact display-name or chatId resolution; ambiguous names fail closed
  • Bounded history reads with stable timestamp/message-ID cursor pagination
  • Target-specific latest-message refresh using DB evidence
  • First-full-then-incremental local relationship context
  • Optimistic context versions to prevent stale task overwrites
  • A global line-chat-advisor Codex skill
  • No send tool, generic input tool, arbitrary app target, OCR, screenshot, Shell MCP, or AppleScript MCP

Safety architecture

The MCP exposes exactly eight operations:

Tool Purpose Writes LINE source DB?
line_status Verify DB discovery, Keychain access, decryption, and snapshot state No
list_chats List recent exact chat candidates No
read_history Read bounded history and deduplicate it into private local memory No
refresh_latest Passively poll, then activate or launch only LINE if needed No
get_relationship_context Read private local semantic context No
save_relationship_context Save bounded context to local memory with cursor/version checks No
sync_older_messages Optional, constrained older-history backfill; not used for normal reads No
line_health Return redacted diagnostics No

read_history and save_relationship_context may write to the ignored local memory database. They never modify LINE's source DB. See PRIVACY.md and AUDIT.md for the detailed boundary.

Requirements

  • macOS with LINE Desktop installed and signed in
  • ChatGPT desktop with Codex/MCP support
  • Node.js 20 or later
  • Homebrew Python 3.14 compatible with the pinned apsw-sqlite3mc wheel
  • Xcode Command Line Tools, Swift, LLDB, and Git
  • macOS Login Keychain access
  • Accessibility permission for the pinned local Peekaboo build; Screen Recording may also be requested by Peekaboo even though ordinary chat text comes from the DB, not screenshots
  • Optional: ChatGPT Remote paired between the phone and Mac

Installation

git clone https://github.com/LEO0047/line-chat-advisor-mcp-ai-assistant.git
cd line-chat-advisor-mcp-ai-assistant
scripts/bootstrap
scripts/build-peekaboo

scripts/bootstrap clones the three commits in VENDOR_LOCK.md without executing vendor code, installs hash-pinned Python and lockfile-pinned Node dependencies, and runs the tests. scripts/build-peekaboo separately builds only the reviewed Peekaboo commit into the ignored runtime/ directory.

Register the MCP in ~/.codex/config.toml, replacing the placeholder with the absolute clone path:

[mcp_servers.line-readonly]
command = "/opt/homebrew/bin/node"
args = ["<absolute-project-path>/src/line-readonly-mcp/server.mjs"]

Install the global skill without copying private state:

mkdir -p "$HOME/.codex/skills"
ln -s "$(pwd)/skills/line-chat-advisor" "$HOME/.codex/skills/line-chat-advisor"

Do not overwrite an existing skill path without reviewing it. Restart/reload ChatGPT/Codex after changing MCP or skill configuration.

One-time key capture

LINE's local DB is encrypted. The project includes a deliberately isolated, user-assisted capture path that stores the validated key directly in Login Keychain and removes temporary artifacts:

scripts/prepare-key-capture
# Sign in only to the visible temporary LINE copy.
scripts/capture-key
scripts/cleanup-key-capture   # safe to run again if cleanup is needed

Read SECURITY.md and AUDIT.md first. Never paste the key into a terminal command, .env, issue, log, prompt, or repository. The technique may break after LINE/macOS updates and may be subject to LINE's terms; use it only on your own Mac and account.

Verify and run

npm run test
scripts/doctor
npm start

After reloading Codex, prompts such as these trigger the global skill:

Read the latest LINE messages from <exact contact name>, use the full
relationship context, tell me whether I should reply, and if so give me only
one reply in my style. Do not send it.

The skill requires this sequence:

line_status → refresh_latest → get_relationship_context → read_history
            → save_relationship_context

If freshness cannot be proven, it stops instead of presenting stale content as current. If a reply is needed, it returns only one sentence. Otherwise it returns 現在不用回。

Repository contents

  • src/line-readonly-mcp/ — Python DB bridge and Node MCP server
  • src/key-capture/ — isolated Keychain/key-validation helpers
  • skills/line-chat-advisor/ — global Codex skill source
  • scripts/ — bootstrap, build, doctor, capture, and cleanup commands
  • tests/ — Python and real stdio MCP tests
  • AUDIT.md — upstream security review
  • VENDOR_LOCK.md — source URLs and reviewed commits
  • ACCEPTANCE.md — sanitized verification status

Dependencies, vendor working copies, build outputs, databases, snapshots, screenshots, logs, keys, local memory, and contact material are intentionally excluded from Git. They are recreated locally or remain private.

Development

npm run test
scripts/doctor
git diff --check

Before changing a vendor pin, repeat the security audit. Never add a message send path or a generic GUI/keyboard tool to the MCP allow-list.

License

Original code in this repository is released under the MIT License. Fetched upstream projects remain under their own licenses. Their source, license, and reviewed commit are listed in VENDOR_LOCK.md.


繁體中文

這是什麼

LINE Context Relay 是 macOS 上的本機優先、唯讀 LINE 聊天輔助機器人。 它透過受限 MCP 讓 ChatGPT/Codex 讀取 LINE Desktop 的本機加密資料庫,先用 DB 證據刷新精確目標聊天室,再結合完整關係脈絡,判斷現在該不該回;需要回覆 時只提供一句最像使用者的版本。

本專案永遠不會傳送 LINE 訊息。 建議只顯示在 ChatGPT/Codex。

若使用者的 ChatGPT 桌面版與手機已啟用並配對 ChatGPT Remote,可以由手機送出 任務,讓配對的 Mac 執行本機 LINE 讀取,再把建議帶回 ChatGPT。Remote、Locked Use 與鎖定畫面下的實際可用性會隨版本與裝置狀態改變,必須在自己的設備實測; Mac 仍需開機、連網,且已登入可用的圖形工作階段。

主要能力

  • 對 LINE 主 DB、WAL、SHM 建立穩定私人副本
  • 只用 SQLITE_OPEN_READONLYquery_only 開啟副本
  • 解密金鑰只從 macOS Login Keychain 取得
  • 精確名稱/chatId 解析,重名就停止而不是猜測
  • 有上限的歷史讀取與 timestamp/message-ID cursor 分頁
  • 以目標聊天室 DB 前進證據判定最新同步
  • 第一次完整讀取,之後依 cursor 增量更新關係脈絡
  • context version 防止不同 Codex task 互相覆蓋新版摘要
  • 全域 line-chat-advisor skill
  • 沒有 send_message、通用輸入、任意 app、OCR、截圖、Shell MCP 或 AppleScript MCP

安全資料流

一般讀取固定依序執行:

line_status → refresh_latest → get_relationship_context → read_history
            → save_relationship_context

refresh_latest 只有在目標聊天室的 timestamp/message ID 前進時才成功;若無法 證明資料已刷新,skill 會停止,不會拿舊訊息假裝最新。read_historysave_relationship_context 只會寫入被 Git 忽略、權限為 0600 的本機記憶, 永遠不會修改 LINE 來源 DB。

安裝

git clone https://github.com/LEO0047/line-chat-advisor-mcp-ai-assistant.git
cd line-chat-advisor-mcp-ai-assistant
scripts/bootstrap
scripts/build-peekaboo

scripts/bootstrap 會依 VENDOR_LOCK.md 下載三個經審查的固定 commit,不執行 vendor 程式,接著安裝 lockfile/hash 鎖定依賴並跑測試。 Peekaboo 必須用獨立指令明確建置,產物只放在被忽略的 runtime/

~/.codex/config.toml 註冊 MCP:

[mcp_servers.line-readonly]
command = "/opt/homebrew/bin/node"
args = ["<專案絕對路徑>/src/line-readonly-mcp/server.mjs"]

安裝全域 skill:

mkdir -p "$HOME/.codex/skills"
ln -s "$(pwd)/skills/line-chat-advisor" "$HOME/.codex/skills/line-chat-advisor"

修改 MCP 或 skill 後必須重新載入 ChatGPT/Codex,已開啟的 task 不會自動更新 啟動時載入的工具清單。

一次性金鑰擷取

LINE 本機 DB 有加密。專案提供隔離、需要使用者配合的一次性流程,驗證後直接 把金鑰寫入 Login Keychain,並刪除暫存檔:

scripts/prepare-key-capture
# 只登入畫面上可見的暫時 LINE 副本
scripts/capture-key
scripts/cleanup-key-capture

執行前請完整閱讀 SECURITY.mdAUDIT.md。金鑰不可 放入命令列、.env、Issue、log、prompt 或 Git。這項技術可能因 LINE/macOS 更新 失效,也可能受到 LINE 使用條款限制;只能用於自己的 Mac、帳號與資料。

驗證與使用

npm run test
scripts/doctor
npm start

重新載入 Codex 後,可使用:

讀取 LINE:<聯絡人精確名稱> 的最近訊息,結合完整關係脈絡,告訴我現在該不該回;
需要回覆時只給我一句最像我的版本,不要傳送。

需要回覆時只會輸出一句建議;不需要時只輸出 現在不用回。;刷新或安全條件 不成立時只回報阻塞原因,不會改用 Computer Use、OCR 或舊快照。

隱私與公開範圍

以下內容永遠不進 Git:LINE DB/WAL/SHM、Keychain 金鑰、擷取候選值、聊天內容、 chatId、聯絡人名稱、截圖、OCR、log、本機 memory、dependency tree、vendor working copy、binary 與 build artifacts。詳細規則見 PRIVACY.md

授權

本 repo 的原創程式採 MIT License。透過 bootstrap 下載的第三方專案 仍使用各自授權;來源、license 與固定 commit 請見 VENDOR_LOCK.md

本專案是非官方社群工具,與 LINE Corporation、OpenAI 無隸屬、贊助或背書關係。

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选