Cosmos Mcp

io.github.teampolarity由 GitHub 帳號 teampolarity 發布v0.7.1更新於 Oct 24, 2026

Personal knowledge graph every MCP client reads from and writes to. Portable across agents.

概覽

AI 產生的概覽

讓助理讀寫個人的 Cosmos 知識圖譜,使觀察、事件與偏好能在多個 MCP 用戶端之間持續保留。

可以做什麼
提供十一個工具:四個讀取工具(whoami、export、get_graph、ask)與七個寫入工具(observe、record_event、record_preference、capture_turn、reconstruct_hours、dump、checkin、declare),用來把觀察、事件、偏好、位置紀錄與簽到寫入 Cosmos 圖譜。命令列另提供 iMessage、Claude Code 工作階段紀錄、shell 歷史、瀏覽器與行事曆的本機同步子命令,以及 macOS 背景守護程序。圖譜存放在使用者的 Cosmos 帳號中,設計上可跨用戶端攜帶。
適用情境
當你希望多個 MCP 用戶端(Claude Code、Claude Desktop、Cursor、Codex、Zed、Continue)共用一個記憶層,而不是各自保留私有上下文時,適合使用。也適合想把本機訊息、筆記或 shell 歷史匯入該圖譜的使用者。若只需要單一用戶端的工作階段記憶,則幫助不大。
執行需求
透過 npx 執行 npm 套件 @polarity-lab/cosmos-mcp 的本機 Node.js 程序,使用 stdio 傳輸。需要從 Cosmos 連接器頁面取得 pmk_ 金鑰,以 COSMOS_TOKEN 提供或存入 macOS 鑰匙圈;可選變數包括 COSMOS_URL、COSMOS_MCP_KEY、COSMOS_USER_ID 與 COSMOS_SYSTEM_KEY。需要連線至 cosmos.polarity-lab.com。macOS 專屬功能(鑰匙圈、深層連結處理器、背景守護程序、iMessage 與行事曆同步)需要完整磁碟存取權。
安裝前請注意
此伺服器需要 pmk_ 金鑰(COSMOS_TOKEN 或鑰匙圈項目),並可讀取敏感的本機資料:iMessage 的 chat.db、行事曆、瀏覽器歷史、shell 歷史以及 Claude Code 工作階段紀錄,這些內容會傳送到 Cosmos 服務。macOS 同步需要為終端機或 Cosmos Sync.app 授予完整磁碟存取權。一鍵安裝指令碼會註冊 URL scheme、改寫用戶端設定並安裝背景 LaunchAgent,建議先用 --dry-run 檢查。寫入類工具會把資料加入圖譜。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Cosmos Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[Polarity]

cosmos-mcp

One exocortex. Every agent.
MCP server for your Cosmos graph.

[npm] [license] [site] [glama]


Every AI you use is building its own private graph of you. Claude has one. ChatGPT has one. Cursor has one. None of them talk to each other, and none of them are yours.

Cosmos inverts that. Your knowledge graph lives in one place, and any MCP-capable client (Claude Code, Claude Desktop, Cursor, Codex, Zed, Continue) reads and writes to the same one. When an agent notices something durable about you, it lands in the graph. When you switch tools, the graph follows. The user, not the platform, owns the integration layer.

The thing you carry is a .polarity file. Yours.

One-line install

bash
curl -fsSL https://mcp.polarity-lab.com/install.sh | sh

On macOS this installs the MCP server, registers cosmos-mcp://, wires Claude Desktop, Claude Code, Cursor, Codex, Zed, and Continue, then installs Cosmos Sync.app so iMessage, browser history, calendar, Claude Desktop transcripts, and shell history can sync in the background. On linux and windows it installs the MCP server path only.

If you want to inspect before changing anything:

bash
curl -fsSL https://mcp.polarity-lab.com/install.sh -o install.shbash install.sh --dry-runbash install.sh

Provisioning

There are two ways to get a pmk_… key onto your Mac.

Automatic. Sign in at cosmos.polarity-lab.com/connectors, tap "open in cosmos-mcp." The OS opens a one-shot handler that writes the key into your system keychain. You never see the raw key.

For that deep link to work, register the URL scheme once:

bash
npx -y @polarity-lab/cosmos-mcp install-handler

This drops a tiny .app into ~/Library/Application Support/cosmos-mcp/ and registers cosmos-mcp:// with Launch Services. macOS-only.

