---
title: "Deploy gmailmcp"
description: "Deploy and Host gmailmcp with Railway"
category: "Other"
url: https://railway.com/deploy/gmailmcp
---

# Deploy gmailmcp

Deploy and Host gmailmcp with Railway

**[Deploy gmailmcp on Railway](https://railway.com/template/gmailmcp)**

- **Creator:** Eito Miyamura's Projects
- **Category:** Other

## Template content

### gmailmcp-landing-page

- **Source:** https://github.com/Miyamura80/MCP-Template
- **Public domain:** Yes

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### gmailmcp-backend

- **Source:** https://github.com/Miyamura80/MCP-Template
- **Public domain:** Yes

## Documentation

# Deploy and Host gmailmcp on Railway

gmailmcp is a Model Context Protocol (MCP) server that connects AI clients such as Claude, Cursor, or any MCP host to Gmail. After a one-time Google OAuth connection, your assistant can read, search, organize, draft, and send email on your behalf, at your direction, over a single authenticated `/mcp` endpoint.

## About Hosting gmailmcp

Hosting gmailmcp means running a FastAPI + FastMCP backend as a single Docker image that exposes the MCP server at `/mcp` alongside an HTTP API. It needs a PostgreSQL database for application state and for encrypted OAuth token storage; Alembic migrations run automatically before each deploy. Authentication is handled by WorkOS AuthKit (OAuth 2.1 on the MCP transport), and Gmail access uses a Google Cloud OAuth client requesting the `gmail.modify` scope. You provide those credentials as environment variables; the template auto-generates the session secret and the token-encryption key and wires the database connection for you. After the first deploy, point your OAuth redirect URIs at the assigned Railway domain.

## Common Use Cases

- Give an AI assistant secure, scoped access to read and triage an inbox: list and search threads, open messages, mark read/done, and archive.
- Draft, reply to, and send email through natural-language instructions in your MCP client, with drafts you can review before they go out.
- Run agentic inbox-curation workflows (bulk clean-up and prioritization) without handing the model your raw Google password or full account access.

## Dependencies for gmailmcp Hosting

- A PostgreSQL database (provisioned automatically by this Railway template).
- A WorkOS AuthKit account for OAuth 2.1 authentication on the `/mcp` endpoint.
- A Google Cloud OAuth client with the Gmail API enabled (`gmail.modify` scope).

### Deployment Dependencies

- WorkOS AuthKit: https://workos.com/docs/authkit
- Google Cloud OAuth credentials: https://console.cloud.google.com/apis/credentials
- Gmail API scopes reference: https://developers.google.com/gmail/api/auth/scopes
- Model Context Protocol: https://modelcontextprotocol.io
- Source template: https://github.com/Miyamura80/MCP-Template

### Implementation Details

The backend reads its database URL from `BACKEND_DB_URI`; in the template this is wired to the Postgres service with `${{Postgres.DATABASE_URL}}` over Railway's private network. Two secrets are generated once at deploy and persisted (so redeploys never invalidate sessions or stored tokens):

```
SESSION_SECRET_KEY   = ${{ secret(32) }}
GOOGLE_TOKEN_ENC_KEY = ${{ secret(43, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_") }}=
```

`GOOGLE_TOKEN_ENC_KEY` is a Fernet key (32 bytes, url-safe base64): 43 random base64url characters plus a literal `=` decode to exactly 32 bytes. The public URL values resolve from the assigned domain, e.g. `MCP_PUBLIC_URL = https://${{RAILWAY_PUBLIC_DOMAIN}}/mcp`.

## Why Deploy gmailmcp on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying gmailmcp on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — [Jul'26] Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/gmailmcp
