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:package.json includes these scripts:
index.ts with this small zoo server:
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
Themcp-server template intentionally has no React UI. Install the View
dependencies:
views/animal-card/view.tsx:
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:
http://localhost:8080/mcp.
Add a Dockerfile
CreateDockerfile:
.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:Deploy a private service
Deploy from source and require an authenticated Cloud Run invoker:--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.