# Agents and the CLI

The `mailpiece` CLI works with your install from a terminal, and is also an MCP server and an agent skill.

Paste this into your agent:

> Install the mailpiece CLI and connect it to my newsletter. Read mailpiece.dev/docs/agents.md first.

## Install and sign in

Build with Go; the binary lands in `bin/mailpiece`. Put it on your `PATH`.

Make a token under Profile › Personal access tokens: read only looks, read and write can change things. `--account` is the number in the app's address.

```sh
git clone https://github.com/mailpiece/mailpiece-cli.git
cd mailpiece-cli
make build

mailpiece auth login TOKEN --account 834206594 --api-url https://app.example.com
mailpiece doctor
```

## MCP

`mailpiece mcp` serves the newsletter as MCP tools over stdio. It only reads unless you pass `--writes`, with a read and write token.

`--domains` narrows the tools: `posts`, `search`, `subscribers`, `snippets`, `journeys`, `settings`, `users`, `identity` and `access_tokens`. Setups per agent are on the [integrations](https://mailpiece.dev/integrations) pages.

```sh
claude mcp add mailpiece -- mailpiece mcp
claude mcp add mailpiece -- mailpiece mcp --writes
claude mcp add mailpiece -- mailpiece mcp --domains posts,subscribers
```

## The skill

Installs the CLI's agent skill for coding agents, refreshed when the CLI is upgraded. Bare `mailpiece skill` asks where to put it.

```sh
mailpiece skill install
```

## Careful with sending

`mailpiece post deliver` mails the whole list and cannot be undone. `mailpiece post test` mails one address.

Still need help? Ask on [GitHub](https://github.com/mailpiece/mailpiece).
