Skip to content
sam-ayoPublic

About

Email client to connect all your accounts and MCP + MCP APP to use with your fav agent

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

mail

A keyboard-first email client with one inbox for all your accounts.

The unified inbox with the reading pane

The command palette

The light theme

The email accounts and the color themes in Settings

pnpm install
cp .env.example .env
pnpm dev

AI agents (MCP)

/mcp is a remote MCP server for the mail in all accounts of a workspace. Add ${APP_URL}/mcp as a custom connector in Claude, ChatGPT, or another MCP client. The client signs in with OAuth 2.1. The tools are list_accounts, search_threads, get_thread, get_attachment, modify_threads, send_message, and compose_message.

  • The server uses mcp-use. The tools are in app/mcp/server.ts. The mcpUse() Vite plugin runs that file in its own Vite environment, and app/routes/mcp.ts forwards /mcp and /mcp/* to it.

  • compose_message is an MCP App. It sends nothing. The chat shows the email in the view app/mcp/views/compose-message/view.tsx, where the user edits it and presses Send. Send calls send_message. A client without MCP Apps gets the draft as text.

  • mcp-env.d.ts gives the view the types of the tools. mcp-use makes it again when Vite starts.

  • Better Auth (@better-auth/mcp) is the authorization server, under /api/auth. It supports Client ID Metadata Documents and Dynamic Client Registration. The config is in app/server/agent-auth.server.ts.

  • A workspace has no password. The login step (/oauth/login) uses the mail session of the browser. The consent step is /oauth/consent.

  • The scopes are mail:read, mail:write, and mail:send. offline_access gives a refresh token.

  • Settings › AI agents lists the connected agents. Disconnect takes effect at once.

  • /agents is the public documentation of the connector. The Claude and ChatGPT directory listings link to it.

  • /review is the sign-in for directory reviewers. REVIEW_PASSWORD turns it on. Each sign-in gets a new workspace with three demo accounts, so reviewers never share a workspace. Demo accounts send nothing.

  • OPENAI_APPS_CHALLENGE is the domain token for ChatGPT, at /.well-known/openai-apps-challenge.

Rotate the encryption key

ENCRYPTION_KEY encrypts the account credentials and the cached thread summaries in the database. Each stored value names the key that encrypted it, so you can replace the key without a loss of data. Replace the key if it possibly leaked, for example after a security incident at the host.

  1. Make a new key with openssl rand -base64 32.
  2. In production, move the old key to ENCRYPTION_KEY_PREVIOUS, and put the new key in ENCRYPTION_KEY. ENCRYPTION_KEY_PREVIOUS can hold more than one key, separated by commas.
  3. Redeploy. The app now encrypts with the new key, and it decrypts with the old and the new key.
  4. Run pnpm reencrypt with the production DATABASE_URL, ENCRYPTION_KEY, and ENCRYPTION_KEY_PREVIOUS. It encrypts all stored values again with the new key.
  5. Run pnpm reencrypt --check. It must say "All values use the current key."
  6. Remove ENCRYPTION_KEY_PREVIOUS in production, and redeploy.

If a step fails, do not remove the old key. The app cannot read a value without its key.

About

Email client to connect all your accounts and MCP + MCP APP to use with your fav agent

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages