A Python-based sync agent that integrates Notion, Obsidian, Google Calendar, and Google Tasks. The system is controlled through AI chat interactions and can run as a background service for notifications and monitoring.
The system supports three access methods:
- User requests sync via chat
- AI assistant (me) fetches source data via MCP tools (Notion/Obsidian)
- AI calls Python sync functions with MCP data
- Python sync engine processes and maps data
- Python writes to Google APIs directly
- AI reports status back to user
- User runs:
python main.py --sources notion google_tasks - Python script uses direct APIs
- Python fetches data and syncs
- CLI outputs status to console
- User triggers sync via Cursor Background Agent (web interface/IDE) from phone
- Python service uses direct APIs only (no MCP access)
- Python fetches data from all sources via direct APIs
- Python sync engine detects changes and processes syncs
- Service logs status and sends notifications
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment:
- Copy
.env.exampleto.env - Fill in your Google OAuth2 credentials:
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETGOOGLE_PROJECT
- Add
NOTION_API_TOKENfor background agent direct API access
Important for Google OAuth:
- If using a Web client type (recommended): Add
http://localhost:8080as an authorized redirect URI in Google Cloud Console - If using a Native client type: The out-of-band flow (
urn:ietf:wg:oauth:2.0:oob) will be used automatically - The code will automatically try the web client flow first, then fall back to native if needed
- Copy
-
First-time OAuth2 authentication:
Recommended: Run the OAuth setup script once to authenticate all Google services:
python scripts/setup_google_oauth.py
This script will:
- Request all required scopes (Calendar, Tasks, Drive) in one flow
- Store refresh tokens securely (encrypted if
cryptographyis installed) - Save tokens to
data/google_tokens.json.encrypted
Alternative: OAuth will also run automatically when you first use any Google API client, but the setup script is recommended for a one-time setup.
Note: For secure token storage, install cryptography:
pip install cryptography
Simply ask the AI assistant to sync your data:
"Sync my Notion tasks to Google Tasks"
"Update my calendar from Notion events"
"Sync Obsidian notes to Notion"
The AI assistant will:
- Fetch data via MCP tools
- Call Python sync functions
- Report results back to you
python main.py --sources notion google_tasks --dry-runCreate one Google Task, one Calendar event, and one Notion page:
python main.py --create --notion-parent-page-id <notion-page-id>Notes:
- Google OAuth requires an interactive terminal the first time (you will be prompted for Tasks and Calendar).
- Notion internal integrations cannot create workspace-level pages. Share a page or database with the integration and pass its ID:
--notion-parent-page-id <id>or--notion-parent-database-id <id>
- Public integrations with
insert_contentcan use--notion-parent-workspace.
Trigger syncs from your phone via Cursor Background Agent web interface (cloud).
python -m unittest discover -s tests
See docs/TESTING.md for integration and load tests.
See docs/DEPLOYMENT.md for systemd and Windows Task Scheduler examples.
tracker/
├── src/
│ ├── agents/ # Sync agent classes
│ ├── data_models/ # Task, Event, Note models
│ ├── api_clients/ # Google APIs, Notion API clients
│ ├── sync/ # Sync engine (Phase 2)
│ ├── ai_interface/ # Helper functions for AI
│ ├── notifications/ # Email/SMS notifications (Phase 4)
│ └── config/ # Settings and credentials
├── config/
│ └── sync_rules.yaml # Sync configuration
├── data/ # SQLite database, tokens
├── deploy/ # Deployment configs
├── docs/ # Documentation (setup, testing, deployment)
├── secrets/ # Credentials (gitignored)
└── tests/ # Test files
- User requests sync via chat
- AI assistant uses MCP tools to fetch Notion/Obsidian data
- AI calls Python sync function:
sync_notion_to_google_tasks(notion_data) - Python converts data models and syncs to Google APIs
- AI reports status
- User runs CLI command
- Python uses direct APIs
- Python fetches data and syncs
- CLI outputs status
- User triggers via web interface
- Python uses direct APIs (Notion API, Google APIs, Google Drive API)
- Python fetches data, detects changes, syncs
- Service logs and sends notifications
Edit config/sync_rules.yaml to customize:
- Sync directions (bidirectional, unidirectional)
- Data mappings (property mappings)
- Filters (what to sync)
- Conflict resolution strategies
- OAuth2 tokens stored securely in
data/google_tokens.json.encrypted - Credentials in
.envfile (gitignored) - MCP tools use existing Cursor authentication
- No credentials logged or exposed
-
✅ Phase 1: Foundation (Complete)
- Project structure
- Data models
- API clients
- Configuration system
- AI helper functions
-
✅ Phase 2: Core Sync Logic
-
✅ Phase 3: AI Interface Integration
-
✅ Phase 4: Background Service
-
✅ Phase 5: Production Hardening
-
⏳ Phase 6: Integration & Testing
MIT