# Mailpiece with OpenCode

*Draft, test and schedule your newsletter from OpenCode.*

Write your newsletter from OpenCode: hand it your notes in the terminal and it drafts the issue in Mailpiece.

## What you get

- Turn these notes into a draft post
- Send me a test of the draft
- Schedule it for Tuesday at 9
- Who subscribed this week?

## Sign in

Build the CLI as the [agents guide](https://mailpiece.dev/docs/agents) shows and make a read and write token under Profile › Personal access tokens, so OpenCode can draft, test and schedule. The account number is the one in the app's address.

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

## Connect

Install the skill, which OpenCode reads from `~/.agents/skills`, then add the server to `~/.config/opencode/opencode.json` for every project, or `opencode.json` in the project's root for one.

```sh
mailpiece skill install

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "mailpiece": {
      "type": "local",
      "command": ["mailpiece", "mcp", "--writes"],
      "enabled": true
    }
  }
}
```

## Ask

"Turn these notes into a draft and send me a test." The test goes to your own address only.

Sending to the whole list can't be undone, so read what OpenCode is about to do before you let it.

## Set it up this afternoon

Install Mailpiece on a server, connect OpenCode, and send your next issue. [Install Mailpiece](https://mailpiece.dev/docs/install)
