Skip to main content
Glama

gcp_auth_status

Read-onlyIdempotent

Verify your GCP authentication status and view active account details. Optionally list all authenticated accounts in text or JSON format.

Instructions

인증 상태|로그인 확인|계정 정보|auth status|whoami - GCP 인증 상태와 계정 정보를 확인합니다

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
show_all_accountsNo모든 인증된 계정 표시 (기본: false)
formatNo출력 형식 (기본: text)text

Implementation Reference

  • The main handler function that checks GCP auth status. Calls checkGcloudAuth() to verify authentication, then fetches config and optionally all accounts. Returns formatted output in text or JSON format with details about active account, project, region, zone.
    export async function gcpAuthStatus(args: GcpAuthStatusArgs) {
      try {
        const authStatus = await checkGcloudAuth();
    
        if (!authStatus.authenticated) {
          return {
            content: [
              {
                type: 'text',
                text: formatError(authStatus.error),
              },
            ],
            isError: true,
          };
        }
    
        // Get additional configuration
        const configResult = await executeGcloud('config list --format=json', 10000);
        let config: any = {};
        try {
          config = JSON.parse(configResult.stdout || '{}');
        } catch {
          config = {};
        }
    
        // Get all accounts if requested
        let allAccounts: string[] = [];
        if (args.show_all_accounts) {
          try {
            const accountsResult = await executeGcloud('auth list --format="value(account)"', 10000);
            allAccounts = accountsResult.stdout.trim().split('\n').filter(Boolean);
          } catch {
            // Ignore errors
          }
        }
    
        const result = {
          authenticated: true,
          activeAccount: authStatus.account,
          project: authStatus.project,
          region: config.compute?.region || 'not set',
          zone: config.compute?.zone || 'not set',
          allAccounts: args.show_all_accounts ? allAccounts : undefined,
        };
    
        if (args.format === 'json') {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(result, null, 2),
              },
            ],
          };
        }
    
        const lines = [
          '🔑 GCP 인증 상태',
          '',
          `✅ 인증됨`,
          `👤 계정: ${result.activeAccount}`,
          `📁 프로젝트: ${result.project || '(설정 안됨)'}`,
          `🌍 리전: ${result.region}`,
          `📍 존: ${result.zone}`,
        ];
    
        if (args.show_all_accounts && allAccounts.length > 1) {
          lines.push('', '📋 모든 인증된 계정:');
          allAccounts.forEach((account) => {
            const isActive = account === result.activeAccount;
            lines.push(`  ${isActive ? '→' : ' '} ${account}${isActive ? ' (활성)' : ''}`);
          });
        }
    
        return {
          content: [
            {
              type: 'text',
              text: lines.join('\n'),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text',
              text: formatError(error),
            },
          ],
          isError: true,
        };
      }
    }
  • The tool definition/input schema for 'gcp_auth_status'. Includes name, description, annotations (readOnly, idempotent), and inputSchema with optional 'show_all_accounts' (boolean) and 'format' (text/json) parameters.
    export const gcpAuthStatusDefinition = {
      name: 'gcp_auth_status',
      description: '인증 상태|로그인 확인|계정 정보|auth status|whoami - GCP 인증 상태와 계정 정보를 확인합니다',
      annotations: {
        title: 'GCP 인증 상태 확인',
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: true,
      },
      inputSchema: {
        type: 'object' as const,
        properties: {
          show_all_accounts: {
            type: 'boolean',
            description: '모든 인증된 계정 표시 (기본: false)',
            default: false,
          },
          format: {
            type: 'string',
            enum: ['text', 'json'],
            description: '출력 형식 (기본: text)',
            default: 'text',
          },
        },
        required: [],
      },
    };
  • TypeScript interface GcpAuthStatusArgs defining the shape of input arguments (show_all_accounts?: boolean, format?: 'text' | 'json').
    interface GcpAuthStatusArgs {
      show_all_accounts?: boolean;
      format?: 'text' | 'json';
    }
  • src/index.ts:86-89 (registration)
    Registration of gcpAuthStatusDefinition in the tools array (line 86) and import from './gcp/auth.js' (line 25). Also the switch-case handler at lines 227-228 dispatches calls to gcp_auth_status.
      gcpAuthStatusDefinition,
      gcpServicesListDefinition,
      gcpBillingInfoDefinition,
    ];
  • Helper function checkGcloudAuth() that checks if gcloud is installed and authenticated. Runs 'gcloud auth list' to get active account and 'gcloud config get-value project' to get the current project.
    export async function checkGcloudAuth(): Promise<{ authenticated: boolean; project?: string; account?: string; error?: GcloudError }> {
      const gcloudPath = await findGcloudPath();
    
      if (!gcloudPath) {
        return {
          authenticated: false,
          error: {
            type: 'NOT_INSTALLED',
            message: 'gcloud CLI가 설치되지 않았습니다.',
            suggestion: 'https://cloud.google.com/sdk/docs/install 에서 Google Cloud SDK를 설치해주세요.',
          },
        };
      }
    
      try {
        // Check authentication status
        const authResult = await execAsync(`${gcloudPath} auth list --format="value(account)" --filter="status:ACTIVE"`, { timeout: 10000 });
        const account = authResult.stdout.trim();
    
        if (!account) {
          return {
            authenticated: false,
            error: {
              type: 'NOT_AUTHENTICATED',
              message: 'GCP 인증이 필요합니다.',
              suggestion: '`gcloud auth login` 명령어를 실행해주세요.',
            },
          };
        }
    
        // Get current project
        const projectResult = await execAsync(`${gcloudPath} config get-value project`, { timeout: 5000 });
        const project = projectResult.stdout.trim();
    
        return {
          authenticated: true,
          account,
          project: project || undefined,
        };
      } catch (error: any) {
        return {
          authenticated: false,
          error: parseGcloudError(error.message || ''),
        };
      }
    }
Behavior3/5

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

Annotations already indicate readOnlyHint=true, destructiveHint=false, idempotentHint=true, openWorldHint=true, which cover safety clearly. The description adds that it checks 'auth status' and 'account info', which is consistent but does not disclose additional behavioral details like side effects or required permissions.

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

Conciseness3/5

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

The description is short but includes repetitive synonyms (e.g., auth status mentioned twice) and mixes languages, which adds noise. It is not structured or front-loaded in an optimal way, but it is functional.

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

Completeness3/5

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

Given the tool has two optional parameters and no output schema, the description is minimally complete. It covers the core purpose but does not explain return values or when to use specific parameters. For a simple tool, it suffices, but lacks detail.

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?

Schema coverage is 100% with clear descriptions for both parameters (show_all_accounts, format). The description does not add any extra meaning or details beyond the schema, so baseline 3 is appropriate.

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 tool checks GCP authentication status and account info, using both Korean and English terms. It distinguishes itself from sibling tools like billing or logs by focusing on auth status. However, the multi-term format with pipes is somewhat messy.

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, nor does it mention any context or prerequisites. An agent would not know if this is the right tool for specific auth-related tasks.

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

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/su-record/hi-gcloud'

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