콘텐츠로 이동

ADK용 AgentMail MCP 도구

ADK에서 지원PythonTypeScriptGo

The AgentMail MCP Server 는 AI 에이전트용으로 제작된 이메일 수신함 API인 AgentMail을(를) ADK 에이전트와 연결합니다. 이 통합을 통해 에이전트는 자연어로 메시지를 보내고, 받으며, 답장하고, 전달할 수 있는 고유한 이메일 수신함을 갖게 됩니다.

사용 사례

  • 에이전트 전용 수신함 제공: 에이전트가 인간 팀원처럼 독립적으로 이메일을 보내고 받을 수 있도록, 전용 이메일 주소를 생성하세요.

  • 이메일 워크플로우 자동화: 초기 메시지 발송, 회신 읽기, 스레드 추적을 포함해 이메일 대화를 처음부터 끝까지 처리하게 합니다.

  • 수신함 간 대화 관리: 스레드와 메시지를 조회·검색하고, 이메일을 전달하며, 첨부파일을 가져와 에이전트가 항상 최신 상태를 유지하도록 관리합니다.

필수 조건

에이전트와 함께 사용

from google.adk.agents import Agent
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StdioConnectionParams
from mcp import StdioServerParameters

AGENTMAIL_API_KEY = "YOUR_AGENTMAIL_API_KEY"

root_agent = Agent(
    model="gemini-2.5-pro",
    name="agentmail_agent",
    instruction="Help users manage email inboxes and send messages",
    tools=[
        McpToolset(
            connection_params=StdioConnectionParams(
                server_params=StdioServerParameters(
                    command="npx",
                    args=[
                        "-y",
                        "agentmail-mcp",
                    ],
                    env={
                        "AGENTMAIL_API_KEY": AGENTMAIL_API_KEY,
                    }
                ),
                timeout=30,
            ),
        )
    ],
)
import { LlmAgent, MCPToolset } from "@google/adk";

const AGENTMAIL_API_KEY = "YOUR_AGENTMAIL_API_KEY";

const rootAgent = new LlmAgent({
    model: "gemini-2.5-pro",
    name: "agentmail_agent",
    instruction: "Help users manage email inboxes and send messages",
    tools: [
        new MCPToolset({
            type: "StdioConnectionParams",
            serverParams: {
                command: "npx",
                args: ["-y", "agentmail-mcp"],
                env: {
                    AGENTMAIL_API_KEY: AGENTMAIL_API_KEY,
                },
            },
        }),
    ],
});

export { rootAgent };
package main

import (
    "context"
    "log"
    "os"
    "os/exec"

    "github.com/modelcontextprotocol/go-sdk/mcp"
    "google.golang.org/genai"

    "google.golang.org/adk/v2/agent"
    "google.golang.org/adk/v2/agent/llmagent"
    "google.golang.org/adk/v2/cmd/launcher"
    "google.golang.org/adk/v2/cmd/launcher/full"
    "google.golang.org/adk/v2/model/gemini"
    "google.golang.org/adk/v2/tool"
    "google.golang.org/adk/v2/tool/mcptoolset"
)

const agentMailAPIKey = "YOUR_AGENTMAIL_API_KEY"

func main() {
    ctx := context.Background()

    model, err := gemini.NewModel(ctx, "gemini-flash-latest", &genai.ClientConfig{
        APIKey: os.Getenv("GOOGLE_API_KEY"),
    })
    if err != nil {
        log.Fatalf("Failed to create the model: %v", err)
    }

    server := exec.CommandContext(ctx, "npx", "-y", "agentmail-mcp")
    // Forward only what npx needs, plus the AgentMail key. The parent environment
    // may hold unrelated secrets, such as the GOOGLE_API_KEY read above.
    server.Env = []string{"AGENTMAIL_API_KEY=" + agentMailAPIKey}
    for _, k := range []string{
        "PATH", "HOME", // POSIX
        "APPDATA", "LOCALAPPDATA", "TEMP", "USERPROFILE", // Windows
    } {
        if v, ok := os.LookupEnv(k); ok {
            server.Env = append(server.Env, k+"="+v)
        }
    }

    agentmail, err := mcptoolset.New(mcptoolset.Config{
        Transport: &mcp.CommandTransport{Command: server},
    })
    if err != nil {
        log.Fatalf("Failed to create the AgentMail tool set: %v", err)
    }

    rootAgent, err := llmagent.New(llmagent.Config{
        Model:       model,
        Name:        "agentmail_agent",
        Instruction: "Help users manage their inboxes and send emails with AgentMail",
        Toolsets:    []tool.Toolset{agentmail},
    })
    if err != nil {
        log.Fatalf("Failed to create the agent: %v", err)
    }

    l := full.NewLauncher()
    cfg := &launcher.Config{AgentLoader: agent.NewSingleLoader(rootAgent)}
    if err := l.Execute(ctx, cfg, os.Args[1:]); err != nil {
        log.Fatalf("Run failed: %v\n\n%s", err, l.CommandLineSyntax())
    }
}

사용 가능한 도구

수신함 관리

도구 설명
list_inboxes 모든 수신함을 조회합니다.
get_inbox 특정 수신함의 세부 정보를 가져옵니다.
create_inbox 사용자명 및 도메인이 포함된 새 수신함을 생성합니다.
delete_inbox 수신함을 삭제합니다.

스레드 관리

도구 설명
list_threads 수신함의 스레드를 조회합니다.
get_thread 메시지와 함께 특정 스레드를 조회합니다.
get_attachment 메시지에서 첨부파일을 다운로드합니다.

메시지 작업

도구 설명
send_message 수신함에서 새 이메일을 전송합니다.
reply_to_message 기존 메시지에 답장합니다.
forward_message 메시지를 다른 수신자에게 전달합니다.
update_message 읽음 상태 등 메시지 속성을 갱신합니다.

추가 리소스