Authenticated Cloud Run MCP server

Enables secure hosting on Google Cloud Run with user-based IAM authentication, providing controlled access to custom servers over the internet for team collaboration.
Back to servers
Provider
FreeTech
Release date
Mar 05, 2025
Language
TypeScript
Stats
18 stars

This MCP SSE Server on Google Cloud Run provides a secure way to share your Model Context Protocol server with team members before official authentication features are available. By leveraging Google Cloud Run and User-Based IAM Authentication, you can allow clients to access your custom MCP server over the internet with proper security controls.

How It Works

The MCP server is hosted on Google Cloud Run. Using Cloud Run IAM Authentication, you can securely connect to the server from the internet by creating a proxy connection with the Google Cloud SDK.

Quick Installation Guide

This setup should work with minimal configuration if you already have Docker and the gcloud CLI installed locally:

  1. Update deploy.sh with your project id, service account email, and other details
  2. Deploy the service and note the provided Cloud Run URL
  3. Add the URL to mcp_proxy.ts along with your project id
  4. Run the proxy: npx ts-node mcp_proxy.ts
  5. Access your MCP server at http://localhost:3030

Detailed Deployment Steps

Local Testing

Before deployment, you can test the server locally:

npm install
npm run dev

Deploying to Google Cloud Run

  1. Ensure you have the Google Cloud SDK installed
  2. Update the deploy.sh script with your project details:
    • PROJECT_ID: Your Google Cloud project ID
    • REGION: Your preferred GCP region
    • SERVICE_ACCOUNT_EMAIL: The service account email with appropriate permissions
  3. Make the script executable and run it:
chmod +x deploy.sh
./deploy.sh

The deployment script will build a Docker container, push it to Google Container Registry, and deploy it to Cloud Run with authentication enabled.

Connecting to Your MCP Server

Running the Proxy

Run the MCP proxy locally to connect to your deployed server:

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

Using with Cursor

  1. Start the proxy connection:

    npx ts-node mcp_proxy.ts
    
  2. Add your local proxy server to Cursor:

    • Go to Settings > Features
    • In the MCP Servers section, add http://localhost:3030
    • Make sure to select SSE (not command)
  3. Test the connection by starting a new composer in agent mode and asking a question

Troubleshooting

Connection Issues

If you experience connection problems:

  • Verify the Cloud Run URL in mcp_proxy.ts matches your deployed service
  • Check Cloud Run logs for any server-side errors
  • Ensure you have proper authentication with Google Cloud

Security Benefits

This setup provides strong security advantages:

  • 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

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later