hoocal
An AI-agent-managed calendar service with bidirectional Google Calendar and Apple iCloud sync, enabling calendar and event management via MCP tools.
README
hoocal
An AI-agent-managed calendar service with bidirectional Google Calendar + Apple iCloud sync.
An AI agent connects over MCP (Model Context Protocol) and fully manages calendars and events — create / read / update / delete, reschedule, search, query availability. The agent reads and writes a local canonical store; a background sync engine reconciles that store with the user's real Google and iCloud calendars in both directions.
Architecture
Three logical layers, four runtime processes (one Docker image, APP env selects the entrypoint):
| Layer | Package / App | Responsibility |
|---|---|---|
| Agent interface | apps/mcp-server |
MCP Streamable-HTTP server; 12 calendar tools; local store only (never imports providers/sync — enforced by dependency-cruiser) |
| Core | packages/core |
Canonical PostgreSQL store, local↔remote mapping, RLS multi-tenancy, availability compute |
| Sync engine | packages/sync-engine + apps/sync-worker |
BullMQ bidirectional reconciliation; Google + iCloud adapters behind one CalendarProvider interface |
apps/webhook-receiver |
Google events.watch push receiver |
|
apps/onboarding-web |
User-driven Google OAuth + iCloud app-password capture (credentials never touch the agent) |
Supporting packages: @hoocal/shared (pure types/errors/utils), @hoocal/ical-codec
(RFC 5545 ↔ canonical), @hoocal/providers (adapters), @hoocal/auth-server (inbound MCP
OAuth 2.1 resource server), @hoocal/credentials (outbound provider secrets), @hoocal/contracts
(Zod tool schemas).
See the implementation plan for the full design and milestone roadmap.
Status — M0–M5 implemented ✅
All milestones are built and tested (73 unit tests + integration tests against real Postgres & Redis; full build / typecheck / module-boundary / lint gate green):
- M0 Scaffold — monorepo, full Drizzle schema (9 tables, enums, indexes, RLS), docker-compose, migration runner.
- M1 Google pull —
CalendarProviderinterface,GoogleAdapter(incrementalsyncToken+ 410 full-resync), DST-correct recurrence codec, envelope-encrypted credentials, pull pipeline (idempotent, watermark-in-tx). - M2 MCP + auth + reads — multi-tenant Streamable-HTTP MCP server, OAuth 2.1 resource server + PRM, session→user binding, 5 read tools, RLS tenant isolation (proven via a real MCP client).
- M3 Writes + push — 7 write tools (is_writable gating, two-phase confirm), agent-write store methods, idempotent push pipeline, Google OAuth onboarding with encrypted credential storage.
- M4 Bidirectional + webhooks — 3-stage echo suppression, LWW + SEQUENCE conflict resolution + journal, 412 handling, BullMQ scheduler/worker + per-unit advisory lock (Redis-tested), Google
events.watchwebhook receiver, fallback poll. - M5 iCloud + hardening —
ICloudAdapter(tsdav, full-PUT, capability errors), RFC 5545 ics codec (round-trip incl. TZID + master/override), iCloud onboarding, a shared adapter contract suite proving Google + iCloud satisfy one spec, and a live Radicale CalDAV integration test of the real transport.
Recurrence + sync edge cases (all implemented):
- Per-instance recurring edits —
delete scope: this(EXDATE),update scope: this(detach the occurrence into a standalone event + EXDATE), andthisAndFuture(split the series, preserving a COUNT-bounded remainder). All sync cleanly to both providers. - iCloud RECURRENCE-ID overrides — a resource's master + override VEVENTs pull as distinct events; writes use read-merge-write so editing one VEVENT never clobbers the others.
- iCloud delete-detection — an href/etag snapshot (carried in the watermark) detects server-side deletions; an unchanged CTag is a cheap no-op.
- Google
events.watch— the sync-worker registers and renews push channels before the 7-day TTL whenWEBHOOK_PUBLIC_URLis configured; otherwise the fallback poll runs.
Representation note: an agent-modified single occurrence is stored as a detached standalone event (master EXDATE + new event) rather than a provider-native exception — functionally equivalent and round-trips cleanly through both providers.
Develop
Requires Node ≥ 20, pnpm 11, Docker.
pnpm install
cp .env.example .env # fill in secrets as needed
# Bring up infra + all 4 services (runs migrations first)
pnpm compose:up
# Or run the toolchain locally
pnpm build
pnpm typecheck
pnpm depcruise # architectural boundary checks
pnpm test
# Database
pnpm db:generate # regenerate SQL migrations from the schema
pnpm db:migrate:dev # apply migrations (tsx, no build needed) + FORCE RLS
Health endpoints: mcp-server :8080/health, sync-worker :8081/health,
webhook-receiver :8082/health, onboarding-web :8083/health.
Testing philosophy
Sync is tested without hammering real providers: a local Radicale CalDAV server is the
iCloud mock, Google is mocked at the HTTP layer (nock/msw) with recorded fixtures, and one
shared adapter contract suite runs against both providers to prove provider-agnosticism.
A live Google sandbox smoke runs only behind RUN_LIVE_GOOGLE=1 (nightly), never in the default suite.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。