Skip to content
AgentMail
AgentMail
Agent platforms

Send & Receive Emails with opencode

Use the AgentMail MCP server directly in opencode to send and receive emails

opencode is an open-source terminal coding agent. Add the hosted AgentMail MCP server to its config and it gets an email inbox of its own to send, receive, and reply from.

What you will need

  • The opencode CLI installed.
  • An AgentMail API key, if you connect with a key. Generate one here.

Add the MCP server

Add the server to opencode.json in your project root, or to ~/.config/opencode/opencode.json to make it global. With an API key:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "agentmail": {
      "type": "remote",
      "url": "https://mcp.agentmail.to/mcp",
      "enabled": true,
      "headers": {
        "x-api-key": "{env:AGENTMAIL_API_KEY}"
      }
    }
  }
}

Export AGENTMAIL_API_KEY in the environment opencode starts from. To sign in with OAuth instead, drop the headers block and authenticate once:

opencode mcp auth agentmail

Confirm the server and its auth status with opencode mcp list. Then ask opencode to use it:

Create an AgentMail inbox and send a hi email from it to you@example.com.

Next Steps

Was this page helpful?Suggest editsRaise issue