A7 MCP Server AI Agent And External Tool Integration
NLU-AIT A7 [st126235]
Ask AI about A7 MCP Server AI Agent And External Tool Integration
Powered by Claude Β· Grounded in docs
I know everything about A7 MCP Server AI Agent And External Tool Integration. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
A7: MCP-Server, AI Agent, and External Tool Integration
NLU Assignment 7 β MCP-Server, AI Agent, and External Tool Integration Student: Dechathon Niamsa-ard [st126235]
Overview
This project builds an integrated AI Agent ecosystem using the Model Context Protocol (MCP) on n8n, deployed locally via Docker (with PostgreSQL backend) and exposed to the internet using a Cloudflare Quick Tunnel β replacing ngrok as the tunneling solution. The agent is connected to a Telegram Bot for real-time messaging and to Google Calendar for full CRUD event management (Create, Read, Update, Delete), demonstrating a practical NLU-powered scheduling assistant capable of understanding natural language commands and taking real-world actions.
Infrastructure note: Instead of ngrok (as described in the guide), this setup uses
cloudflared tunnel --url http://localhost:5678which generates a temporary public HTTPS URL with no account or token required. The URL is used as the n8n Webhook/Production URL for all MCP and Telegram callbacks.
Task 1: MCP Infrastructure & Server Setup (3 Points)
1.1 Server Deployment β Docker + Cloudflare Tunnel (0.5 pts)
n8n is self-hosted via Docker Compose backed by a PostgreSQL 16 database for persistent workflow and credential storage. The local instance is exposed publicly using Cloudflare Quick Tunnel:
cloudflared tunnel --url http://localhost:5678
This creates a stable HTTPS endpoint (e.g., https://twiki-council-appointments-injuries.trycloudflare.com) that n8n uses as its WEBHOOK_URL, making all webhooks and MCP SSE endpoints reachable from the internet.
Cloudflare Quick Tunnel running in the terminal β the generated public HTTPS URL is printed and used as the n8n Webhook URL throughout the entire assignment.
n8n Welcome page loaded in the browser via the public Cloudflare URL, confirming the tunnel is active and the instance is reachable from the internet.
n8n workflow dashboard showing all workflows. Both MCP Server and Client Side are marked Published (green badge), confirming they are active and accessible via the public tunnel URL.
1.2 MCP Server Workflow β 3 Internal Tools (1 pt)
A dedicated workflow named "MCP Server" acts as the tool provider. An MCP Server Trigger node is the entry point; three internal tool nodes branch from it:
| Tool | Node Type | Function |
|---|---|---|
| Calculator | Built-in Calculator | Evaluates arithmetic expressions |
| Date & Time | Code Tool (Date_and_Time) | Returns current date/time in Asia/Bangkok (UTC+7) |
| Get_Latest_News | HTTP Request Tool | Fetches BBC News RSS via api.rss2json.com β no API key needed |
The workflow is toggled Active (Published). The resulting Production URL (ending in /sse) is the SSE endpoint that the AI Agent Client connects to.
MCP Server workflow: MCP Server Trigger connected to Calculator, Date & Time, and HTTP Request (Get_Latest_News). The β Published indicator at the top-right confirms the workflow is active, exposing all three tools over the SSE endpoint.
1.3 AI Agent Client (1.5 pts)
A second workflow named "Client Side" contains the AI Agent. It is configured as a Tools Agent with the following components:
| Component | Configuration |
|---|---|
| Trigger | When chat message received (Chat Trigger) |
| AI Agent type | Tools Agent |
| Chat Model | OpenAI Chat Model node β Groq API (llama-3.3-70b-versatile), Base URL: https://api.groq.com/openai/v1 |
| Memory | Simple Memory β Window Buffer Memory, context window length: 10 |
| Tool | MCP Client β SSE Endpoint set to the MCP Server Production URL |
The agent is verified by chatting directly in n8n. The execution log shows the MCP Client discovering and invoking tools on the MCP Server.
Client Side workflow executing a news query. The user asks for the latest BBC news; the agent calls the MCP Client β HTTP Request tool and returns structured BBC headlines. The execution log on the right confirms the full tool call chain: AI Agent β Simple Memory β Groq Chat Model β MCP Client β HTTP Request.
Task 2: Telegram & Google Calendar Integration (3 Points)
2.1 Telegram Bot API (0.5 pts)
The Client Side workflow is extended to use Telegram as the messaging channel:
- The When chat message received trigger is replaced with a Telegram Trigger node (listening for
messageupdates, credential: Bot Token from BotFather). - A Send a text message node is added after the AI Agent output, routing the agent's reply back to the user's Telegram chat.
- The bot is named "ST126235 NLP A7 Schedule Bot".
Flow: Telegram Trigger β AI Agent β Send a text message
Client Side workflow updated with Telegram Trigger (left) and Send a text message node (right). The execution log shows a successful Telegram send, with the output confirming the message_id and chat details.
Live Telegram conversation: the bot correctly reports today's date as March 30, 2026 (Bangkok timezone) using the Date & Time MCP tool, and fetches BBC News front-page headlines using the Get_Latest_News MCP tool β both tools invoked transparently via the MCP Server.
2.2 Google Calendar Tool (0.5 pts)
Five Google Calendar nodes are added to the AI Agent's tool set via OAuth 2.0 credentials (Google Cloud Console β Calendar API enabled, redirect URI set to the Cloudflare tunnel URL), providing full CRUD capability:
| Tool Node | Action | Purpose |
|---|---|---|
| Create an event | CREATE | Creates new calendar events with title, date range, all-day flag |
| Get many events | READ | Lists upcoming events within a date range |
| Get an event | READ | Retrieves a single event by ID or by querying a specific date |
| Update an event | UPDATE | Modifies event title, dates, or description |
| Delete an event | DELETE | Permanently removes an event from the calendar |
The agent's system prompt is configured to treat Asia/Bangkok (UTC+7) as the default timezone and always use ISO 8601 date formatting.
AI Agent with all five Google Calendar tools visible. The execution log shows the agent confirming all four project phase events with Google Calendar direct links.
Final Client Side workflow state: Telegram Trigger β AI Agent β Send a text message. The AI Agent has 8 tools: Groq Chat Model, Simple Memory, MCP Client, and all five Google Calendar tools (Create, Get Many, Get One, Update, Delete). Execution log confirms successful calendar event creation.
2.3 Automated Project Scheduling (1 pt)
A natural language scheduling command is sent to the bot via Telegram, requesting creation of four all-day project phase events:
"Please create 4 Google Calendar events for my project: 1. '1st Phase: Literature Review' April 7 to April 20, 2026 2. '2nd Phase: Project Proposal' April 21 to May 4, 2026 3. '3rd Phase: Update Progress' May 5 to May 18, 2026 4. '4th Phase: Final (Presentation)' May 19 to May 25, 2026 Each should be an all-day event."
The agent parses the intent, calls Create an event in Google Calendar four times, and replies with a confirmation summary.
| # | Event | Start | End |
|---|---|---|---|
| 1 | 1st Phase: Literature Review | 2026-04-07 | 2026-04-20 |
| 2 | 2nd Phase: Project Proposal | 2026-04-21 | 2026-05-04 |
| 3 | 3rd Phase: Update Progress | 2026-05-05 | 2026-05-18 |
| 4 | 4th Phase: Final (Presentation) | 2026-05-19 | 2026-05-25 |
Telegram conversation: after verifying the date and fetching news via MCP tools, the user sends the project scheduling command. The bot confirms all four phases are created in Google Calendar with their exact date ranges.
Google Calendar β April 2026 (after creation):
April 2026 calendar view confirming "1st Phase: Literature Review" (Apr 7β20) and the start of "2nd Phase: Project Proposal" (Apr 21) are created as all-day events.
Google Calendar β May 2026 (after creation):
May 2026 calendar view confirming "2nd Phase: Project Proposal" (ending May 4), "3rd Phase: Update Progress" (May 5β18), and "4th Phase: Final (Presentation)" (May 19β25) β all four phases visible on the calendar.
2.4 Interaction Verification β Full CRUD (1 pt)
The agent is verified through a complete Create β Read β Update β Delete cycle, all triggered via natural language in Telegram.
Read β Get Many Events
"What are my upcoming project phases? Can you list all events on my calendar for the next month?"
n8n execution log: AI Agent calls Get many events in Google Calendar, retrieves all four project phases, and returns them to the Telegram user.
Bot lists all four project phase events with exact date ranges, confirming the events are live and readable from Google Calendar.
Read β Get One Event by Date
"What event I have on 12 April 2026?"
n8n execution log: Get an event in Google Calendar returns the "1st Phase: Literature Review" event details (ID, summary, start/end times) for April 12, 2026.
Bot correctly identifies that on April 12, 2026, the user has "1st Phase: Literature Review" β demonstrating single-event lookup by date.
Update Event
"Update literature review to Start April 10 2026 and End with April 21 2026"
n8n execution log: Update an event in Google Calendar successfully modifies the "1st Phase: Literature Review" event β new start: 2026-04-10, new end: 2026-04-21. The output confirms the updated event ID and timestamps.
Bot confirms the update: "The '1st Phase: Literature Review' event has been updated to start on April 10, 2026, and end on April 21, 2026."
April 2026 calendar showing "1st Phase: Literature Review" now starts on April 10 (shifted from April 7), reflecting the update command from Telegram.
Delete Event
"Delete 1st Phase: Literature Review"
April 2026 calendar showing the state before deletion β "1st Phase: Literature Review" (Apr 10β21) and "2nd Phase: Project Proposal" are visible. "Event saved" toast confirms the calendar is live.
n8n execution log: Delete an event in Google Calendar returns success: true β the event has been permanently removed.
Bot confirms: "The event '1st Phase: Literature Review' has been deleted from your Google Calendar."
April 2026 calendar after deletion β "1st Phase: Literature Review" is gone. Only "2nd Phase: Project Proposal" (Apr 21+) and an unrelated event remain, confirming the delete was successful.
Final State
After the CRUD cycle, the event is re-added to restore the original schedule:
"Add '1st Phase: Literature Review' April 7 to April 20, 2026"
Complete Telegram conversation thread showing the full CRUD cycle: Create (Γ4) β Get Many β Update β Get One β Delete β Re-create. The bot handles every operation correctly through natural language, demonstrating end-to-end Google Calendar management.
Architecture Summary
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP Server Workflow β
β MCP Server Trigger βββΊ Calculator β
β βββΊ Date & Time (Code Tool) β
β βββΊ Get_Latest_News (HTTP) β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β Production URL (SSE)
βββββββββββββββββββββββββΌββββββββββββββββββββββββββ
β Client Side Workflow β
β Telegram Trigger β
β β β
β AI Agent (Groq llama-3.3-70b-versatile) β
β βββ Simple Memory (Window Buffer, k=10) β
β βββ MCP Client βββΊ MCP Server (SSE) β
β βββ Create an event in Google Calendar β
β βββ Get many events in Google Calendar β
β βββ Get an event in Google Calendar β
β βββ Update an event in Google Calendar β
β βββ Delete an event in Google Calendar β
β β β
β Send a text message (Telegram) β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β
cloudflared tunnel --url http://localhost:5678
(Cloudflare Quick Tunnel β public HTTPS, no account needed)
| Component | Details |
|---|---|
| n8n | Self-hosted via Docker, PostgreSQL 16 backend, port 5678 |
| Tunnel | Cloudflare Quick Tunnel (cloudflared) β no account or token required |
| LLM | Groq API β llama-3.3-70b-versatile (free tier, OpenAI-compatible) |
| Memory | Window Buffer Memory β context window 10 turns |
| MCP Tools | Calculator, Date & Time (Code), Get_Latest_News (BBC RSS via HTTP) |
| Messaging | Telegram Bot API β ST126235 NLP A7 Schedule Bot |
| Calendar | Google Calendar API via OAuth 2.0 β full CRUD (Create, Get Many, Get One, Update, Delete) |
Setup
1. Configure local_n8n/.env
The .env file holds database credentials and the public tunnel URL used by n8n as its WEBHOOK_URL:
# Database Config
DB_USER=n8n_admin
DB_PASSWORD=your_password
DB_NAME=n8n_db
# Tunnel URL (update this each time cloudflared generates a new URL)
NGROK_URL=https://<your-tunnel>.trycloudflare.com
The variable is named
NGROK_URLfor compatibility with thedocker-compose.yamltemplate, but the value is a Cloudflare Quick Tunnel URL.
2. Start the stack
cd local_n8n
docker compose up -d
3. Start the Cloudflare tunnel
cloudflared tunnel --url http://localhost:5678
# β Copy the generated HTTPS URL into local_n8n/.env as NGROK_URL, then restart:
docker compose restart n8n
4. Configure n8n workflows
- Create / import the MCP Server workflow, publish it, note the Production URL (ends in /sse)
- Create the Client Side workflow:
- Configure Groq API credentials (llama-3.3-70b-versatile)
- Set MCP Client SSE Endpoint to the MCP Server Production URL
- Configure Telegram Bot credentials (Bot Token from BotFather)
- Configure Google Calendar OAuth2 credentials (5 nodes: Create, Get Many, Get One, Update, Delete)
- Activate the Client Side workflow
References
- n8n Documentation β docs.n8n.io
- Cloudflare Quick Tunnels β developers.cloudflare.com/cloudflare-one/connections/connect-networks/do-more-with-tunnels/trycloudflare
- Groq API β console.groq.com
- Google Calendar API β developers.google.com/calendar
- Telegram Bot API β core.telegram.org/bots/api
- Assignment reference environment β github.com/chaklam-silpasuwanchai/Python-fo-Natural-Language-Processing/tree/main/Code/11%20-%20Agentic%20AI/local_n8n
