---
name: aiworkers
description: >
  Use the AIWorkers / НЕЙРОСОТРУДНИКИ MCP (aiworkers-mcp): login without putting
  a token in a URL, manage workers, memory, chats, ready replies, surveys, tasks,
  telegram commands, restart the Telegram worker process, two-layer balances
  (account USD vs group TokenTime), salary quote→confirm, one-time tt buy,
  partner info, booking CRM. Use when the user mentions MCP, aiworkers,
  нейросотрудник, aiworkers-mcp, /mcp, awp_, awm_, баланс, tt, токены,
  «сколько токенов», пополнить, зарплата, contribution, партнёрка,
  «перезапусти бота», restart the bot, or asks to log in / get an API key.
---

# AIWorkers MCP

Thin MCP client. Business logic stays on `https://ai.knopka.click`. Do not invent tokens or seeds.

Install docs (source of truth): https://github.com/dimaneuron/aiworkers-mcp  
Landing: https://ai.knopka.click/mcp  
Product: https://ai.knopka.click

If this project has no MCP yet: read that README, install `aiworkers-mcp`, have the human run `aiworkers-mcp login`, then `aiworkers_whoami` and `aiworkers_skill_update`.

## Login (no token in the link)

1. Call **`aiworkers_login_link`** (works without a key) and give the human this URL:
   `https://t.me/aiworkersbot?start=mcp`
2. They open it in Telegram, Mini App shows a module token **once**. Seed of 12 words never goes to chat or to the server.
3. Human runs `aiworkers-mcp login` on the Mac and pastes the token. That writes `~/.config/aiworkers/credentials.json` (`chmod 600`).
4. Restart the agent. Call **`aiworkers_whoami`**.

Do not put tokens in git, in `mcp.json` committed to the repo, or in chat. Prefer `aiworkers-mcp login` over env in config.

Refresh this skill file locally: call **`aiworkers_skill_update`**.

## Tokens

| Kind | Prefix | Scope |
|------|--------|--------|
| Parent | `awp_…` | All groups this Telegram user admins. Can mint children. |
| Child | `awm_…` | One `module` + one `group_id`. No escalation. |
| Legacy | forms / getApiKey | Still works; no module field. |

Modules: `surveys`, `tasks`, `workers`, `telegram`, `crm`. Finance is not in v1.

Parent `awp_` can mint children: **`aiworkers_token_mint(module, group_id)`**. Writes `awm_` into `credentials.json` when `save=true` (default). Token is shown once in the tool result — tell the human the **prefix** + module + group; do not dump the full secret unless they need it on another machine (`aiworkers-mcp login`). Generation is **free** for now; later it will debit **group TokenTime**. If 402 — not enough `group.tt`.

Wrong module → 403 `нужен child для <module>, не общий`. Child `awm_` workers: only that group + the key owner's wallet.

## First call

`aiworkers_whoami` — groups, `kind`, `module`, `eth_address`. If there is no key, it returns the login URL.

## Two wallets (do not mix)

1. **Account** — `users.balance` USD. One per person, shared across groups. Top-up: `https://t.me/aiworkersbot?start=addBalance`, or with amount `…?start=addBalance_10` (integer USD only; a dot in start payload is invalid). **`workers_topup_link` does not credit tt.** There is no `tt_credit` on that tool. The bot opens the same payment screen and shows **Change amount**. Bare `addBalance` is the old picker.
2. **Group TokenTime** — `group.tt`. Chat spend hits this. Subscription: **+$1 contribution → +3600 tt**. One-time: **$10 → 3600 tt** (10×), solary unchanged.

`workers_balance(group_id)` always returns both layers plus `hints`. `workers_list` has group tt on each row and **one** `account` object at the root.

Rates in the payload: `tt_per_usd_subscription` = 3600, `tt_per_usd_onetime` = 360. Do not invent other numbers.

## Money: quote → confirm

Nothing is charged until `confirm=true` on the matching confirm tool. Quote lives ~5 min. Reuse / missing / expired quote → 409.

- **Salary (own contribution only):** `workers_salary_quote(add_usd)` then `workers_salary_confirm(quote_id, confirm=true)`. Integer USD, must increase. Quote shows my contribution / others / new solary. Other admins can raise their own share — say that. Cannot decrease via MCP (human writes @dimaneuron).
- **One-time tt:** `workers_tt_buy_quote(amount_usd=10)` or `tt=…` then `workers_tt_buy_confirm(quote_id, confirm=true)`. Does **not** change solary.
- Never write tt via `workers_update`.