Manual. If you already have a pmk_… key, or you do not want to install the handler:

bash
npx -y @polarity-lab/cosmos-mcp provision pmk_xxx

The CLI validates the key against cosmos, then stores it in the macOS system keychain under service cosmos-mcp-key. Subsequent imessage sync, browser sync, calendar sync calls read from the keychain. No env var needed.

Confirm iMessage access.

bash
npx -y @polarity-lab/cosmos-mcp imessage probe

Verifies Full Disk Access is granted and reports how many chats are visible. If you see an EACCES message, open System Settings, Privacy & Security, Full Disk Access, and add Terminal (or whichever app runs the CLI).

CI. Set COSMOS_TOKEN=pmk_… in env. It takes precedence over the keychain, so existing pipelines keep working untouched.

Manual MCP config

The installer handles this for common clients. If you want to wire a client by hand, point it at the package.

bash
npx -y @polarity-lab/cosmos-mcp init

This opens your browser. Sign in at cosmos.polarity-lab.com, approve a per-user key, and the token lands at ~/.config/cosmos-mcp/token (0600). Then point any MCP client at it:

json
{  "mcpServers": {    "cosmos": {      "command": "npx",      "args": ["-y", "@polarity-lab/cosmos-mcp"]    }  }}

That config drops into ~/Library/Application Support/Claude/claude_desktop_config.json for Claude Desktop, your .cursor/mcp.json for Cursor, the equivalent for whichever client.

What you get

Eleven tools, four read, seven write.

Read

ToolCallsWhat it returns
polarity_whoamiGET /api/polarity/whoamiBound user + scopes. Cheap probe.
polarity_exportPOST /api/polarity/exportFull personal graph as polarity/v1 JSON.
polarity_get_graphGET /api/polarityGraph view, scoped by entity (user, cosmos, polarity).
polarity_askPOST /api/polarity/askNL question synthesized over the graph.

Write

ToolCallsWhat it does
polarity_observePOST /api/polarity/observeFreeform observation. Cosmos extracts.
polarity_record_eventPOST /api/polarity/observe (kind=event)Something happened at a point in time.
polarity_record_preferencePOST /api/polarity/observe (kind=preference)A like, dislike, working-style rule.
polarity_capture_turnPOST /api/polarity/capture-turnHand a whole user/assistant exchange to cosmos. Pulls every durable observation in one call. Prefer over multiple polarity_observe calls.
polarity_reconstruct_hoursPOST /api/polarity/reconstruct-hoursPersist life-hour receipts onto the skill-map sky (per user only). Use from Cursor/Cosmos IDE after substantive work.
polarity_dumpPOST /api/polarity/dumpLocation-anchored short message.
polarity_checkinPOST /api/polarity/checkinCheck-in at a waypoint. Triggers co-presence detection.
polarity_declarePOST /api/polarity/declareDeclare future presence at a waypoint.

Sources

The MCP server is one way to write to the graph. Cosmos accepts source pages from anywhere you keep notes, and the MCP read tools see all of it through the same view.

SourceHow it connectsWhat lands
iMessageLocal CLI: npx -y @polarity-lab/cosmos-mcp imessage sync. Mac only. Grant Terminal Full Disk Access first.Conversational turns from chat.db, with text content. People appear as person nodes in your graph, sized by conversation weight, named via your local AddressBook, dated by your real message timestamps.
Claude DesktopLocal CLI: npx -y @polarity-lab/cosmos-mcp claude-desktop sync. Reads Claude Code session transcripts at ~/.claude/projects/.Every Claude Code session becomes a thread node; user and assistant turns land in conversation_turns with full text. Tool-use plumbing is stripped client-side.
Shell historyLocal CLI: npx -y @polarity-lab/cosmos-mcp shell-history sync. Reads ~/.zsh_history (falls back to bash/fish) with a byte-offset watermark.Each sync window lands as one source_page keyed by shell-history:<sync-iso>, body = newline-joined commands. Trivial commands (ls, cd .., single chars) and consecutive duplicates are filtered client-side.
NotionOAuth at cosmos.polarity-lab.com/connectors. Pick the pages and databases you want shared.Each Notion page becomes a source_page node, keyed by Notion id, kept fresh by a daily sync.
ObsidianCommunity plugin: polarity-lab/obsidian-cosmos. Paste your pmk_ key, point at your vault.Each note becomes a source_page node keyed by vault-relative path. Tags and wikilinks resolve into edges.
MCP clientsThis package.Observations, events, preferences, location dumps, check-ins, declarations.
Direct APIPOST /api/polarity/observe with your key.Anything you can express as an observation.

