gcp_auth_status
Check Google Cloud Platform authentication status and account information to verify login credentials and active sessions.
Instructions
인증 상태|로그인 확인|계정 정보|auth status|whoami - GCP 인증 상태와 계정 정보를 확인합니다
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| show_all_accounts | No | 모든 인증된 계정 표시 (기본: false) | |
| format | No | 출력 형식 (기본: text) | text |
Implementation Reference
- src/gcp/auth.ts:38-131 (handler)The core handler function for the 'gcp_auth_status' tool. It checks GCP authentication using checkGcloudAuth, fetches config and accounts if needed, and returns formatted output in text or JSON.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, }; } }
- src/gcp/auth.ts:4-36 (schema)Tool schema definition including name, description, annotations, and input schema for parameters show_all_accounts and format. Also defines the TypeScript interface for function arguments.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: [], }, }; interface GcpAuthStatusArgs { show_all_accounts?: boolean; format?: 'text' | 'json'; }
- src/index.ts:77-89 (registration)Adds gcpAuthStatusDefinition to the tools array returned by ListToolsRequestHandler, registering the tool with the MCP server.const tools = [ gcpSetupDefinition, gcpLogsReadDefinition, gcpRunStatusDefinition, gcpRunLogsDefinition, gcpSqlQueryDefinition, gcpSqlProxyDefinition, gcpStorageListDefinition, gcpSecretListDefinition, gcpAuthStatusDefinition, gcpServicesListDefinition, gcpBillingInfoDefinition, ];
- src/index.ts:227-228 (registration)In the CallToolRequestHandler switch statement, dispatches calls to the gcp_auth_status tool by invoking the gcpAuthStatus handler function.case 'gcp_auth_status': return await gcpAuthStatus(args as any) as CallToolResult;