## Zero balance

If `account.usd <= 0`: give addBalance (`workers_topup_link` / `hints.topup_url`), say other admins can raise salary (`hints.other_admins_can_raise`), call **`workers_partner`**. Do not invent partner percents — use `rates` from that tool (empty dict means no published %).

If `group.tt <= 0` but the account has money: offer salary (subscription 3600 tt/$) vs one-time 10×, ask what the human wants.

## Tools (by module)

Always: `aiworkers_login_link`, `aiworkers_whoami`, `aiworkers_skill`, `aiworkers_skill_update`, **`aiworkers_token_mint`** (parent `awp_` → child `awm_`).

- **workers**: list/get/update card; memory; chats (no logs dump beyond the tool); ready replies. **`workers_chat_send`** — one message to a known chat (`workers_chats_list` only): `channel=auto|bot|embed|topic` (default auto = bot DM, or widget outbox). Mirrors the same content into the user's forum topic (no extra agent label). **`workers_broadcast_quote` / `workers_broadcast_confirm`** — one-shot DM blast of a ready reply to people who already wrote this bot; quote then `confirm=true`. Status stays in the mailing topic like native «Разослать»; MCP audit goes to the main-admin error log. Not arbitrary Telegram ids, not folders, not pyrogram. **`workers_readyreply_upsert`** posts the donor into the native ready-reply topic (`P{message_id}` + customization button). Re-upsert of an item without `message_id` publishes it; changing `text` edits the Telegram post. No bot token in responses. **`workers_balance`**, **`workers_topup_link`** (account only), **`workers_salary_quote` / `workers_salary_confirm`**, **`workers_tt_buy_quote` / `workers_tt_buy_confirm`**, **`workers_partner`**. Empty `group_id` → credentials / `AIWORKERS_GROUP_ID`, else «нужен group_id».
- **surveys**: DSL (`Q1*` = required), validate, create (mismatch `group_id` → 403, no silent remap), agent get/update/responses/stats/settings/scenarios, archive/delete, `survey_agent_share` (`form_url` + `chat_text` for `workers_chat_send` / readyreply). `survey_id` may be the full id, public slug from `/form/XXXXXXX`, or a pasted form URL. Resource `survey://dsl/spec`. Writes via POST, not PUT.
- **tasks**: list/count/get/create/update/complete/cancel. Need `group_id` or credentials.
- **telegram**: status + command menu; **`telegram_restart(group_id)`** — start/restart pm2 `aibot-<username>` (same as /telegram_bot «Перезапустить скрипт»). Rate-limited: 60s cooldown per bot, in-flight lock, hourly cap. On 429 wait `retry_after` — do not loop. **Do not send chats via telegram_*.** Personal/broadcast is **`workers_chat_send`** / **`workers_broadcast_*`**. If the user says «перезапусти бота» / restart the bot → call `telegram_restart`, not `workers_update`.
- **crm**: Booking context + process. Not admin CRM dialogs.

Pass `group_id` when the tool has it. Default comes from credentials / `AIWORKERS_GROUP_ID`.

## Hard rules

- Never log or repeat the 12-word seed.
- Never ask the human to paste the seed into the agent chat.
- `whoami` must not show bot tokens (API already strips them).
- Child key for `workers` cannot call `tasks` or another group.
- Surveys/tasks 403 «Токен не привязан к group_id» on a parent key → `aiworkers_token_mint(module=surveys|tasks, group_id=…)`, not Mini App as the only path.
- Send: only `workers_chat_send` / `workers_broadcast_*`. Recipient must already be in `workers_chats_list`. Never invent a Telegram chat id. Broadcast needs quote then `confirm=true`.
- «Перезапусти бота» is `telegram_restart`, never `workers_update`.
- «Сколько токенов» / баланс / tt → `workers_balance` (one group) or `workers_list` (all). Not a loop of `workers_get`.
- «Пополнить» the **account** → `workers_topup_link`. With a USD amount the URL is `start=addBalance_N` (integer). Still no tt. To add **tt** → salary quote or one-time tt quote, after the human confirms. Never patch `tt` with `workers_update`.
- Partner: `workers_partner` only. Do not mix with worker-bot `/ref`. Do not invent %.

## Update this skill

```
aiworkers_skill_update
```

Writes the latest `SKILL.md` to `~/.cursor/skills/aiworkers/` (and project `.cursor/skills/aiworkers/` if you are in a repo with `.cursor`). Same from CLI: `aiworkers-mcp skill-update`.