Unchanged pages are skipped server-side, so re-syncing a quiet vault or stable Notion workspace costs almost nothing. The iMessage sync is incremental too, watermarked on the last successful run, so re-running it is a no-op until new messages arrive.

iMessage sync

cosmos-mcp ships an imessage subcommand that reads your local Messages database and lands every conversation in your graph.

bash
# default: incremental sync, 90-day window on first runnpx -y @polarity-lab/cosmos-mcp imessage sync
# re-sync the original 90-day window regardless of watermarknpx -y @polarity-lab/cosmos-mcp imessage sync --backfill
# pull everything since a specific datenpx -y @polarity-lab/cosmos-mcp imessage sync --since 2024-01-01
# check what the last run didnpx -y @polarity-lab/cosmos-mcp imessage status

A three-rule slop filter (no-reply senders, short-code numbers, low-volume contacts) keeps the graph clean. Your AddressBook resolves phone numbers and emails into real contact names. The reading is local to your Mac; only the extracted, normalized turns go into your cosmos graph, which is your account.

Claude Desktop sync

cosmos-mcp ships a claude-desktop subcommand that watches Claude Code session transcripts and lands each turn in your graph. The desktop chat surface itself stores conversations server-side, so the live, watchable on-disk source is ~/.claude/projects/<encoded-cwd>/<session-id>.jsonl.

bash
# default: incremental, watermarked per sessionnpx -y @polarity-lab/cosmos-mcp claude-desktop sync
# limit to recent activitynpx -y @polarity-lab/cosmos-mcp claude-desktop sync --since 2026-05-01
# scan and report without shippingnpx -y @polarity-lab/cosmos-mcp claude-desktop sync --dry-run
# see what the last run didnpx -y @polarity-lab/cosmos-mcp claude-desktop status

Tool-use blocks, hook plumbing, and sub-agent (sidechain) turns are stripped client-side; only the visible text the user and the assistant exchanged is shipped. Each session id becomes its own thread node, keyed by (user_id, "claude-desktop", session_id).

Background sync (macOS)

cosmos-mcp daemon install drops a LaunchAgent that ticks every four hours and runs the browser, iMessage, calendar, claude-desktop, and shell-history syncs back-to-back. The agent fires a signed, notarized Cosmos Sync.app bundle that ships inside the npm package and gets copied into ~/Applications/Cosmos Sync.app at install time.

bash
npx -y @polarity-lab/cosmos-mcp daemon install

After install, grant the bundle Full Disk Access once:

  1. open System Settings → Privacy & Security → Full Disk Access
  2. click +, then drag ~/Applications/Cosmos Sync.app into the list
  3. make sure the checkbox next to it is on
  4. run cosmos-mcp daemon kick to fire a tick now

Browser sync works without that step. iMessage and Calendar need it because they read TCC-protected SQLite databases on the user side. cosmos-mcp daemon status reports the signing team id, the plist + runner paths, and whether launchd has the agent loaded. cosmos-mcp daemon uninstall removes the plist, runner, and ~/Applications/Cosmos Sync.app.

Configuration

Env varDefaultWhen you set it
COSMOS_URLhttps://cosmos.polarity-lab.comOverride the cosmos API endpoint.
COSMOS_TOKEN(from keychain)pmk_... per-user key for CLI subcommands. Takes precedence over the macOS keychain entry. Set this in CI.
COSMOS_MCP_KEY(from token file)pmk_... per-user key. Honored for back-compat.
COSMOS_USER_ID(from token file)Polarity user id.
COSMOS_SYSTEM_KEY(unset)Single-tenant mode. Sends X-System-Key instead of X-MCP-Key. Requires COSMOS_USER_ID. For internal testing before per-user keys are deployed.

The pitch in three lines

Your AI tools each know fragments of you. They are not allowed to share. Cosmos is the layer that lets them. You hold the key. The graph is portable. When you leave, you take the understanding with you.

License

MIT.

來源:README.md,提交 3d04c64

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.7.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分