11from datetime import datetime
2+ from typing import Annotated
23
34from mcp .server .fastmcp import FastMCP
45from pydantic import Field
@@ -36,16 +37,20 @@ async def add_email_account(email: EmailSettings) -> None:
3637
3738@mcp .tool (description = "Paginate emails, page start at 1, before and since as UTC datetime." )
3839async def page_email (
39- account_name : str = Field (description = "The name of the email account." ),
40- page : int = Field (default = 1 , description = "The page number to retrieve (starting from 1)." ),
41- page_size : int = Field (default = 10 , description = "The number of emails to retrieve per page." ),
42- before : datetime | None = Field (default = None , description = "Retrieve emails before this datetime (UTC)." ),
43- since : datetime | None = Field (default = None , description = "Retrieve emails since this datetime (UTC)." ),
44- subject : str | None = Field (default = None , description = "Filter emails by subject." ),
45- body : str | None = Field (default = None , description = "Filter emails by body." ),
46- text : str | None = Field (default = None , description = "Filter emails by text." ),
47- from_address : str | None = Field (default = None , description = "Filter emails by sender address." ),
48- to_address : str | None = Field (default = None , description = "Filter emails by recipient address." ),
40+ account_name : Annotated [str , Field (description = "The name of the email account." )],
41+ page : Annotated [int , Field (default = 1 , description = "The page number to retrieve (starting from 1)." )] = 1 ,
42+ page_size : Annotated [int , Field (default = 10 , description = "The number of emails to retrieve per page." )] = 10 ,
43+ before : Annotated [
44+ datetime | None , Field (default = None , description = "Retrieve emails before this datetime (UTC)." )
45+ ] = None ,
46+ since : Annotated [
47+ datetime | None , Field (default = None , description = "Retrieve emails since this datetime (UTC)." )
48+ ] = None ,
49+ subject : Annotated [str | None , Field (default = None , description = "Filter emails by subject." )] = None ,
50+ body : Annotated [str | None , Field (default = None , description = "Filter emails by body." )] = None ,
51+ text : Annotated [str | None , Field (default = None , description = "Filter emails by text." )] = None ,
52+ from_address : Annotated [str | None , Field (default = None , description = "Filter emails by sender address." )] = None ,
53+ to_address : Annotated [str | None , Field (default = None , description = "Filter emails by recipient address." )] = None ,
4954) -> EmailPageResponse :
5055 handler = dispatch_handler (account_name )
5156
@@ -66,12 +71,18 @@ async def page_email(
6671 description = "Send an email using the specified account. Recipient should be a list of email addresses." ,
6772)
6873async def send_email (
69- account_name : str = Field (description = "The name of the email account to send from." ),
70- recipients : list [str ] = Field (description = "A list of recipient email addresses." ),
71- subject : str = Field (description = "The subject of the email." ),
72- body : str = Field (description = "The body of the email." ),
73- cc : list [str ] | None = Field (default = None , description = "A list of CC email addresses." ),
74- bcc : list [str ] | None = Field (default = None , description = "A list of BCC email addresses." ),
74+ account_name : Annotated [str , Field (description = "The name of the email account to send from." )],
75+ recipients : Annotated [list [str ], Field (description = "A list of recipient email addresses." )],
76+ subject : Annotated [str , Field (description = "The subject of the email." )],
77+ body : Annotated [str , Field (description = "The body of the email." )],
78+ cc : Annotated [
79+ list [str ] | None ,
80+ Field (default = None , description = "A list of CC email addresses." ),
81+ ] = None ,
82+ bcc : Annotated [
83+ list [str ] | None ,
84+ Field (default = None , description = "A list of BCC email addresses." ),
85+ ] = None ,
7586) -> None :
7687 handler = dispatch_handler (account_name )
7788 await handler .send_email (recipients , subject , body , cc , bcc )
0 commit comments