MCP-Server-n8n
This project provides a Model Context Protocol server built with n8n, allowing AI systems to interact with various Google services and other utility tools through a unified interface. It includes integrations for Google Calendar, Docs, Drive, and Gmail, as well as a range of utility functions. Security and credential management are emphasized.
MCP Server for n8n
Overview
This repository contains an implementation of a Model Context Protocol (MCP) server built using n8n. The MCP server provides AI systems with access to various external tools and services through a standardized interface.
Architecture
The server is built around an MCP Trigger node that exposes a webhook endpoint, allowing AI systems to connect and utilize the available tools. All tools are connected to this central trigger node, which handles incoming requests and routes them to the appropriate service.
Available Tools
The MCP server provides access to the following services and tools:
Google Calendar Integration
- get_calendar_events: Retrieve events from a specified calendar
- get_calendar_availability: Check calendar availability for a specific time range
- create_calendar_event: Create new calendar events
- update_calendar_event: Modify existing calendar events
Google Docs Integration
- create_google_doc: Create a new Google Doc in a specified folder
- update_google_doc: Insert text into an existing Google Doc
- get_google_doc: Retrieve the contents of a Google Doc
Google Drive Integration
- search_google_drive: Search for files and folders in Google Drive
Gmail Integration
- send_email: Send new emails
- get_emails: Retrieve a list of emails
- get_email: Get a specific email by ID
- reply_to_email: Reply to an existing email thread
Utility Tools
- google_search: Perform web searches using SerpAPI
- Calculator: Perform mathematical calculations
- get_job_app_data: Retrieve data from a specific HTTP endpoint
Setup Instructions
Prerequisites
- n8n installed (either locally or on a server)
- Google account with access to Calendar, Drive, Docs, and Gmail
- SerpAPI account and API key (for web search functionality)
Installation
-
Clone this repository:
git clone https://github.com/yourusername/MCP-Server-n8n.git cd MCP-Server-n8n
-
Import the workflow:
- In n8n, go to Workflows → Import From File
- Select the
MCP_Server.example.json
file
-
Configure credentials:
- You'll need to set up the following OAuth2 credentials in n8n:
- Google Calendar
- Google Docs
- Google Drive
- Gmail
- Add your SerpAPI key
- You'll need to set up the following OAuth2 credentials in n8n:
-
Update placeholders:
- Replace all instances of
YOUR_EMAIL@example.com
with your actual email - Update the Google Drive folder ID for document creation
- Configure the HTTP request node with the appropriate endpoint if needed
- Replace all instances of
-
Activate the workflow:
- Save the workflow
- Toggle the "Active" switch to enable it
Security Considerations
When using this MCP Server, be aware of the following security considerations:
-
Credential Protection: Never commit actual credential IDs or tokens to version control. The
.gitignore
file is set up to prevent this, but always double-check before pushing changes. -
Access Control: The webhook endpoint can be accessed by anyone who knows the URL. Consider implementing authentication mechanisms or IP restrictions.
-
Data Privacy: This server has access to potentially sensitive data in your Google services. Be mindful of what operations you allow and who has access to the server.
-
API Rate Limits: Be aware of rate limits for the various APIs being used, especially SerpAPI which may have usage-based billing.
Usage
AI systems can connect to this MCP server to perform operations that require access to external services. The server acts as a bridge between the AI and these services, handling authentication and providing a standardized interface for interaction.
Webhook
The MCP Trigger node exposes a webhook endpoint at the path /mcp-test
which serves as the entry point for AI systems to interact with the available tools.
Implementation Details
The workflow is organized into logical sections using sticky notes:
- Google Calendar
- Google Drive
- Google Docs
- Gmail
- Miscellaneous Tools
Each tool is configured to accept parameters from the AI system, with many parameters using the $fromAI()
function to dynamically accept input at runtime.
Contributing
If you want to contribute to this project:
- Create a branch for your feature
- Make your changes
- Use the sanitized version of the configuration file for any examples
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.