Deploy gmailmcp
Deploy and Host gmailmcp with Railway
GmailMCP
gmailmcp-landing-page
Just deployed
Just deployed
/var/lib/postgresql/data
gmailmcp-backend
Just deployed
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
/mcpendpoint. - A Google Cloud OAuth client with the Gmail API enabled (
gmail.modifyscope).
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.
Template Content
gmailmcp-landing-page
Miyamura80/MCP-Templategmailmcp-backend
Miyamura80/MCP-Template