11from datetime import datetime
2- from typing import Annotated
32
43from mcp .server .fastmcp import FastMCP
4+ from pydantic import Field
55
66from mcp_email_server .config import (
77 AccountAttributes ,
@@ -36,16 +36,16 @@ async def add_email_account(email: EmailSettings) -> None:
3636
3737@mcp .tool (description = "Paginate emails, page start at 1, before and since as UTC datetime." )
3838async def page_email (
39- account_name : Annotated [ str , "The name of the email account." ] ,
40- page : Annotated [ int , "The page number to retrieve (starting from 1)." ] = 1 ,
41- page_size : Annotated [ int , "The number of emails to retrieve per page." ] = 10 ,
42- before : Annotated [ datetime | None , "Retrieve emails before this datetime (UTC)." ] = None ,
43- since : Annotated [ datetime | None , "Retrieve emails since this datetime (UTC)." ] = None ,
44- subject : Annotated [ str | None , "Filter emails by subject." ] = None ,
45- body : Annotated [ str | None , "Filter emails by body." ] = None ,
46- text : Annotated [ str | None , "Filter emails by text." ] = None ,
47- from_address : Annotated [ str | None , "Filter emails by sender address." ] = None ,
48- to_address : Annotated [ str | None , "Filter emails by recipient address." ] = None ,
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." ) ,
4949) -> EmailPageResponse :
5050 handler = dispatch_handler (account_name )
5151
@@ -66,12 +66,12 @@ async def page_email(
6666 description = "Send an email using the specified account. Recipient should be a list of email addresses." ,
6767)
6868async def send_email (
69- account_name : Annotated [ str , "The name of the email account to send from." ] ,
70- recipients : Annotated [ list [str ], "A list of recipient email addresses." ] ,
71- subject : Annotated [ str , "The subject of the email." ] ,
72- body : Annotated [ str , "The body of the email." ] ,
73- cc : Annotated [ list [str ] | None , "A list of CC email addresses." ] = None ,
74- bcc : Annotated [ list [str ] | None , "A list of BCC email addresses." ] = None ,
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." ) ,
7575) -> None :
7676 handler = dispatch_handler (account_name )
7777 await handler .send_email (recipients , subject , body , cc , bcc )
0 commit comments