Loading

How to Build AI Email Agents with Google ADK and MCP?

Artificial Intelligence (AI) has evolved dramatically from its origins as simple rule-based systems. Modern AI models excel in language comprehension, vision, reasoning, and decision-making. One of the earliest AI applications was the chatbot—a tool designed to answer questions in natural language.

For years, AI’s role was limited to: You ask, it responds. This was helpful but constrained.

What if AI could do more than answer? What if it could act?

Think of an assistant that doesn’t just recommend a restaurant but reserves a table for you, or one that doesn’t just list deadlines but updates your project management tool on your behalf. This is the power of AI Agents—intelligent systems that execute tasks, not just provide information.

What Are AI Agents?

An AI Agent goes beyond a chatbot. It’s a specialized assistant built for specific tasks, capable of taking actions rather than only offering suggestions. Think of it as a virtual employee equipped with tools to complete jobs.

Example:

A Travel Booking Agent doesn’t just search for flights. It checks your calendar, selects optimal flights, books a ticket based on your preferences, and sends check-in reminders—all from a simple request like, “Get me to Dubai next weekend.”

The Power of Tools

An agent’s strength comes from its ability to use tools. A tool is any external resource, service, or function that enables task completion. These include:

⦁ Web browsers ⦁ Email or calendar APIs ⦁ Databases ⦁ Code interpreters ⦁ Third-party apps like Slack, Trello, or Notion ⦁ Custom functions for specific tasks

By integrating reasoning with tool access, agents become active executors, not passive advisors.

Model Context Protocol (MCP)

To enable seamless integration between AI agents and external tools, the Model Context Protocol (MCP) has emerged as a critical standard. MCP is an open protocol that standardizes how Large Language Models (LLMs) communicate with data sources, applications, and tools. Think of it as a universal connector, like a USB-C port for AI, simplifying how agents access context and execute actions.

MCP operates on a client-server architecture: ⦁ MCP Servers: Expose tools, data (resources), or interactive templates (prompts) to agents. ⦁ MCP Clients: AI agents or LLM host applications that consume these resources to perform tasks.

This standardization eliminates the need for custom integrations for every tool, fostering an ecosystem where agents can dynamically discover and use capabilities provided by MCP servers.

Email Crafting and Sending Workflow

To explore AI agents and MCP, a project was built using the Google Agent Development Kit (ADK), a framework for creating task-oriented agents. The project automated email crafting and sending, showcasing how agents can execute tasks with MCP integration. The system uses a root agent to coordinate two sub-agents:

⦁ Email Crafter Agent: Collects the recipient’s email, subject, and body, refining drafts based on user feedback. ⦁ Email Sender Agent: Sends the finalized email using a Python function connected to the Gmail API. MCP enabled the email sender agent to access the Gmail API as an MCP compatible tool, streamlining the integration.

Steps of the Workflow

User Request: The user asks the root agent to create and send an email. ⦁ Crafting Phase: The root agent delegates to the email crafter, which gathers the recipient’s email, subject, and content, refining the draft per user input. ⦁ Approval: The crafter outputs the draft in a structured format:
Recipient: jane.doe@example.com
Subject: Meeting Follow-Up
Body: Hi Jane, thanks for the meeting...
The root agent confirms, “Ready to send?” ⦁ Sending Phase: Upon approval, the root agent passes the data to the email sender, which uses an MCP-compatible tool to send the email via the Gmail API. ⦁ Confirmation: The user receives a success or error notification.

Building Agents with ADK and MCP

Using ADK, We defined agents and tools, integrating MCP for tool access. Below are key components:

Defining an Agent

Agents are created with a name, model, description, and instructions. The description guides the root agent in task delegation.

from google.adk.agents import Agent

crafting_agent = Agent( name="email_crafter", model="gemini-2.0-flash-exp", description="Gathers recipient, subject, and body to compose an email.", instruction="Ask for email details and output in a structured format." )

Defining a Tool

A tool is a Python function with a clear docstring, which the agent uses to identify its purpose. The email sender used an MCP-compatible tool for the Gmail API.

def send_email(recipient: str, subject: str, body: str): """Sends an email to the specified recipient with the given subject and body.""" #Gmail API logic via MCP server return "Email sent successfully!"

Creating Sub-Agents

The sender agent was assigned the send_email tool, with MCP facilitating access.

sending_agent = Agent( name="email_sender", model="gemini-2.0-flash-exp", description="Sends emails using provided recipient, subject, and body.", instruction="Extract email details and use the send_email tool.", tools=[send_email] )

Orchestrating with a Root Agent

The root agent coordinates, passing data between sub-agents based on their descriptions.

root_agent = Agent( name="email_workflow_manager", model="gemini-2.0-flash-exp", description="Orchestrates email crafting and sending.", instruction="Engage email_crafter to gather details, then pass to email_sender.", sub_agents=[crafting_agent, sending_agent] )

Integrating MCP

To integrate MCP, MCPToolset class was used in ADK to connect the email sender agent to an MCP server hosting the Gmail API tool:

Connect: The agent establishes a connection to the MCP server (local or remote). ⦁ Discover: Queries the server for available tools using the list_tools method. ⦁ Adapt: Converts MCP tool schemas into ADK-compatible tools. ⦁ Execute: Forwards tool calls to the MCP server via the call_tool method.

This allowed the email sender to access the Gmail API seamlessly, demonstrating MCP’s role in simplifying tool integration.

Importance of Descriptions and Docstrings

• Agent Descriptions: The root agent uses sub-agent descriptions to assign tasks accurately. A clear description like “Sends emails” ensures proper delegation. • Tool Docstrings: Agents rely on docstrings to select tools. A precise docstring like “Sends an email” ensures the correct tool is used, especially with MCP tools.

Lessons from the Experiment

This project highlighted how AI agents, powered by ADK and MCP, can automate tasks efficiently. The root agent’s orchestration, the sub-agents’ specialized roles, and MCP’s standardized tool access created a streamlined, user-centric system. MCP’s client-server model eliminated the need for custom API integrations, making the Gmail API tool reusable across agents.

Artificial Intelligence (AI) has evolved dramatically from its origins as simple rule-based systems. Modern AI models excel in language comprehension, vision, reasoning, and decision-making. One of the earliest AI applications was the chatbot—a tool designed to answer questions in natural language. For years, AI’s role was limited to: You ask, it responds. This was helpful but constrained. What if AI could do more than answer? What if it could act? Think of an assistant that doesn’t just recommend a restaurant but reserves a table for you, or one that doesn’t just list deadlines but updates your project management tool on your behalf. This is the power of AI Agents—intelligent systems that execute tasks, not just provide information.

Conclusion

AI agents are redefining our interaction with technology. By combining reasoning, tool usage, and standards like MCP, they enable automation of routine tasks and complex workflows. Frameworks like ADK and protocols like MCP are building a scalable, secure, and interoperable ecosystem for agents.

This email project is just the start. Imagine agents managing schedules, generating reports, or debugging code, all coordinated by a root agent and powered by MCP-compatible tools. As AI agents evolve, they’ll shift us from passive AI interactions to active, task-driven partnerships, transforming productivity and innovation.