Skip to main content
Glama
Mohking1

maildoc

by Mohking1

maildoc

AIエージェントと自動化のための軽量なメール検索、添付ファイル取得、PDF抽出ツール。

セットアップ

pip install -r requirements.txt

.env に認証情報を設定します(.env.example を参照)。

GMAIL_USERNAME=user@example.com
GMAIL_APP_PASSWORD=your_app_password

Related MCP server: Gmail MCP Server

クイックスタート

from maildoc import search_emails, download_attachment, extract_pdf_text

# Search emails with attachments
emails = search_emails(
    sender="billing@example.com",
    with_attachments=True,
    limit=5,
)

# Download and extract text from PDF attachments (with optional password for protected files)
for email in emails:
    for att in email["attachments"]:
        if att["filename"].endswith(".pdf"):
            pdf_bytes = download_attachment(email["uid"], att["filename"])
            if pdf_bytes:
                # Pass password if the PDF is password-protected (e.g., bank statements)
                text = extract_pdf_text(pdf_bytes, password="optional_password")
                print(text)

MCPサーバー (Claude Desktop / Cursor / Antigravity)

Model Context Protocol (MCP) サーバーとして実行します:

python server.py

claude_desktop_config.json の例:

{
  "mcpServers": {
    "maildoc": {
      "command": "python",
      "args": ["/absolute/path/to/maildoc/server.py"],
      "env": {
        "GMAIL_USERNAME": "user@example.com",
        "GMAIL_APP_PASSWORD": "your_app_password"
      }
    }
  }
}

ツールリファレンス

メールと検索

  • search_emails(sender, subject, body, seen, date_gte, date_lt, with_attachments, folder, limit): メールボックスを検索し、構造化された辞書を返します。

  • fetch_email_by_uid(uid, folder): UIDで単一のメールを取得します。

  • list_folders(): メールボックスのフォルダを一覧表示します。

  • mark_email_as_read(uid, folder): メールを既読にします。

  • move_email(uid, destination_folder, source_folder): メールをフォルダ間で移動します。

  • delete_email(uid, folder): メールを削除します。

  • create_folder(folder_name): メールボックスのフォルダを作成します。

  • delete_folder(folder_name): メールボックスのフォルダを削除します。

  • connect_to_email(), disconnect_from_email(): 接続ライフサイクルのヘルパーです。

PDF抽出

  • read_pdf_attachment(uid, attachment_filename, password=None, folder="INBOX"): 添付ファイルをダウンロードし、そのテキストを直接1ステップで抽出します(MCP / AIエージェントに最適)。

  • extract_pdf_text(pdf_bytes, password=None): PDFバイトからすべてのテキストを抽出します。

  • extract_pdf_page_text(pdf_bytes, page_number, password=None): 特定のページ(1始まり)からテキストを抽出します。

Related MCP Connectors

Related MCP Servers

  • F
    license
    B
    quality
    D
    maintenance
    Enables AI assistants to interact with Gmail accounts for searching, reading, sending, and managing emails through secure OAuth2 authentication. It provides comprehensive tools for message operations, conversation threads, and account statistics using the FastMCP framework.
    8
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Full Gmail control for any MCP-compatible AI agent. Exposes ~40 tools for reading, composing, labeling, filtering, threading, and account management.
    -