11from datetime import datetime
2- from typing import Annotated
2+ from typing import Annotated , Literal
33
44from mcp .server .fastmcp import FastMCP
55from pydantic import Field
@@ -38,19 +38,31 @@ async def add_email_account(email: EmailSettings) -> None:
3838@mcp .tool (description = "Paginate emails, page start at 1, before and since as UTC datetime." )
3939async def page_email (
4040 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 ,
41+ page : Annotated [
42+ int ,
43+ Field (default = 1 , description = "The page number to retrieve (starting from 1)." ),
44+ ] = 1 ,
4245 page_size : Annotated [int , Field (default = 10 , description = "The number of emails to retrieve per page." )] = 10 ,
4346 before : Annotated [
44- datetime | None , Field (default = None , description = "Retrieve emails before this datetime (UTC)." )
47+ datetime | None ,
48+ Field (default = None , description = "Retrieve emails before this datetime (UTC)." ),
4549 ] = None ,
4650 since : Annotated [
47- datetime | None , Field (default = None , description = "Retrieve emails since this datetime (UTC)." )
51+ datetime | None ,
52+ Field (default = None , description = "Retrieve emails since this datetime (UTC)." ),
4853 ] = None ,
4954 subject : Annotated [str | None , Field (default = None , description = "Filter emails by subject." )] = None ,
5055 body : Annotated [str | None , Field (default = None , description = "Filter emails by body." )] = None ,
5156 text : Annotated [str | None , Field (default = None , description = "Filter emails by text." )] = None ,
5257 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 ,
58+ to_address : Annotated [
59+ str | None ,
60+ Field (default = None , description = "Filter emails by recipient address." ),
61+ ] = None ,
62+ order : Annotated [
63+ Literal ["asc" , "desc" ],
64+ Field (default = None , description = "Order emails by field. `asc` or `desc`." ),
65+ ] = "desc" ,
5466) -> EmailPageResponse :
5567 handler = dispatch_handler (account_name )
5668
@@ -64,6 +76,7 @@ async def page_email(
6476 text = text ,
6577 from_address = from_address ,
6678 to_address = to_address ,
79+ order = order ,
6780 )
6881
6982
0 commit comments