Host an Model Context Protocol SSE deployment on Cloud Run, Authenticating with IAM.
What is the freetech company mcp sse authenticated cloud run
Host MCP SSE Server on Google Cloud Run
At the moment (03/04/2024) MCP is still addressing Authentication and Authorization. They plan to complete this in H1 2025. The issue is, I want to share my MCP server with my team NOW. So here we are. The only immediate answer to use a SSE MCP server in Cursor, etc.. right now is a network layer based solution (e.g., a proxy). Basic auth, api keys, forget about it.
Utilizing GCP Cloud Run and User Based IAM Authentication, I have created a simple, secure way to allow clients to access a custom MCP server over the internet.
How it works
The MCP server is hosted on Google Cloud Run. Utilizing Cloud Run IAM Authentication, we can securely connect to the server from the internet by utilizing the Google Cloud SDK to create a proxy connection.
TLDR README
This should work out of the box with minimal config if you already have docker and the gcloud CLI set up locally.
Step 1: Update deploy.sh
with your project id, service account email, etc.
Step 2: On deploy success, grab the cloud run URL that was provided, and add it to mcp_proxy.ts
along with your project id.
Step 3: Run the proxy npx ts-node mcp_proxy.ts
Step 3: Access your MCP server using http://localhost:3030 - Add it to Cursor under Settings > Features > MCP Servers (make sure you select SSE not command)
LONG BORING README
Deployment Steps
- Clone the repository
- Run
npm install
to install the dependencies - Run
npm run dev
to start the server locally
Deployment to Google Cloud Run
To deploy your MCP server to Google Cloud Run:
- Make sure you have the Google Cloud SDK installed
- Update the
deploy.sh
script with your project details:PROJECT_ID
: Your Google Cloud project IDREGION
: Your preferred GCP regionSERVICE_ACCOUNT_EMAIL
: The service account email with appropriate permissions
- Run the deployment script:
chmod +x deploy.sh ./deploy.sh
The deployment script will:
- Build a Docker container for your MCP server
- Push it to Google Container Registry
- Deploy it to Cloud Run with authentication enabled
Connecting to your deployed MCP server
To connect to your deployed MCP server:
-
Run the MCP proxy locally:
npx ts-node mcp_proxy.ts
-
The proxy will:
- Check if you're authenticated with Google Cloud
- Obtain authentication tokens automatically
- Create a local proxy server (default: http://localhost:3030)
- Forward authenticated requests to your Cloud Run service
-
Configure your MCP client to connect to the local proxy URL
Use the MCP server in Cursor
- First, let's run our proxy to establish a connection between our local machine and the MCP server hosted on Google Cloud Run.
npx ts-node mcp_proxy.ts
- Now let's add our local proxy server to cursor within the Setting > Features tab in the MCP server section.
- Now, we're good to go! Start a new composer (ensure you are in agent mode) and ask what the weather is in a location. Your ouput in your terminal where the proxy is connected + the output of your composer should look like this:
Security
This setup provides several security benefits:
- Your MCP server is not publicly accessible without authentication
- All connections are secured with Google Cloud IAM
- Team members need Google Cloud SDK access to connect
Connection Issues
- Verify the Cloud Run URL in
mcp_proxy.ts
matches your deployed service - Check Cloud Run logs for any server-side errors
Contributing
Contributions are welcome! Feel free to submit issues or pull requests.
License
Leave a Comment
Frequently Asked Questions
What is MCP?
MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications, providing a standardized way to connect AI models to different data sources and tools.
What are MCP Servers?
MCP Servers are lightweight programs that expose specific capabilities through the standardized Model Context Protocol. They act as bridges between LLMs like Claude and various data sources or services, allowing secure access to files, databases, APIs, and other resources.
How do MCP Servers work?
MCP Servers follow a client-server architecture where a host application (like Claude Desktop) connects to multiple servers. Each server provides specific functionality through standardized endpoints and protocols, enabling Claude to access data and perform actions through the standardized protocol.
Are MCP Servers secure?
Yes, MCP Servers are designed with security in mind. They run locally with explicit configuration and permissions, require user approval for actions, and include built-in security features to prevent unauthorized access and ensure data privacy.
Related MCP Servers
AWS Knowledge Base Retrieval
An MCP server implementation for retrieving information from the AWS Knowledge Base using the Bedrock Agent Runtime.
chrisdoc hevy mcp
sylphlab pdf reader mcp
An MCP server built with Node.js/TypeScript that allows AI agents to securely read PDF files (local or URL) and extract text, metadata, or page counts. Uses pdf-parse.
aashari mcp server atlassian bitbucket
Node.js/TypeScript MCP server for Atlassian Bitbucket. Enables AI systems (LLMs) to interact with workspaces, repositories, and pull requests via tools (list, get, comment, search). Connects AI directly to version control workflows through the standard MCP interface.
aashari mcp server atlassian confluence
Node.js/TypeScript MCP server for Atlassian Confluence. Provides tools enabling AI systems (LLMs) to list/get spaces & pages (content formatted as Markdown) and search via CQL. Connects AI seamlessly to Confluence knowledge bases using the standard MCP interface.
prisma prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
Zzzccs123 mcp sentry
mcp sentry for typescript sdk
zhuzhoulin dify mcp server
zhongmingyuan mcp my mac
zhixiaoqiang desktop image manager mcp
MCP 服务器,用于管理桌面图片、查看详情、压缩、移动等(完全让Trae实现)
Submit Your MCP Server
Share your MCP server with the community
Submit Now