feat: add AgentMail as alternative email provider#49
Open
adi-singh13 wants to merge 1 commit into
Open
Conversation
Add AgentMail (https://agentmail.to) as an optional email provider alongside the existing IMAP/SMTP support. This gives users a simpler setup path — just an API key instead of configuring mail server hosts, ports, TLS settings, and credentials. New files: - src/services/agentmail.service.ts — AgentMail API client service - src/tools/agentmail.tool.ts — MCP tools for AgentMail operations Modified files: - src/config/schema.ts — Add optional [agentmail] config section - src/config/loader.ts — Parse agentmail config, update template - src/types/index.ts — Add AgentMailConfig type - src/tools/register.ts — Wire up AgentMail tools when configured - src/main.ts — Instantiate AgentMailService when API key is present - README.md — Document AgentMail setup and available tools The integration is fully additive — no existing IMAP/SMTP code is changed. AgentMail tools are prefixed with agentmail_ to avoid name collisions. Configuration can be done via config.toml or the AGENTMAIL_API_KEY environment variable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds AgentMail as an optional email provider alongside the existing IMAP/SMTP support. The integration is fully additive — no existing code is modified or removed.
Motivation
While IMAP/SMTP is the standard for email access, some users (especially those building AI agents) prefer a simpler setup that does not require configuring mail server hosts, ports, TLS, and credentials. AgentMail offers:
extracted_text— automatically strips quoted reply chains, useful for AI processingThis makes it a natural fit as an alternative provider for an email MCP server.
What changed
New files
src/services/agentmail.service.ts— Lightweight AgentMail API client (usesfetch, no additional npm dependencies)src/tools/agentmail.tool.ts— 5 MCP tools prefixed withagentmail_to avoid name collisionsModified files
src/config/schema.ts— Optional[agentmail]config section with Zod validationsrc/config/loader.ts— Parse AgentMail config from TOML, updated config templatesrc/types/index.ts—AgentMailConfiginterfacesrc/tools/register.ts— Conditionally register AgentMail tools when configuredsrc/main.ts— InstantiateAgentMailServicewhen API key is present (config orAGENTMAIL_API_KEYenv var)README.md— Document setup, configuration, and available toolsNew tools
agentmail_create_inbox@agentmail.toaddressagentmail_list_inboxesagentmail_list_messagesagentmail_get_messageagentmail_send_messageConfiguration
Via
config.toml:Or environment variable:
Both IMAP/SMTP accounts and AgentMail can be used simultaneously — the config schema now requires at least one IMAP/SMTP account or an
[agentmail]section.Design decisions
fetchto call the AgentMail REST API, avoiding any build-time dependencyagentmail_prefix so they coexist cleanly with existing tools