MaleekNoob/custom_mcp_servers
If you are the rightful owner of custom_mcp_servers and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
This project demonstrates a FastMCP server with tools for greeting and sending emails via Gmail API.
FastMCP Server with Gmail Tool
This project demonstrates a simple FastMCP server with two available tools: a greet function for basic greetings and a send_email function that leverages the Google Gmail API to send emails.
Project Description
The server.py script sets up a Microservice Communication Protocol (MCP) server using the FastMCP framework. It exposes two remote procedure call (RPC) tools:
greet(name: str): A simple tool that returns a greeting string.send_email(to_email: str, subject: str, body: str): A more advanced tool that connects to the Google Gmail API to send an email to a specified recipient. It handles the OAuth2 authentication flow for you, requiring a one-time setup.
Prerequisites
Before you can run the server and use the send_email tool, you must complete the following steps to set up the Google Gmail API:
-
Google Cloud Project
Go to the Google Cloud Console and create a new project. -
Enable the Gmail API
In your new project, navigate to APIs & Services → Library, then search for and enable the Gmail API. -
Create OAuth 2.0 Credentials
- Go to APIs & Services → Credentials
- Click + CREATE CREDENTIALS and select OAuth client ID
- Choose Desktop app as the application type
- Name your client and click Create
-
Download
credentials.json
A pop-up will display your client ID and secret. Click the DOWNLOAD JSON button and save the file ascredentials.jsonin the same directory as yourserver.pyscript.
Installation
You can install the required libraries using either uv (recommended) or pip.
Using uv (Recommended)
First, make sure uv is installed on your system. Then run:
uv add fastmcp
uv add google-api-python-client google-auth-httplib2 google-auth-oauthlib
You're right — thanks for catching that. Here's the properly rendered Markdown version, without mixing up the code blocks:
Using pip
Alternatively, install the packages with pip:
pip install mcp
pip install fastmcp google-api-python-client google-auth-httplib2 google-auth-oauthlib
Usage
Step 1: Initial Authentication
Before running the server with fastmcp dev, perform a one-time authentication to generate the token.json file. This file securely stores your credentials.
Run the script:
python server.py
This will open a browser window and guide you through Google's authentication process. After a successful login, token.json will be created in your directory.
Step 2: Running the Server
Once you have the token.json file, you can start the FastMCP development server:
fastmcp dev server.py
You should see a message indicating that the server is running and the tools are registered.
Step 3: Using a Client
You can interact with the server's tools by using a client script.
Example:
# client.py
from fastmcp import connect
async def main():
conn = await connect("http://localhost:8000")
# Call greet tool
greeting = await conn.call("greet", {"name": "Alice"})
print("Greet response:", greeting)
# Call send_email tool
result = await conn.call("send_email", {
"to_email": "example@example.com",
"subject": "Test Email",
"body": "Hello from FastMCP!"
})
print("Send email response:", result)
import asyncio
asyncio.run(main())