cosmos
The Cosmos MCP server lets AI agents read from and write to a personal knowledge graph — a shared "exocortex" of durable facts about you that persists across all your AI tools.
Read tools:
polarity_whoami: Verify which user account the MCP key is bound to (cheap connectivity probe).polarity_export: Download your entire personal knowledge graph as structured JSON.polarity_get_graph: Read a scoped graph projection — your self-image (user), the system's observations (cosmos), or the comparison between the two (polarity).polarity_ask: Ask a natural-language question and get a synthesized answer with cited node/edge IDs drawn from your graph.
Write tools:
polarity_observe: Record any durable observation (preferences, frustrations, project context) with optional tags, confidence score, and kind.polarity_record_event: Log a timestamped event (meeting, shipped release, incident).polarity_record_preference: Persist a stated like, dislike, opinion, or working-style rule across sessions.polarity_capture_turn: Submit a full user/assistant exchange for automatic extraction of all durable observations — preferred over multiple individualpolarity_observecalls.polarity_dump: Write a short message anchored to a specific location waypoint.polarity_checkin: Record that the user is present at a waypoint, triggering co-presence detection.polarity_declare: Declare future presence at a waypoint for a given time window (e.g.,next_30,tonight).
Data sources such as iMessage, Claude Desktop, shell history, Notion, and Obsidian all feed into the same graph. The graph lives in your .polarity file — you own the key.
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.
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:
npx -y @polarity-lab/cosmos-mcp install-handlerThis 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:
npx -y @polarity-lab/cosmos-mcp provision pmk_xxxThe 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.
npx -y @polarity-lab/cosmos-mcp imessage probeVerifies 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.
Install
npx -y @polarity-lab/cosmos-mcp initOpens 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:
{
"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
Tool | Calls | What it returns |
|
| Bound user + scopes. Cheap probe. |
|
| Full personal graph as |
|
| Graph view, scoped by entity ( |
|
| NL question synthesized over the graph. |
Write
Tool | Calls | What it does |
|
| Freeform observation. Cosmos extracts. |
|
| Something happened at a point in time. |
|
| A like, dislike, working-style rule. |
|
| Hand a whole user/assistant exchange to cosmos. Pulls every durable observation in one call. Prefer over multiple |
|
| Location-anchored short message. |
|
| Check-in at a waypoint. Triggers co-presence detection. |
|
| Declare 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.
Source | How it connects | What lands |
iMessage | Local CLI: | Conversational turns from |
Claude Desktop | Local CLI: | Every Claude Code session becomes a thread node; user and assistant turns land in |
Shell history | Local CLI: | Each sync window lands as one |
Notion | OAuth at cosmos.polarity-lab.com/connectors. Pick the pages and databases you want shared. | Each Notion page becomes a |
Obsidian | Community plugin: polarity-lab/obsidian-cosmos. Paste your | Each note becomes a |
MCP clients | This package. | Observations, events, preferences, location dumps, check-ins, declarations. |
Direct API |
| 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.
# default: incremental sync, 90-day window on first run
npx -y @polarity-lab/cosmos-mcp imessage sync
# re-sync the original 90-day window regardless of watermark
npx -y @polarity-lab/cosmos-mcp imessage sync --backfill
# pull everything since a specific date
npx -y @polarity-lab/cosmos-mcp imessage sync --since 2024-01-01
# check what the last run did
npx -y @polarity-lab/cosmos-mcp imessage statusA 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.
# default: incremental, watermarked per session
npx -y @polarity-lab/cosmos-mcp claude-desktop sync
# limit to recent activity
npx -y @polarity-lab/cosmos-mcp claude-desktop sync --since 2026-05-01
# scan and report without shipping
npx -y @polarity-lab/cosmos-mcp claude-desktop sync --dry-run
# see what the last run did
npx -y @polarity-lab/cosmos-mcp claude-desktop statusTool-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.
npx -y @polarity-lab/cosmos-mcp daemon installAfter install, grant the bundle Full Disk Access once:
open System Settings → Privacy & Security → Full Disk Access
click +, then drag
~/Applications/Cosmos Sync.appinto the listmake sure the checkbox next to it is on
run
cosmos-mcp daemon kickto 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 var | Default | When you set it |
|
| Override the cosmos API endpoint. |
| (from keychain) |
|
| (from token file) |
|
| (from token file) | Polarity user id. |
| (unset) | Single-tenant mode. Sends |
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.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/teampolarity/cosmos-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server