# heyalgo auth.md

You are an AI coding agent connecting to HeyAlgo (https://heyalgo.ai).

HeyAlgo supports zero-copy-paste agent registration and in-agent Stripe checkout over a hosted Streamable HTTP MCP server (68 tools covering ICP research, lead lists, multi-step sequences, Master Inbox, billing, white-label agency workspaces, automations, SMS and phone).

## Expect a human in the loop

Two steps require the human to click a link in their browser:
1. **Claim ceremony (Step 2):** The user signs in to HeyAlgo (or creates a free account) and enters a 6-digit code to issue this agent a personal `hey_mcp_...` key.
2. **Subscription checkout (Step 4):** Exploring, building lists, and drafting sequences are free. Launching a live sequence or sending outreach requires an active monthly Team plan: surface a checkout link and poll `get_billing_status` until `canLaunch` is `true`.

Never invent prices from memory. Always read current plans from `get_billing_status`.

## Fastest path: 1-click OAuth 2.1 (Claude, Cursor, ChatGPT, Codex)

If your client supports standard MCP OAuth 2.1 (RFC 9728 + RFC 8414 + Dynamic Client Registration), connect directly to the hosted MCP endpoint with no API key:

```text
https://app.heyalgo.ai/api/mcp
```

Your client will auto-discover `https://app.heyalgo.ai/.well-known/oauth-protected-resource`, register dynamically, open a browser sign-in at `https://app.heyalgo.ai/mcp/authorize`, and receive a personal `hey_mcp_...` bearer token automatically.

Human install guide: https://heyalgo.ai/install
Agent skill (/heyalgo): https://heyalgo.ai/skill.md

## Step 1: Register this agent (direct HTTP protocol)

```http
POST https://app.heyalgo.ai/api/mcp/agent/register
Content-Type: application/json

{"clientName":"Claude Code"}
```

Response: `{ "claim_token", "verification_uri", "user_code", "expires_in", "interval" }`. Hold `claim_token` in memory.

## Step 2: Human claim ceremony (no manual API-key copy-paste)

Send the link on its own first and ask the user to tell you once they are signed in:

> Open this link to sign in to HeyAlgo (Google or email). Tell me once you're in and I'll send you a 6-digit code to connect this agent:
> `<verification_uri>`

Only after they confirm they are signed in, send the 6-digit code:

> Now enter this agent code: **<user_code>**

(Splitting the link and the code avoids confusion if the user signs in with a 6-digit email OTP.)

## Step 3: Poll for your personal MCP key

```http
POST https://app.heyalgo.ai/api/mcp/agent/token
Content-Type: application/json

{"claim_token":"clm_..."}
```

- While waiting: HTTP 400 `{"error":"authorization_pending","interval":5}`. Wait 5 seconds and retry.
- On expiry: HTTP 400 `{"error":"expired_token"}`. Restart at Step 1.
- On approval: HTTP 200 `{"access_token":"hey_mcp_...","token_type":"Bearer","mcp_endpoint":"https://app.heyalgo.ai/api/mcp","workspace_id":"..."}`.

Save `access_token` in your MCP client config (never print or commit it to git) and connect to `https://app.heyalgo.ai/api/mcp` with `Authorization: Bearer <access_token>`.

### Manual fallback (if the user already has a key)

Create a key in https://app.heyalgo.ai/settings/mcp, then connect:

#### Claude Code

```bash
claude mcp add --transport http heyalgo https://app.heyalgo.ai/api/mcp \
  --header "Authorization: Bearer YOUR_HEYALGO_MCP_KEY"
```

#### OpenAI Codex CLI

```bash
export HEYALGO_MCP_KEY="YOUR_HEYALGO_MCP_KEY"
codex mcp add heyalgo --url https://app.heyalgo.ai/api/mcp \
  --bearer-token-env-var HEYALGO_MCP_KEY
```

#### Cursor and Claude Desktop (mcp.json)

```json
{
  "mcpServers": {
    "heyalgo": {
      "url": "https://app.heyalgo.ai/api/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_HEYALGO_MCP_KEY"
      }
    }
  }
}
```

## Step 4: Build value first, then unlock sending in chat

1. Call `list_workspaces`, `get_billing_status`, and `get_knowledge_base`.
2. Build the user's ICP, create a People list (`create_list`, `add_leads_to_list`), and draft a sequence (`create_sequence`, `add_sequence_step`) so the user sees real buyers and drafted outreach before paying.
3. Ask the user to approve before publishing a sequence (`set_sequence_status`), sending SMS (`send_sms`), or placing a call (`place_phone_call`).
4. If `get_billing_status` shows `canLaunch: false`, or if `set_sequence_status` returns `{"error":"billing_required","checkoutUrl":"..."}`, call `create_subscription_checkout_link` (or use the returned `checkoutUrl`) and show the link to the user:

> Open this link to activate your HeyAlgo plan and unlock sending. I'll wait here and launch as soon as checkout finishes:
> `<checkoutUrl>`

5. Poll `get_billing_status` every 5 seconds until `canLaunch` is `true`, then automatically retry `set_sequence_status` (`action: "publish"`).

## Safety and sending boundaries

- Outreach sequences never send until explicitly published via `set_sequence_status` with `canLaunch: true`.
- Direct messaging tools (`send_sms` and `place_phone_call`) execute immediately and require explicit user confirmation.
- DNC enforcement is server-side across `add_leads_to_list` and active sequences.
- Revoking a key in https://app.heyalgo.ai/settings/mcp invalidates access immediately.

## Full tool inventory (68 tools)

### Agency & white-label (7 tools)

- `list_workspaces`: List every HeyAlgo workspace you belong to, including client workspaces, with setup, mailbox, LinkedIn and credit status.
- `get_agency_overview`: Pull cross-client metrics: active campaigns, sent messages, replies, connected senders and credit usage.
- `create_client_workspace`: Provision an isolated client workspace under your agency credit pool with an optional cap and branded invite.
- `update_client_credit_limit`: Set, raise, lower or remove a client workspace's credit spend cap.
- `get_whitelabel_settings`: Inspect custom domain status, DNS records, brand name, colors and support email.
- `save_whitelabel_settings`: Update portal domain, brand name, logo, favicon, accent color and support email.
- `verify_whitelabel_domain`: Check live DNS TXT or CNAME verification and activate your agency's custom portal domain.

### Workspace, credits, KB, profiles & enrichment (16 tools)

- `get_credits`: Inspect available credits, held credits, team credits and sending entitlement.
- `get_knowledge_base`: Read a workspace's company overview, ICP, buyer personas, tonality and extra context.
- `update_knowledge_base`: Update a workspace's company overview, ICP, personas, tonality and messaging rules.
- `list_schedules`: List configured outreach sending schedules and IANA timezones in a workspace.
- `create_schedule`: Create a sending schedule with timezone, active weekdays and send window.
- `update_schedule`: Update an existing sending schedule's name, timezone, active days or hours.
- `delete_schedule`: Delete a non-default sending schedule from a workspace.
- `list_dnc`: Search suppressed emails, domains and LinkedIn URLs in a workspace's DNC list.
- `add_dnc_entries`: Suppress emails, domains or LinkedIn profiles and stop active enrollments.
- `remove_dnc_entry`: Remove a single entry from the workspace's Do-Not-Contact list by entry ID.
- `get_member_profile`: Read the authenticated rep's title, signature, bio, writing style and context.
- `update_member_profile`: Update the authenticated rep's profile fields used to personalize outreach.
- `get_enrichment_settings`: Inspect configured email, phone and company enrichment providers for a workspace.
- `set_enrichment_providers`: Enable or reorder active contact and company enrichment provider IDs.
- `list_integrations`: List connected third-party apps and CRM integrations in a workspace.
- `list_prewarmed_orders`: Inspect pre-warmed sending domains and Google or Microsoft mailbox orders.

### Senders, lists & core sequences (11 tools)

- `list_accounts`: List connected Gmail, Outlook, LinkedIn and funded VA LinkedIn sender accounts.
- `list_lists`: List People and Companies lists and row counts inside a workspace.
- `create_list`: Create a new People or Companies list with optional custom columns.
- `add_leads_to_list`: Upsert structured leads into a People list with deduplication and DNC checks.
- `get_list_rows`: Read paginated people or company records from any workspace list.
- `list_sequences`: List outbound email and LinkedIn sequences with status, metrics and launch blockers.
- `get_sequence`: Inspect full sequence steps, senders, schedule and launch readiness checks.
- `set_sequence_status`: Publish, resume or pause a sequence with full entitlement and safety checks.
- `create_sequence`: Create a new draft outreach sequence attached to a People list.
- `add_sequence_step`: Add an email, LinkedIn message, invite, visit, wait or condition step.
- `update_sequence_step`: Edit subject, body, AI prompt or wait timing on an existing sequence step.

### List editing, sequence controls & reply triage (13 tools)

- `rename_list`: Rename an existing People or Companies list.
- `delete_list`: Permanently delete a People or Companies list from a workspace.
- `add_list_columns`: Add custom columns to an existing workspace list.
- `set_list_cell`: Update a custom column cell value on a specific list row.
- `remove_list_rows`: Delete one or more rows from a list by row ID.
- `update_sequence_settings`: Configure schedule, sender accounts, review mode, reply rule, OOO rule or delay.
- `rename_sequence`: Rename an outreach sequence.
- `duplicate_sequence`: Clone an existing outreach sequence as a fresh draft.
- `archive_sequence`: Archive an outreach sequence and stop further sends.
- `delete_sequence`: Permanently delete a draft or archived outreach sequence.
- `remove_sequence_step`: Delete a step or condition branch from a sequence.
- `get_sequence_review_queue`: List queued outbound messages awaiting review or approval in review mode.
- `classify_reply`: Set the reply category (positive, negative, objection, out_of_office) on a reply.

### Master Inbox, labels & reply drafts (10 tools)

- `list_conversations`: Read email and LinkedIn threads in Master Inbox, filtered by unread or search.
- `get_conversation_thread`: Read the full message and reply history for a specific prospect.
- `update_conversation_state`: Mark a thread read, unread, done, reopened, snoozed or unsnoozed.
- `save_reply_draft`: Create or update an email or LinkedIn reply draft in a prospect thread.
- `discard_reply_draft`: Delete an unsent Master Inbox reply draft by message ID.
- `list_conversation_labels`: List all custom Master Inbox labels in a workspace.
- `create_conversation_label`: Create a new custom label for organizing Master Inbox conversations.
- `set_conversation_label`: Attach or remove a custom label on a conversation.
- `list_automations`: List all monitors, signal workflows and Reply Agent automations.
- `set_automation_enabled`: Enable or pause any workspace automation or Reply Agent with one call.

### Automation workflows & runs (5 tools)

- `get_automation`: Inspect an automation's full trigger, blocks, schedule and enabled state.
- `create_automation`: Create a new scheduled, event-driven or manual automation workflow.
- `delete_automation`: Delete an automation workflow from a workspace.
- `run_automation`: Run an automation immediately in live or test mode.
- `list_automation_runs`: Inspect recent execution runs and statuses for an automation.

### Phone, SMS & live voice calls (6 tools)

- `get_phone_account`: Inspect connected Telnyx phone lines, numbers and SMS or voice readiness.
- `list_phone_inbox`: Read recent SMS and phone call threads in a workspace.
- `send_sms`: Send a 1:1 SMS message to a contact record from an assigned phone line.
- `place_phone_call`: Initiate an outbound phone call to a contact record from an assigned line.
- `list_bulk_sms_batches`: Check bulk SMS eligibility and list recent bulk SMS batches.
- `get_bulk_sms_batch`: Inspect delivery progress and counts for a specific bulk SMS batch.

## Further reading

- Machine-readable summary: https://heyalgo.ai/llms.txt
- Complete product reference: https://heyalgo.ai/llms-full.txt
- Human MCP guide: https://heyalgo.ai/mcp
- White-label agency guide: https://heyalgo.ai/whitelabel
- Outbound stack comparisons: https://heyalgo.ai/compare
- Product changelog: https://heyalgo.ai/changelog
