Skip to main content
Glama

list_services

Retrieve a list of Google Cloud Run services within a specified project and region using the MCP Server. Simplify service monitoring and management with accurate, region-specific details.

Instructions

Lists Cloud Run services in a given project and region.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectYesGoogle Cloud project ID
regionNoRegion where the services are locatedeurope-west1

Implementation Reference

  • The core handler function executed when the 'list_services' tool is called. It validates the project input, fetches services using listServices helper, formats output by region with service names and URLs, and returns structured content or error.
    gcpTool(options.gcpCredentialsAvailable, async ({ project }) => {
      if (typeof project !== 'string') {
        return {
          content: [
            {
              type: 'text',
              text: 'Error: Project ID must be provided and be a non-empty string.',
            },
          ],
        };
      }
      try {
        const allServices = await listServices(project);
        const content = [];
        for (const region of Object.keys(allServices)) {
          const serviceList = allServices[region];
          const servicesText = serviceList
            .map((s) => {
              const serviceName = s.name.split('/').pop();
              return `- ${serviceName} (URL: ${s.uri})`;
            })
            .join('\n');
          content.push({
            type: 'text',
            text: `Services in project ${project} (location ${region}):\n${servicesText}`,
          });
        }
        return { content };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error listing services for project ${project}: ${error.message}`,
            },
          ],
        };
      }
    })
  • Input schema definition for the 'list_services' tool using Zod, specifying the optional 'project' parameter with description and default value.
    {
      description: 'Lists all Cloud Run services in a given project.',
      inputSchema: {
        project: z
          .string()
          .describe('Google Cloud project ID')
          .default(options.defaultProjectId),
      },
    },
  • tools/tools.js:33-33 (registration)
    Invocation of registerListServicesTool during main tool registration in the application setup.
    registerListServicesTool(server, options);
  • Helper function listServices that initializes clients, ensures API enabled, lists Cloud Run locations, and fetches services from each location using Google Cloud Run API, returning object keyed by region.
    export async function listServices(projectId) {
      if (!runClient) {
        const { v2 } = await import('@google-cloud/run');
        const { ServicesClient } = v2;
        const { ServiceUsageClient } = await import('@google-cloud/service-usage');
        runClient = new ServicesClient({ projectId });
        serviceUsageClient = new ServiceUsageClient({ projectId });
      }
      const context = {
        runClient: runClient,
        serviceUsageClient: serviceUsageClient,
      };
      await ensureApisEnabled(context, projectId, ['run.googleapis.com']);
      const locations = await listCloudRunLocations(projectId);
    
      const allServices = {};
      for (const location of locations) {
        const parent = runClient.locationPath(projectId, location);
    
        try {
          console.log(
            `Listing Cloud Run services in project ${projectId}, location ${location}...`
          );
          const [services] = await callWithRetry(
            () => runClient.listServices({ parent }),
            'listServices'
          );
          allServices[location] = services;
        } catch (error) {
          console.error(`Error listing Cloud Run services:`, error);
          throw error;
        }
      }
      return allServices;
    }
  • The registration function registerListServicesTool that defines and registers the 'list_services' tool on the MCP server, including name, schema, and wrapped handler.
    function registerListServicesTool(server, options) {
      server.registerTool(
        'list_services',
        {
          description: 'Lists all Cloud Run services in a given project.',
          inputSchema: {
            project: z
              .string()
              .describe('Google Cloud project ID')
              .default(options.defaultProjectId),
          },
        },
        gcpTool(options.gcpCredentialsAvailable, async ({ project }) => {
          if (typeof project !== 'string') {
            return {
              content: [
                {
                  type: 'text',
                  text: 'Error: Project ID must be provided and be a non-empty string.',
                },
              ],
            };
          }
          try {
            const allServices = await listServices(project);
            const content = [];
            for (const region of Object.keys(allServices)) {
              const serviceList = allServices[region];
              const servicesText = serviceList
                .map((s) => {
                  const serviceName = s.name.split('/').pop();
                  return `- ${serviceName} (URL: ${s.uri})`;
                })
                .join('\n');
              content.push({
                type: 'text',
                text: `Services in project ${project} (location ${region}):\n${servicesText}`,
              });
            }
            return { content };
          } catch (error) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Error listing services for project ${project}: ${error.message}`,
                },
              ],
            };
          }
        })
      );
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states it's a list operation but doesn't mention whether it's paginated, what format the results are in, whether authentication is required, or any rate limits. For a cloud service listing tool, this leaves significant behavioral questions unanswered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core functionality and appropriately sized for a straightforward listing tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations, no output schema, and incomplete behavioral disclosure, the description is insufficient. It doesn't help the agent understand what the tool returns, how to interpret results, or important operational constraints. The description should provide more context given the lack of structured metadata.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description mentions 'project and region' parameters but adds no semantic context beyond what's already in the schema (which has 100% coverage with clear descriptions). The description doesn't explain why these parameters matter or how they affect the listing operation, so it meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Lists') and resource ('Cloud Run services') with scope ('in a given project and region'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_projects' or 'get_service', which would be needed for a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'list_projects' or 'get_service'. There's no mention of prerequisites, typical use cases, or exclusions, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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