Skip to main content
Glama

gcp_setup

Idempotent

Create, update, or check Google Cloud Platform configuration files for project-specific settings in Hi-GCloud MCP server.

Instructions

설정|초기화|프로필|setup|init|configure - 프로젝트별 GCP 설정 파일(.hi-gcloud.json)을 생성합니다. project_path에 현재 작업 폴더 경로를 지정하세요.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionNo수행할 작업. status: 현재 설정 확인, create: 설정 생성, update: 설정 업데이트status
project_pathNo프로젝트 경로 (현재 작업 폴더 경로를 지정하세요)
project_idNoGCP 프로젝트 ID
regionNo기본 리전 (예: asia-northeast3)
accountNo계정 이메일

Implementation Reference

  • Main handler function for the 'gcp_setup' tool. Dispatches to 'getStatus' or 'saveConfig' based on the 'action' parameter.
    export async function gcpSetup(args: GcpSetupArgs) {
      const action = args.action || 'status';
    
      try {
        switch (action) {
          case 'status':
            return await getStatus(args.project_path);
          case 'create':
          case 'update':
            return await saveConfig(args);
          default:
            return {
              content: [{ type: 'text', text: `알 수 없는 액션: ${action}` }],
              isError: true,
            };
        }
      } catch (error: any) {
        return {
          content: [{ type: 'text', text: `오류: ${error.message}` }],
          isError: true,
        };
      }
    }
  • Tool schema definition including name, description, annotations, and detailed input schema for parameters like action, project_path, project_id, etc.
    export const gcpSetupDefinition = {
      name: 'gcp_setup',
      description: '설정|초기화|프로필|setup|init|configure - 프로젝트별 GCP 설정 파일(.hi-gcloud.json)을 생성합니다. project_path에 현재 작업 폴더 경로를 지정하세요.',
      annotations: {
        title: 'GCP 프로젝트 설정',
        readOnlyHint: false,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: false,
      },
      inputSchema: {
        type: 'object' as const,
        properties: {
          action: {
            type: 'string',
            enum: ['status', 'create', 'update'],
            description: '수행할 작업. status: 현재 설정 확인, create: 설정 생성, update: 설정 업데이트',
            default: 'status',
          },
          project_path: {
            type: 'string',
            description: '프로젝트 경로 (현재 작업 폴더 경로를 지정하세요)',
          },
          project_id: {
            type: 'string',
            description: 'GCP 프로젝트 ID',
          },
          region: {
            type: 'string',
            description: '기본 리전 (예: asia-northeast3)',
          },
          account: {
            type: 'string',
            description: '계정 이메일',
          },
        },
        required: [],
      },
    };
  • src/index.ts:213-214 (registration)
    Registration and dispatch of the 'gcp_setup' tool handler in the main CallToolRequestSchema switch statement.
    case 'gcp_setup':
      return await gcpSetup(args as any) as CallToolResult;
  • Key helper function that saves or updates the .hi-gcloud.json file with GCP project configuration, auto-detects Cloud SQL instances.
    async function saveConfig(args: GcpSetupArgs) {
      if (!args.project_path) {
        return {
          content: [{
            type: 'text',
            text: '❌ project_path가 필요합니다.\n\n예: gcp_setup(action: "create", project_path: "/path/to/project", project_id: "my-project")',
          }],
          isError: true,
        };
      }
    
      // Get current gcloud config as defaults
      let defaultProject = '';
      let defaultRegion = '';
      let defaultAccount = '';
    
      try {
        const projectResult = await executeGcloud('config get-value project', 5000);
        defaultProject = projectResult.stdout.trim();
        if (defaultProject === '(unset)') defaultProject = '';
      } catch {}
    
      try {
        const regionResult = await executeGcloud('config get-value compute/region', 5000);
        defaultRegion = regionResult.stdout.trim();
        // Handle various "unset" responses from gcloud
        if (!defaultRegion || defaultRegion === '(unset)' || defaultRegion === 'unset') {
          defaultRegion = '';
        }
      } catch {
        defaultRegion = '';
      }
    
      try {
        const accountResult = await executeGcloud('auth list --format="value(account)" --filter="status:ACTIVE"', 5000);
        defaultAccount = accountResult.stdout.trim();
      } catch {}
    
      // Auto-detect Cloud SQL instances
      let cloudSqlInstances: CloudSqlInstance[] = [];
      try {
        const projectId = args.project_id || defaultProject;
        if (projectId) {
          const sqlResult = await executeGcloud(`sql instances list --project=${projectId} --format="json"`, 15000);
          const instances = JSON.parse(sqlResult.stdout || '[]');
          cloudSqlInstances = instances.map((inst: any) => ({
            name: inst.name,
            region: inst.region,
            port: inst.databaseVersion?.startsWith('MYSQL') ? 3306 : 5432,
            database: inst.databaseVersion?.startsWith('MYSQL') ? 'mysql' : 'postgres',
          }));
        }
      } catch {}
    
      // Read existing config if updating
      const configPath = join(args.project_path, '.hi-gcloud.json');
      let existingConfig: any = {};
      if (existsSync(configPath)) {
        try {
          const { readFile } = await import('fs/promises');
          const content = await readFile(configPath, 'utf-8');
          existingConfig = JSON.parse(content);
        } catch {}
      }
    
      const newConfig = {
        project_id: args.project_id || existingConfig.project_id || defaultProject,
        region: args.region || existingConfig.region || defaultRegion || undefined,
        account: args.account || existingConfig.account || defaultAccount,
        cloud_sql: args.cloud_sql || existingConfig.cloud_sql || (cloudSqlInstances.length > 0 ? cloudSqlInstances : undefined),
      };
    
      if (!newConfig.project_id) {
        return {
          content: [{
            type: 'text',
            text: '❌ project_id가 필요합니다. gcloud에 설정된 프로젝트가 없으므로 직접 지정해주세요.\n\n예: gcp_setup(action: "create", project_path: "...", project_id: "my-project")',
          }],
          isError: true,
        };
      }
    
      await writeFile(configPath, JSON.stringify(newConfig, null, 2));
    
      const sqlInfo = newConfig.cloud_sql?.length
        ? `\n🗄️ Cloud SQL:\n${newConfig.cloud_sql.map((sql: CloudSqlInstance) => `   - ${sql.name} (${sql.region}, 포트: ${sql.port})`).join('\n')}`
        : '';
    
      return {
        content: [{
          type: 'text',
          text: `✅ ${configPath} 저장됨
    
    📁 프로젝트: ${newConfig.project_id}
    🌍 리전: ${newConfig.region || '(미설정)'}
    👤 계정: ${newConfig.account || '(미설정)'}${sqlInfo}
    
    > ⚠️ .gitignore에 .hi-gcloud.json 추가를 권장합니다.`,
        }],
      };
    }
  • Helper function that retrieves current gcloud CLI configuration and status of project-specific .hi-gcloud.json file.
    async function getStatus(projectPath?: string) {
      // Get current gcloud config
      let currentProject = '';
      let currentRegion = '';
      let currentAccount = '';
    
      try {
        const projectResult = await executeGcloud('config get-value project', 5000);
        currentProject = projectResult.stdout.trim();
        if (currentProject === '(unset)') currentProject = '';
      } catch {}
    
      try {
        const regionResult = await executeGcloud('config get-value compute/region', 5000);
        currentRegion = regionResult.stdout.trim();
        if (currentRegion === '(unset)') currentRegion = '';
      } catch {}
    
      try {
        const accountResult = await executeGcloud('auth list --format="value(account)" --filter="status:ACTIVE"', 5000);
        currentAccount = accountResult.stdout.trim();
      } catch {}
    
      // Check if .hi-gcloud.json exists
      let configExists = false;
      let existingConfig: any = null;
      if (projectPath) {
        const configPath = join(projectPath, '.hi-gcloud.json');
        if (existsSync(configPath)) {
          configExists = true;
          try {
            const { readFile } = await import('fs/promises');
            const content = await readFile(configPath, 'utf-8');
            existingConfig = JSON.parse(content);
          } catch {}
        }
      }
    
      const lines = [
        '📋 GCP 설정 상태',
        '',
        '## gcloud CLI 설정',
        `- 프로젝트: ${currentProject || '(미설정)'}`,
        `- 리전: ${currentRegion || '(미설정)'}`,
        `- 계정: ${currentAccount || '(미설정)'}`,
      ];
    
      if (projectPath) {
        lines.push('', '## 프로젝트 설정 파일');
        if (configExists && existingConfig) {
          lines.push(`✅ ${projectPath}/.hi-gcloud.json 존재`);
          lines.push(`- project_id: ${existingConfig.project_id || '(미설정)'}`);
          lines.push(`- region: ${existingConfig.region || '(미설정)'}`);
          lines.push(`- account: ${existingConfig.account || '(미설정)'}`);
        } else {
          lines.push(`❌ ${projectPath}/.hi-gcloud.json 없음`);
          lines.push('');
          lines.push('💡 설정 생성: gcp_setup(action: "create", project_path: "...")');
        }
      } else {
        lines.push('');
        lines.push('💡 project_path를 지정하면 프로젝트별 설정 파일을 확인할 수 있습니다.');
      }
    
      return {
        content: [{ type: 'text', text: lines.join('\n') }],
      };
    }
