Building Gmail Email Classification with MCP Server + AI Agent

I’m exploring MCP for the first time and trying to understand how to structure a workflow where an AI Agent classifies Gmail emails and then takes different actions based on the classification. I understand I need an MCP Server Trigger workflow and an AI Agent workflow with MCP Client Tool, but I’m confused about what goes where and how to structure the tools effectively.

What I want to build

An intelligent Gmail email classification and automation system that:

  • Processes all emails on a schedule, excluding those already labeled [processed]
  • Classifies them using custom categories (Swedish labels)
  • Takes conditional actions based on classification:
    • Create Todoist task (if action required)
    • Add to Notion database (if needs reading)
    • Archive/delete (if spam/completed)
    • Apply appropriate Gmail labels

Specific questions

1. AI Agent Prompts

Where do I put what prompts in the AI Agent node?

  • Should my classification system (Swedish labels, rules) go in System Message or User Message?
  • What goes in each field exactly?

2. MCP Tool Structure

How should I structure the tools connected to my MCP Server?

Option A: Separate tools for each operation

  • get_emails → Gmail Get many messages (excluding [processed] label)
  • get_email_content → Gmail Get a message (full content)
  • get_labels → Gmail Get many labels (for name-to-ID mapping)
  • apply_labels → Add label to message
  • create_task → Todoist create task
  • add_to_notion → Notion add database item

Option B: Sub-workflows for complex operations

  • process_emails → Sub-workflow handling Gmail operations
  • take_action → Sub-workflow for conditional actions (Todoist/Notion/etc.)

Which approach works better for conditional logic based on classification?

3. Tool Descriptions

How detailed should MCP tool descriptions be for optimal AI understanding?

Example for get_emails:

  • Simple: “Get emails from Gmail”
  • Detailed: “Get emails from Gmail excluding those with [processed] label. Returns array with id, subject, from fields”

4. General Architecture

What’s the recommended pattern for this type of workflow?

  • Should classification logic and conditional actions live in the AI Agent or MCP Server?
  • How do I handle the branching logic (email → different actions based on classification)?
  • Best practices for multi-service MCP workflows?

Current setup

  • n8n Cloud (planning to self-host)
  • Gmail OAuth configured
  • OpenRouter API access
  • Using official MCP Server Trigger and MCP Client Tool nodes

Looking for architectural guidance and examples of similar conditional MCP workflows!

1 Like