hara-gmail-mcp: add mark_read and archive tools (v0.2.0)
Adds two write-capable IMAP tools: - gmail_mark_read: sets \Seen flag on a message - gmail_archive: copies to [Gmail]/All Mail and removes from INBOX The IMAP connection already used SELECT (read-write mode); this just exposes the mutation surface through MCP. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8056e510c5
commit
4d2e40455d
4 changed files with 65 additions and 6 deletions
|
|
@ -153,6 +153,34 @@ def read_email(
|
|||
)
|
||||
|
||||
|
||||
def mark_read(
|
||||
store: AccountStore,
|
||||
email_addr: str,
|
||||
uid: str,
|
||||
mailbox: str = "INBOX",
|
||||
) -> None:
|
||||
"""Mark a message as read by adding the \\Seen flag."""
|
||||
account = store.get(email_addr)
|
||||
password = store.password_for(email_addr)
|
||||
with _open(account, password, mailbox) as conn:
|
||||
conn.uid("store", uid, "+FLAGS", r"(\Seen)")
|
||||
|
||||
|
||||
def archive(
|
||||
store: AccountStore,
|
||||
email_addr: str,
|
||||
uid: str,
|
||||
mailbox: str = "INBOX",
|
||||
) -> None:
|
||||
"""Archive a message: copy to All Mail then delete from INBOX."""
|
||||
account = store.get(email_addr)
|
||||
password = store.password_for(email_addr)
|
||||
with _open(account, password, mailbox) as conn:
|
||||
conn.uid("copy", uid, "[Gmail]/All Mail")
|
||||
conn.uid("store", uid, "+FLAGS", r"(\Deleted)")
|
||||
conn.expunge()
|
||||
|
||||
|
||||
def _fetch_summary(conn: imaplib.IMAP4_SSL, uid: str) -> MessageSummary:
|
||||
typ, data = conn.uid(
|
||||
"fetch",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue