Skip to main content

MCP server that logs Claude Code work sessions, file edits, and tasks to your Cairn account.

Project description

The Cairn agent (MCP server + hooks)

This folder is the piece that runs on your machine, not on Vercel. It gives Claude Code a set of Cairn tools (log work, list tasks, weekly summaries, and so on) and, if you want, quietly records what you did after every session. Everything here is a thin HTTPS client over your Cairn cloud account — no local database, no second copy of your data.

What's in here:

  • cairn_mcp/ — the Python package, published to PyPI as cairn-mcp:
    • server.py — the MCP server. Eleven tools (work_log_add, task_create, daily_summary, …).
    • client.py — the tiny stdlib HTTP client the server and hooks share. Reads your token, talks to the API.
    • session_logger.py — a SessionEnd hook. Turns a finished Claude Code session into one work-log entry.
    • file_logger.py — a PostToolUse hook. Records a file-activity event whenever Claude writes or edits a file.
  • pyproject.toml — packaging metadata. One dependency, mcp[cli]; one console script, cairn-mcp.
  • .mcp.json, hooks/hooks.json, .claude-plugin/ — the Claude Code plugin wiring.

Easiest: install as a plugin

If you're on Claude Code, skip the manual steps below — this repo is also a plugin marketplace. Two commands from inside Claude Code:

/plugin marketplace add cybort360/cairn
/plugin install cairn@cairn

That registers the cairn MCP server and both auto-logging hooks for you; there's no clone, no venv, and no claude mcp add. One prerequisite: the plugin runs the server through uv, so you need uv on your PATH (curl -LsSf https://astral.sh/uv/install.sh | sh). uv pulls mcp[cli] on its own, so you never manage a Python env.

You still need to drop your token in once — see step 2 of the manual install for where to get it:

printf '%s' 'PASTE_YOUR_TOKEN' > ~/.cairn_token && chmod 600 ~/.cairn_token

From PyPI (any MCP client)

Not on Claude Code, or want the server without the plugin? The package is on PyPI, so uv can run it with nothing to clone or install:

claude mcp add cairn --scope user -- uvx cairn-mcp

uvx cairn-mcp is the command any MCP client can point at; uvx fetches the package and its deps on first run. Save your token first (see step 2 below). For a different client, use its own config — the command is the same.

Manual, from source

For when you'd rather not use uv at all. You need Python 3.10+ and the Claude Code CLI.

1. Clone and install the package into a venv.

git clone https://github.com/cybort360/cairn.git
cd cairn/agent
python3 -m venv .venv
.venv/bin/pip install .

That puts a cairn-mcp console script in .venv/bin/.

2. Get your API token. Sign in at the Cairn web app, open the account menu, and copy your API token. Save it where the client looks for it:

printf '%s' 'PASTE_YOUR_TOKEN_HERE' > ~/.cairn_token
chmod 600 ~/.cairn_token

(You can set CAIRN_TOKEN in the environment instead if you'd rather not write a file. The client checks CAIRN_TOKEN first, then ~/.cairn_token.)

3. Register the server with Claude Code. Point it at the console script. --scope user makes the cairn tools available in every project, not just this one:

claude mcp add cairn --scope user -- "$(pwd)/.venv/bin/cairn-mcp"

4. Check it connected.

claude mcp list

You want to see cairn: … ✔ Connected. Inside a session the tools show up as mcp__cairn__work_log_add, mcp__cairn__task_list, and the rest.

That's the whole install. The hooks below are optional.

Optional: auto-logging hooks

The plugin install already wires these up. Set them by hand only if you went the manual route. The two hooks make Cairn fill itself in without you calling a tool: session_logger writes one entry summarizing each session when it ends; file_logger notes every file Claude touches. Both fail silently — a dropped network call or a missing token never interrupts your work. They use only the standard library, so plain python3 runs them; no mcp needed.

Wire them into Claude Code's settings (~/.claude/settings.json for all projects). The commands run the package modules, so they need cairn_mcp on the path — cd into wherever you cloned ($HOME/cairn/agent assumes ~/cairn; adjust it):

{
  "hooks": {
    "SessionEnd": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "cd \"$HOME/cairn/agent\" && python3 -m cairn_mcp.session_logger 2>/dev/null || true",
            "timeout": 15,
            "statusMessage": "Logging session to Cairn"
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Write|Edit|MultiEdit",
        "hooks": [
          {
            "type": "command",
            "command": "cd \"$HOME/cairn/agent\" && python3 -m cairn_mcp.file_logger 2>/dev/null || true",
            "timeout": 10
          }
        ]
      }
    ]
  }
}

A hard kill (crash, power loss, kill -9) skips the SessionEnd hook, so that one session won't be logged. Everything else — the normal exit, /clear, /logout, Ctrl-D — fires it.

Pointing at a different backend

By default the client talks to production. Override it with CAIRN_API_URL if you're running the web app locally or against a staging deploy:

export CAIRN_API_URL="http://127.0.0.1:8765"

The MCP server reads it the same way, so set it in the claude mcp add environment (-e CAIRN_API_URL=…) if you want the tools pointed somewhere other than prod.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cairn_mcp-0.1.0.tar.gz (69.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cairn_mcp-0.1.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file cairn_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: cairn_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 69.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cairn_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 42630de1c54ccd95d118b31a9ac2af00eacc867badc59c8c4109121c58434b5f
MD5 2530b03af6075f574c599897422f48d1
BLAKE2b-256 49d4d9d97d9b4210a56737ac3f523a5c724871245382bd2d2b6d9789ef2e55cc

See more details on using hashes here.

File details

Details for the file cairn_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cairn_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cairn_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8570125b9ac5b2b820e936bbde6a863760927a0ff5756988822c0e356f8c265
MD5 e30b3e7c1ffe2bd9da32f11289530138
BLAKE2b-256 9763a4f35439054f20a00fe9df3724988343d3a728b38bda74e046052dd3d75e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page