Behavior4/5

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

Annotations provide readOnlyHint=false, idempotentHint=true, and destructiveHint=false, indicating this is a non-destructive, idempotent write operation. The description adds value by specifying the output file format (.hi-gcloud.json) and the project-specific nature, which aren't covered by annotations. No contradiction with annotations exists.

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

Conciseness4/5

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

The description is concise and front-loaded, starting with key synonyms and the core action. It uses two sentences efficiently, with no wasted words. However, the mix of Korean and English terms slightly reduces clarity, and it could better integrate the multiple actions from the schema.

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 5 parameters, no output schema, and annotations covering safety/idempotency, the description adequately explains the core purpose and file output. However, it lacks details on the multi-action behavior (status/create/update), error conditions, or how it interacts with sibling tools, leaving some gaps for an AI agent.

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 description coverage is 100%, with all parameters well-documented in the schema itself. The description mentions only 'project_path' and implies configuration actions, adding minimal semantic context beyond the schema. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't significantly enhance parameter understanding.

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 creates GCP configuration files (.hi-gcloud.json) per project, using specific verbs like '생성합니다' (creates). It distinguishes from siblings by focusing on setup/configuration rather than auth, billing, logs, or other operations. However, it doesn't explicitly mention the multiple actions (status/create/update) revealed in the schema.

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

Usage Guidelines3/5

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

The description provides some context by listing synonyms (설정|초기화|프로필|setup|init|configure) and specifying to use 'project_path' for the current working folder. However, it doesn't explicitly state when to use this tool versus alternatives like gcp_auth_status or gcp_services_list, nor does it provide exclusions or prerequisites for usage.

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