Skip to main content
Glama

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
NameRequiredDescriptionDefault
projectYesGoogle Cloud project ID containing the service
regionNoRegion where the service is locatedeurope-west1
serviceYesName of the Cloud Run service

Implementation Reference

  • 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}`,
                  },
                ],
              };
            }
          }
        )
      );
    }
  • 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);
  • 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),
    },
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/GoogleCloudPlatform/cloud-run-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server