--- name: attio-reverse-engineering description: "Reverse-engineer and integrate Attio CRM (AI models, API, MCP) into OMP — covers internal endpoints, auth, gateway, and provider wiring" --- # Attio Reverse Engineering & OMP Integration ## Architecture ``` Attio Web App (app.attio.com) ├── Public API: api.attio.com/v2 (Bearer token from Settings → Developers → API Keys) ├── Internal AI: app.attio.com/api/internal/chat/completions (session cookie auth, Cloudflare-protected) ├── MCP: mcp.attio.com/mcp (OAuth: openid offline_access mcp) └── SPA: React, all /api/* GET routes return HTML (not API JSON) OMP Integration: ├── attio-gateway.py :8312 — FastAPI, round-robin API key pool, proxies api.attio.com/v2 ├── attio-api-provider.py :8313 — OpenAI-compatible, /v1/models + /v1/chat/completions + tools ├── attio_mcp.py — MCP stdio server, 3 tools (list_workspaces, search_people, get_record) └── mcp.json — attio (remote http OAuth) + attio-farm (local stdio) ``` ## Auth Methods 1. **API Key** (for api.attio.com/v2): `Authorization: Bearer att_...` — works from any client 2. **Session Cookies** (for app.attio.com/internal): requires real browser — Cloudflare blocks urllib/requests 3. **OAuth JWT** (for mcp.attio.com/mcp): obtained via OAuth consent flow, stored in mcp.json ## Internal AI Endpoint - URL: `POST https://app.attio.com/api/internal/chat/completions` - Auth: session cookies (`attio-session`, `attio-app-session`, `attio-session-id`) - Blocked by Cloudflare Error 1010 for non-browser requests - Models available: Claude Opus 5, Claude Sonnet 5 (names in Attio: "Opus 5", "Claude Sonnet 5") - Other probe results: `/{workspace}/api/chat` returns 405 (exists but different method) ## OMP Provider Wiring (3 files) 1. `providers.yml`: under `providers:`, add entry with `apiKey: ""`, `baseUrl`, `models`, `provider: openai` 2. `models.yml`: detailed config per model (api, contextWindow, maxTokens, compat flags) 3. `config.yml`: add `provider/*` to `enabledModels` AND provider to `modelProviderOrder` - **Without enabledModels, /model won't show the provider at all** - OMP restart required after changes ## Pool Format (attio_accounts.json) ```json [{ "email": "...", "api_key": "att_...", "api_workspace_id": "uuid", "api_workspace_slug": "slug", "cookies": [ {"name": "attio-session", "value": "jwt...", "domain": ".attio.com"}, {"name": "attio-app-session", "value": "jwt...", "domain": ".attio.com"}, {"name": "attio-session-id", "value": "uuid", "domain": ".attio.com"} ], "status": "active_pro_trial" }] ``` ## Browser Automation Issues - Camoufox: launch hangs (GeoIP lookup or binary issue on Windows) - Playwright: chromium binary missing, install needed; node.exe must be copied to driver/ - Patchright: driver node.exe missing - curl_cffi: fails to compile on Windows CPython 3.11 - Browser relay (OMP): times out, extension may not be connected - Chrome CDP: port 9224 listening but OMP browser tool can't connect (503) ## Working Tools - `attio_list_workspaces` — reads pool from JSON, no API call needed - `attio_search_people` — POST /v2/objects/people/records/query with filter - `attio_create_person` — POST /v2/objects/people/records with values - `attio_get_record` — GET /v2/objects/{type}/records/{id}