- A machine user: the agent’s identity
- An API key: what the agent uses to call Plain, with the permissions it’s allowed
- A webhook target: how Plain sends the agent events
https://mcp.plain.com/mcp, which signs in as the person with OAuth. The person creates the API key and the webhook target in the Plain app, because both come with secrets that must never pass through this chat.
Follow the steps in order. Steps 1 and 2 only read. Nothing in the workspace changes until the person agrees to it in step 3.
When the person has to choose, such as which template to use, use your host’s question tool if it has one, such as AskUserQuestion in Claude Code. Otherwise ask in chat.
When you’ve handed the person something to do and they say they’re done, check it with a tool if you can, then move straight on to the next step.
Related resources:
- Connecting the MCP server: Agent Setup covers every host
- What connected agents can do: Bring your own agent
- Docs index:
https://www.plain.com/docs/llms.txt
Keep secrets out of this chat
Your host keeps this chat’s history, including anything the person pastes and anything a tool returns. Follow these rules at every step, even if the person asks otherwise:- API keys: never create one, and never ask the person to paste one here
- HMAC secret: never read it or regenerate it. Every webhook in the workspace shares it, so a new one breaks the person’s other integrations
- Pasted API key: tell them it’s now in this chat’s history and that they should delete that key in the Plain app and create a new one. Don’t repeat the value
- Pasted HMAC secret: tell them it’s now in this chat’s history and that deleting an API key doesn’t change it. A workspace admin needs to replace it in Settings → Request signing, then update every service that verifies Plain’s webhooks with the new value. Don’t repeat the value
- Code: refer to secrets only as the environment variables
PLAIN_API_KEYandPLAIN_WEBHOOK_HMAC_SECRET. Never open, print, search or summarize.envfiles or secret stores
1. Check the connection and permissions
If no Plain tools are loaded in your session, follow steps 1 to 3 of Agent Setup to connect the Plain MCP server, then come back here. CallgetMyWorkspace and tell the person the workspace name and ID. A connection is bound to one workspace, so check it’s the one they want. If they gave you a workspace ID (it starts with w_) and it doesn’t match, stop and have them reconnect the MCP server to that workspace.
Then call myPermissions. The person needs machineUser:create, apiKey:create and webhookTarget:create. If any is missing, stop, name the missing permissions, and tell them a workspace admin can do the setup or change their role.
2. Pick a name and a template
Ask the person for the agent’s name and a one sentence description. Customers and teammates see the name. CallmachineUsers and check no machine user already has it. If one does, ask for another.
Call connectedAgentTemplates, ask what the agent should do, and suggest a template:
Offer the templates by these names only. Customer Agent here always means a connected customer agent that the person hosts themselves, never Plain’s built-in Customer Agent. Each template’s
key is for the link in step 4 (customer for Customer Agent, internal for Internal Agent, scratch for From scratch, in lowercase), so don’t show it to the person.
Connected agents use credits each time a discussion with them starts or a thread is assigned to them. Tell the person once and link How credits work.
3. Create the agent
Tell the person the name, description and template you’ll use, and wait for a yes. Then callcreateMachineUser with:
publicNameandfullName: the namedescription: the descriptionisCustomAgent:true. Without it, the machine user isn’t a connected agent and can’t be assigned threads
4. Send the person to the Plain app
Send the person this link and wait for them to say they’re done:template_key_here with customer, internal or scratch (for From scratch), in lowercase. Keep source=mcp in every link you send.
The link opens the API key step of Plain’s agent setup with the template’s permissions already selected. After the key, Plain moves on to the webhook step with the template’s events selected and the webhook linked to this agent. Don’t list permissions or events for the person to tick. Tell them to:
- Create the API key and copy it into their own secret store or
.envfile asPLAIN_API_KEY, not into this chat. Plain shows it once - Set the webhook URL to the public endpoint of the service that receives Plain’s events. If the service doesn’t exist yet, they can skip the webhook, build the service with you in step 6, and add the webhook from the agent’s Webhooks tab afterwards
- Copy the workspace HMAC secret from Settings → Request signing into
PLAIN_WEBHOOK_HMAC_SECRET. Plain signs every webhook request with it - Come back to you once they’re done
5. Check the setup
When the person says they’re done, check both parts. These reads never return a secret.- API key: call
machineUserApiKeysfor the agent. With a template, compare its permissions with the template’spermissions. Name any that are missing, and any extra ones that let the agent do more than its job, such asthread:replyon an Internal Agent. For From scratch there is no template, so ask the person what they chose and check the key matches - Webhook: call
webhookTargets, find the target linked to this agent, and check it’s enabled. With a template, compare its events with the template’seventSubscriptions. For From scratch, check the events match what the person chose
6. Build the service
If the person wants your help building the service that receives Plain’s webhooks, start from Build an internal agent and Example agents:- Verify every request: check the
Plain-Request-Signatureheader withPLAIN_WEBHOOK_HMAC_SECRETbefore trusting the body. Use the webhooks SDK, which does this, or follow Request signing - Call Plain: use the GraphQL SDK with
PLAIN_API_KEY - Connected customer agent: when it’s assigned a thread or a customer sends a new message, reply on the thread, and hand off to a person when it can’t help
- Internal Agent: when a discussion message or mention arrives, reply in the discussion
7. Finish
Give the person:- What exists: the agent’s name and ID, its template, and whether its API key and webhook passed step 5
- What’s left: anything they skipped, with its link
- Where to find it: the agent is listed under Connected agents in Agents in the Plain app
Links
Replaceworkspace_id_here with the ID from getMyWorkspace, which starts with w_, and machine_user_id_here with the ID createMachineUser returned. Never send a link with a placeholder in it.

