google-workspace-mcp-server
Provides tools for sending emails and creating drafts via the Gmail API.
Provides a tool for appending content to Google Docs.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@google-workspace-mcp-serversend an email to hello@example.com with subject 'Greetings' and body 'Hello from MCP!'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Google Workspace MCP Server
A generic, agent-agnostic Model Context Protocol (MCP) server that exposes Gmail and Google Docs capabilities as tools. Any MCP-compatible client (Antigravity, Claude Desktop, custom agents) can connect and use these tools without code changes.
Available Tools
Tool | Description |
| Send an email via Gmail on behalf of the authenticated user |
| Create a draft email in Gmail without sending |
| Append text content to the end of a Google Doc |
Related MCP server: Gmail MCP Server
Prerequisites
Node.js 18 or later
A Google Cloud project with billing enabled (or free tier)
Google Cloud Setup
1. Create a Google Cloud Project
Go to Google Cloud Console.
Create a new project (or select an existing one).
2. Enable APIs
Enable the following APIs for your project:
Gmail API: Enable here
Google Docs API: Enable here
3. Create OAuth 2.0 Credentials
Go to APIs & Services → Credentials.
Click Create Credentials → OAuth client ID.
Select Desktop app as the application type.
Name it (e.g., "MCP Server") and click Create.
Download or copy the Client ID and Client Secret.
4. Configure the OAuth Consent Screen
Go to APIs & Services → OAuth consent screen.
Select External user type (or Internal if using Workspace).
Fill in the required app info and add the following scopes:
https://www.googleapis.com/auth/gmail.sendhttps://www.googleapis.com/auth/gmail.composehttps://www.googleapis.com/auth/documents
Add your Google account as a test user (required for external apps in testing).
Installation
# Clone or navigate to the project directory
cd mcp-server
# Install dependencies
npm install
# Copy the environment template
cp .env.example .envEdit .env and fill in your Google credentials:
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
GOOGLE_REDIRECT_URI=urn:ietf:wg:oauth:2.0:oob
GOOGLE_TOKEN_PATH=./token.jsonAuthorization
Run the one-time authorization flow to grant the server access to your Google account:
npm run authorizeThis will:
Display a URL — open it in your browser.
Sign in with your Google account and grant access.
Paste the authorization code back into the terminal.
Save the OAuth tokens to
token.json.
Note: You only need to do this once. Tokens refresh automatically after that.
Running the Server
Development (with hot reload)
npm run devProduction
npm run build
npm startConnecting to MCP Clients
Antigravity
Add to your Antigravity MCP settings:
{
"mcpServers": {
"google-workspace": {
"command": "node",
"args": ["C:/path/to/mcp-server/dist/index.js"]
}
}
}Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"google-workspace": {
"command": "node",
"args": ["/absolute/path/to/mcp-server/dist/index.js"]
}
}
}MCP Inspector (Testing)
Use the MCP Inspector to test your tools interactively:
npx @modelcontextprotocol/inspector node dist/index.jsTool Schemas
gmail_send_email
{
"to": "recipient@example.com",
"subject": "Hello from MCP",
"body": "This email was sent by an AI agent via the MCP server.",
"cc": "cc@example.com",
"bcc": ["bcc1@example.com", "bcc2@example.com"],
"body_html": "<h1>Hello</h1><p>HTML email body</p>"
}gmail_create_draft
Same schema as gmail_send_email. Creates a draft without sending.
gdocs_append_content
{
"document_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVf2oVzk",
"content": "This text was appended by an AI agent.",
"add_newline": true
}Troubleshooting
Problem | Solution |
| Copy |
| Run |
| Delete |
| Ensure the Gmail and Docs APIs are enabled in your Google Cloud project |
| The document ID is the long string in the URL: |
| Make sure your account is added as a test user in the OAuth consent screen |
| Set |
| Re-run |
Deploy to Railway
Prerequisites
The MCP server running locally with a valid
token.json(complete the Authorization steps first)A Railway account
A GitHub repository with this code pushed
Step 1: Export Your Token
npm run export-tokenThis outputs a Base64-encoded string of your token.json. Copy it — you'll need it in Step 3.
Step 2: Create Railway Service
Go to Railway Dashboard.
Click New Project → Deploy from GitHub Repo.
Select your repository.
Railway will auto-detect the
Dockerfileand begin building.
Step 3: Set Environment Variables
In the Railway service dashboard, go to Variables and add:
Variable | Value |
|
|
| Your Google OAuth client ID |
| Your Google OAuth client secret |
| The Base64 string from Step 1 |
| A secret key of your choice (for securing the endpoint) |
Note:
PORTis injected automatically by Railway. Do not set it manually.
Step 4: Deploy
Railway will automatically build and deploy. Once live, you'll get a public URL like:
https://your-app-name.up.railway.appStep 5: Verify
# Health check
curl https://your-app-name.up.railway.app/health
# Test MCP endpoint (replace YOUR_API_KEY)
curl -X POST https://your-app-name.up.railway.app/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{}},"id":1}'Step 6: Connect Remote MCP Client
Configure your MCP client to connect to the deployed server. Example for clients that support Streamable HTTP:
{
"mcpServers": {
"google-workspace-remote": {
"url": "https://your-app-name.up.railway.app/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}Project Structure
├── src/
│ ├── index.ts # Server entry point (stdio + HTTP dual transport)
│ ├── auth/
│ │ └── google-auth.ts # OAuth2 authentication (file + env var dual mode)
│ ├── services/
│ │ ├── gmail.service.ts # Gmail API logic
│ │ └── gdocs.service.ts # Google Docs API logic
│ ├── tools/
│ │ ├── gmail-send-email.ts # gmail_send_email tool
│ │ ├── gmail-create-draft.ts # gmail_create_draft tool
│ │ └── gdocs-append.ts # gdocs_append_content tool
│ └── utils/
│ └── mime.ts # MIME message builder
├── scripts/
│ ├── authorize.ts # OAuth consent flow script
│ └── export-token.ts # Token export for cloud deployment
├── Dockerfile # Multi-stage Docker build
├── railway.toml # Railway deployment config
├── .env.example # Environment variable template
├── package.json
├── tsconfig.json
└── README.mdLicense
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/princegrg17/google-workspace-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server