get_service
Retrieve detailed information about a specific Cloud Run service, including project ID, region, and service name, to manage and monitor deployments effectively.
Instructions
Gets details for a specific Cloud Run service.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | Yes | Google Cloud project ID containing the service | |
| region | No | Region where the service is located | europe-west1 |
| service | Yes | Name of the Cloud Run service |
Implementation Reference
- tools/register-tools.js:195-266 (handler)registerGetServiceTool: registers the MCP 'get_service' tool, defines its input schema, and provides the handler logic that validates parameters and retrieves service details via getService helper.function registerGetServiceTool(server, options) { server.registerTool( 'get_service', { description: 'Gets details for a specific Cloud Run service.', inputSchema: { project: z .string() .describe('Google Cloud project ID containing the service') .default(options.defaultProjectId), region: z .string() .describe('Region where the service is located') .default(options.defaultRegion), service: z .string() .describe('Name of the Cloud Run service') .default(options.defaultServiceName), }, }, gcpTool( options.gcpCredentialsAvailable, async ({ project, region, service }) => { if (typeof project !== 'string') { return { content: [ { type: 'text', text: 'Error: Project ID must be provided.' }, ], }; } if (typeof service !== 'string') { return { content: [ { type: 'text', text: 'Error: Service name must be provided.' }, ], }; } try { const serviceDetails = await getService(project, region, service); if (serviceDetails) { return { content: [ { type: 'text', text: `Name: ${service}\nRegion: ${region}\nProject: ${project}\nURL: ${serviceDetails.uri}\nLast deployed by: ${serviceDetails.lastModifier}`, }, ], }; } else { return { content: [ { type: 'text', text: `Service ${service} not found in project ${project} (region ${region}).`, }, ], }; } } catch (error) { return { content: [ { type: 'text', text: `Error getting service ${service} in project ${project} (region ${region}): ${error.message}`, }, ], }; } } ) ); }
- lib/cloud-api/run.js:95-125 (helper)getService helper function: core implementation that uses Google Cloud Run ServicesClient to fetch service details by path, handles not-found gracefully.export async function getService(projectId, location, serviceId) { if (!runClient) { const { v2 } = await import('@google-cloud/run'); const { ServicesClient } = v2; runClient = new ServicesClient({ projectId }); } const servicePath = runClient.servicePath(projectId, location, serviceId); try { console.log( `Getting details for Cloud Run service ${serviceId} in project ${projectId}, location ${location}...` ); const [service] = await callWithRetry( () => runClient.getService({ name: servicePath }), 'getService' ); return service; } catch (error) { console.error( `Error getting details for Cloud Run service ${serviceId}:`, error ); // Check if the error is a "not found" error (gRPC code 5) if (error.code === 5) { console.log(`Cloud Run service ${serviceId} not found.`); return null; // Or throw a custom error, or handle as needed } throw error; // Re-throw other errors } }
- tools/tools.js:34-34 (registration)Calls registerGetServiceTool to register the 'get_service' tool on the MCP server.registerGetServiceTool(server, options);
- tools/register-tools.js:200-213 (schema)Zod input schema definition for 'get_service' tool parameters: project, region, service.inputSchema: { project: z .string() .describe('Google Cloud project ID containing the service') .default(options.defaultProjectId), region: z .string() .describe('Region where the service is located') .default(options.defaultRegion), service: z .string() .describe('Name of the Cloud Run service') .default(options.defaultServiceName), },