Add reply_email tool and sender override
All checks were successful
Build And Test / publish (push) Successful in 1m0s

This commit is contained in:
2026-01-01 12:16:06 -08:00
parent 0459fb1d4c
commit 71c55f7289
3 changed files with 171 additions and 6 deletions

View File

@@ -210,7 +210,7 @@ def register_email_tools(mcp: FastMCP, service: EmailService):
)
return result.model_dump()
@mcp.tool(description="Send a new email via SMTP. Supports plain text and HTML content, CC, BCC, and reply-to.")
@mcp.tool(description="Send a new email via SMTP. Supports plain text and HTML content, CC, BCC, reply-to, and custom sender.")
async def send_email(
to: list[str],
subject: str,
@@ -219,6 +219,8 @@ def register_email_tools(mcp: FastMCP, service: EmailService):
bcc: Optional[list[str]] = None,
reply_to: Optional[str] = None,
html_body: Optional[str] = None,
sender_email: Optional[str] = None,
sender_name: Optional[str] = None,
) -> dict:
"""
Send a new email.
@@ -231,8 +233,62 @@ def register_email_tools(mcp: FastMCP, service: EmailService):
bcc: List of BCC recipients (optional)
reply_to: Reply-to address (optional)
html_body: HTML version of the email body (optional)
sender_email: Sender email address (optional, defaults to SMTP_FROM_EMAIL)
sender_name: Sender display name (optional, defaults to SMTP_FROM_NAME)
"""
result = await service.send_email(to, subject, body, cc, bcc, reply_to, html_body)
result = await service.send_email(
to,
subject,
body,
cc,
bcc,
reply_to,
html_body,
sender_email,
sender_name,
)
return result.model_dump()
@mcp.tool(description="Reply to an existing email by ID, with optional reply-all behavior.")
async def reply_email(
email_id: str,
body: str,
mailbox: str = "INBOX",
reply_all: bool = False,
cc: Optional[list[str]] = None,
bcc: Optional[list[str]] = None,
reply_to: Optional[str] = None,
html_body: Optional[str] = None,
sender_email: Optional[str] = None,
sender_name: Optional[str] = None,
) -> dict:
"""
Reply to an existing email.
Args:
email_id: The unique ID of the email to reply to
body: Plain text email body
mailbox: The mailbox containing the email (default: INBOX)
reply_all: Whether to include original recipients (default: False)
cc: List of CC recipients (optional)
bcc: List of BCC recipients (optional)
reply_to: Reply-to address for the reply (optional)
html_body: HTML version of the email body (optional)
sender_email: Sender email address (optional, defaults to SMTP_FROM_EMAIL)
sender_name: Sender display name (optional, defaults to SMTP_FROM_NAME)
"""
result = await service.reply_email(
mailbox,
email_id,
body,
reply_all,
cc,
bcc,
reply_to,
html_body,
sender_email,
sender_name,
)
return result.model_dump()
@mcp.tool(description="Set or remove IMAP flags on an email. Standard flags: \\Seen, \\Answered, \\Flagged, \\Deleted, \\Draft. Custom keywords are also supported.")