Automating Gmail and Google Calendar with PHP Agents ?⚡
on May 11, 2025
Want to read your unread Gmail emails and book a meeting slot to reply — all while coding? In this article, I'll show you how I automated that entire process using a custom MCP server in PHP, connected to Gmail and Google Calendar through Composio, and wrapped it all up with an AI agent using Uniflow and Neuron AI.
Let's dive into the full stack! 🧠✨
Build a PHP MCP Server ⚙️
First, I created an MCP server using the excellent php-mcp/server package. This gave me a production-ready, flexible setup with support for annotations, dependency injection, custom transports (HTTP, STDIO, etc.), and advanced logging.
composer create-project symfony/skeleton
composer require php-mcp/server
Then I added a basic Tool
(e.g. Adder
) to test interactions with MCP clients like Cursor or LangChain.
Set Up Nix Instead of Docker 🐧
To ensure a clean and reproducible environment, I used Nix instead of Docker. With the nix-chain template, I got PHP, Composer, Symfony CLI, PHPStan, PHPUnit and more preconfigured.
make nix
This keeps my environment declarative and lightweight, perfect for sharing or onboarding others.
Connect Gmail & Google Calendar via Composio 📧📅
Composio is like Zapier for devs. I plugged it into my MCP server using their PHP SDK (inspired by the official JS SDK) and added tools like:
GMAIL_FETCH_EMAILS
GMAIL_SEND_EMAIL
GOOGLECALENDAR_CREATE_EVENT
GOOGLECALENDAR_FIND_FREE_SLOTS
Using the CLI:
php bin/console app:generate-tools \
--entityId default \
--action GMAIL_FETCH_EMAILS \
--action GOOGLECALENDAR_FIND_FREE_SLOTS \
...
Now, my PHP server could dynamically fetch actions based on API keys and entity IDs.
Build an AI Agent with Neuron AI 🧠
Next, I wired everything up with Neuron AI, which lets you create AI agents that can call MCP tools directly. My agent receives a prompt like:
"Please find my unread important emails and schedule a calendar slot to respond."
…and autonomously triggers the Gmail and Calendar tools.
Run the Workflow with Uniflow 🛠️
To complete the workflow, I used Uniflow and its PHP Client to execute the agent's logic:
- Read important emails
- Summarize them
- Book a free time slot on Google Calendar
Uniflow's PHP SDK makes it easy to plug this into a broader automation system or SaaS.
Why PHP? 💡
While most Composio and LLM tooling is JS- or Python-centric, I wanted to prove we can do full agent-based automation in PHP — and it works beautifully!
The result: an AI agent that reads your inbox, prioritizes what matters, and gives you back your time. ❤️
Bonus Tips & Resources 💡
- Use
.cursor/mcp.json
to declare your MCP tools project by project - Switch from Docker to Nix for OS-level reproducibility
- Explore Langflow's Vibe Coding Tips for building smarter workflows
- Observe your agent via inspector.dev for debugging
🧪 Checkout the source code
You can checkout the source code of this article on Github here
👋 Ready to Automate Your Workflows?
If this post inspired you, and you want help automating your own processes (email, marketing, scheduling, scraping...), I've got something for you!
👉 Click here to get my personal help — and let's start building together. 🚀
Resources
- Top 10 VIBE CODING TIPS for Agent-Driven Workflows ? https://www.youtube.com/watch?v=L4Pe8MMhgsg
- js2php : https://github.com/jakubkulhan/js2php
- background credit Nastuh Abootalebi : https://unsplash.com/fr/photos/couloir-entre-les-portes-a-panneaux-de-verre-yWwob8kwOCk