# Commands

CrabTalk commands — cargo-style subcommand dispatch for telegram, search, and custom tooling.

CrabTalk uses cargo-style subcommand dispatch. Running `crabtalk <name>` finds `crabtalk-<name>` on your PATH and executes it, forwarding all remaining arguments. If the binary isn't found, CrabTalk offers to install it from crates.io.

```
crabtalk telegram start
#        ^^^^^^^^ ^^^^^
#        command  forwarded args
# executes: crabtalk-telegram start
```

The daemon doesn't spawn or manage commands. Each command is an independent binary that connects to the daemon when it needs to.

## Official commands

| Command   | Description                                         |
|-----------|-----------------------------------------------------|
| `telegram`| Connect Telegram to CrabTalk agents                 |
| `wechat`  | Connect WeChat to CrabTalk agents                   |
| `search`  | Meta search engine and MCP server                   |

## Telegram

The telegram command connects a Telegram bot to your daemon. It runs as a system service (launchd on macOS, systemd on Linux) and forwards messages to the daemon as a client via UDS.

```
crabtalk telegram start
crabtalk telegram stop
```

On first run, it prompts for your bot token (from [@BotFather](https://t.me/BotFather)), saves the config, installs a system service, and starts it.

Config lives at `~/.crabtalk/config/telegram.toml`, separate from the daemon config.

**Message flow**: Telegram message → gateway receives it → connects to daemon via UDS → event loop dispatches to agent → response streams back through gateway to Telegram.

## WeChat

The wechat command connects a WeChat bot to your daemon. On first run, it displays a QR code in the terminal for login.

```
crabtalk wechat start
crabtalk wechat stop
```

Config lives at `~/.crabtalk/config/wechat.toml`.

## Search

The search command provides web search as an MCP server. No API keys required — it uses DuckDuckGo and Wikipedia directly.

```
crabtalk search start
crabtalk search stop
```

The daemon connects to the search service automatically and makes its tools available to agents. Results from multiple engines are merged and ranked by relevance.

## Managing services

List all running command services:

```
crabtalk ps
```

Shows each service's name, port, and status (running or stale).

## Two kinds of commands

**Client commands** connect to the daemon and forward messages from external platforms. Telegram is a client — it receives messages and sends them to the daemon for processing.

**MCP commands** expose tools via the MCP protocol. Search is an MCP server — the daemon connects to it and makes its tools available to agents.

## Writing your own

Start from a template:

- **[crabtalk-client](https://github.com/crabtalk/crabtalk-client)** — template for client commands (platform gateways, bots). Connects to the daemon and forwards external messages.
- **[crabtalk-mcp](https://github.com/crabtalk/crabtalk-mcp)** — template for MCP commands (tool servers). Exposes tools that agents can call.

Name your binary `crabtalk-<name>` and it becomes available as `crabtalk <name>`.

## What's next

- [Build a Gateway](/content/blog/build-gateway/index.html) — create a custom platform gateway
- [Build an MCP Server](/content/blog/build-mcp-server/index.html) — create a custom tool server
- [MCP Servers](/content/docs/crabtalk/mcp-servers/index.html) — how tool servers connect to the daemon
