Skip to content

feat: MCP server mode (catchme mcp) - #6

Merged
pancacake merged 1 commit into
HKUDS:mainfrom
salem221094:feat/mcp-server
Apr 25, 2026
Merged

feat: MCP server mode (catchme mcp)#6
pancacake merged 1 commit into
HKUDS:mainfrom
salem221094:feat/mcp-server

Conversation

@salem221094

Copy link
Copy Markdown
Contributor

Summary

This PR implements the feature proposed in #5 — exposing CatchMe's activity tree as a proper MCP (Model Context Protocol) stdio server.

Any MCP-compatible host (Claude Desktop, Cursor, Hermes Agent, Windsurf, etc.) can now use CatchMe as a native tool — no skill files, no shell-parsing prose answers, no lock-in.

Changes

File Change
catchme/mcp_server.py New: MCP stdio server (~160 lines)
catchme/run.py Added cmd_mcp() + catchme mcp CLI entry + help text
pyproject.toml Added mcp[cli]>=1.0 as optional [mcp] extra

Tools Exposed

Tool Description
search_activity(query, date?) Natural-language retrieval — wraps existing retrieve() generator, returns {answer, sources} JSON
list_days() All recorded days with summaries and session counts
get_session(session_id) Full session detail (app/location breakdown, 2 levels deep)
get_tree(date) Raw activity tree JSON for a given day

Installation & Usage

pip install 'catchme[mcp]'
catchme mcp   # starts stdio server, blocks until host disconnects

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "catchme": {
      "command": "catchme",
      "args": ["mcp"]
    }
  }
}

Cursor (.cursor/mcp.json):

{
  "mcpServers": {
    "catchme": { "command": "catchme", "args": ["mcp"] }
  }
}

Design Notes

  • Zero new capture logic — purely an interface layer over existing retrieve(), _load_all_trees(), and _node_index() from pipelines/retrieve.py
  • Optional dependencymcp is not pulled in unless the user explicitly installs catchme[mcp], so the base install is unaffected
  • Graceful error — if mcp is not installed, catchme mcp prints a clear install instruction and exits cleanly instead of crashing with an ImportError
  • stdio transport — matches the standard used by Claude Desktop, Cursor, and most MCP hosts; no port binding, no config needed

Testing

Tested locally with Claude Desktop and the MCP Inspector:

  • list_days() returns correct day summaries
  • search_activity("what was I coding this morning") correctly traverses the tree and returns a structured answer
  • get_session() and get_tree() return correct JSON
  • Missing mcp package produces a clean error message

Happy to adjust the tool schema, add HTTP/SSE transport as an alternative, or split into a smaller first step if preferred.

Exposes CatchMe's activity tree as a proper MCP (Model Context Protocol)
server over stdio transport. Any MCP-compatible host (Claude Desktop,
Cursor, Hermes Agent, etc.) can now use CatchMe as a native tool without
shell-parsing prose answers.

Tools exposed:
- search_activity(query, date?) — LLM-powered retrieval, returns answer + sources
- list_days() — available recorded days with top-level summaries
- get_session(session_id) — full session detail with app/location breakdown
- get_tree(date) — full activity tree JSON for a given day

Changes:
- catchme/mcp_server.py: new MCP stdio server using the `mcp` SDK
- catchme/run.py: added `cmd_mcp()` and `catchme mcp` CLI entry
- pyproject.toml: added `mcp[cli]>=1.0` as optional dep under [mcp] extra

Usage:
  pip install catchme[mcp]
  catchme mcp  # starts stdio server

Claude Desktop config:
  {"mcpServers": {"catchme": {"command": "catchme", "args": ["mcp"]}}}

Closes HKUDS#5
@pancacake

Copy link
Copy Markdown
Collaborator

thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants