Skip to main content
Cloud Run can run a mcp-use server as a long-lived Node process. The generated CLI scripts build the default-exported server and own the HTTP listener. Cloud Run requires the process to listen on 0.0.0.0 and injects the port in PORT. The configuration below satisfies both parts of that container contract.

Create the project

Create the server from the beta template:
The generated package.json includes these scripts:
Replace index.ts with this small zoo server:
There is no top-level listen() call. npm run dev and npm start import the default export and own the listener. At runtime, mcp-use start reads Cloud Run’s PORT before falling back to the server configuration.

Optional: add a View

The mcp-server template intentionally has no React UI. Install the View dependencies:
Create views/animal-card/view.tsx:
The tool’s view.name matches the directory under views/. A view-bound tool must declare outputSchema and return matching structuredContent; the View reads that typed result through useToolContext. Validate the project locally:
The local endpoint is http://localhost:8080/mcp.

Add a Dockerfile

Create Dockerfile:
Create .dockerignore:
npm start serves .mcp-use/build/, binds to the server’s 0.0.0.0 configuration, and uses the injected PORT.

Configure Google Cloud

Select a project and enable the source-deployment services:
Create a dedicated runtime service account:
Set the values used by every deploy:

Deploy a private service

Deploy from source and require an authenticated Cloud Run invoker:
For later revisions, run the same command with the same --region, --service-account, and --no-allow-unauthenticated flags. Keeping the security-sensitive flags in the repeatable deploy command makes the intended IAM posture explicit. Grant your current Google identity permission to invoke the service:

Connect with a materialized ID token

Cloud Run ID tokens expire. Generate the settings file immediately before starting the client rather than putting shell variable names inside JSON:
jq writes the actual URL and token values. If the client later receives 401 Unauthorized, generate a fresh token and regenerate the file.

Verify

Read recent service logs without relying on a fixed log format:
For lifecycle or resource removal, use the Cloud Run and Google Cloud project controls appropriate to your account. This guide intentionally does not run broad cleanup commands.

Platform references