Skip to main content
Glama

gcp_logs_read

Read-onlyIdempotent

Query and analyze logs from Google Cloud Platform's Cloud Logging service to monitor errors, track resource activity, and troubleshoot issues across GCP projects.

Instructions

로그 조회|에러 확인|Cloud Logging|gcp logs|에러 로그 - GCP Cloud Logging에서 로그를 조회합니다

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNo로그 필터 (예: "severity=ERROR", "resource.type=cloud_run_revision")
project_idNoGCP 프로젝트 ID (기본: 현재 설정된 프로젝트)
time_rangeNo시간 범위 (예: "1h", "6h", "24h", "7d"). 기본: "1h"1h
limitNo최대 로그 수 (기본: 50, 최대: 500)
formatNo출력 형식 (기본: text)text

Implementation Reference

  • The async handler function that implements the core logic for the gcp_logs_read tool. It constructs a filter based on args, executes 'gcloud logging read' command, parses logs, formats them, and returns structured content with error reports.
    export async function gcpLogsRead(args: GcpLogsReadArgs) {
      try {
        const projectId = await getProjectId(args.project_id);
        const timeRange = args.time_range || '1h';
        const limit = Math.min(args.limit || 50, 500);
        const timestamp = parseTimeRange(timeRange);
    
        // Build filter
        let filter = `timestamp>="${timestamp}"`;
        if (args.filter) {
          filter += ` AND ${args.filter}`;
        }
    
        // Execute gcloud logging read
        const command = `logging read '${filter}' --project=${projectId} --limit=${limit} --format=json`;
        const result = await executeGcloud(command, 60000);
    
        // Parse JSON output
        let logs: any[] = [];
        try {
          logs = JSON.parse(result.stdout || '[]');
        } catch {
          logs = [];
        }
    
        // Transform to LogEntry format
        const logEntries: LogEntry[] = logs.map((log: any) => ({
          timestamp: log.timestamp || log.receiveTimestamp || '',
          severity: log.severity || 'DEFAULT',
          message: log.textPayload || log.jsonPayload?.message || JSON.stringify(log.jsonPayload || {}),
          resource: log.resource?.type,
          labels: log.labels,
        }));
    
        // Create error report for hi-ai integration
        const errorReport = createErrorReport(logEntries);
    
        if (args.format === 'json') {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({
                  project: projectId,
                  timeRange,
                  totalLogs: logEntries.length,
                  ...errorReport,
                  logs: logEntries,
                }, null, 2),
              },
            ],
          };
        }
    
        // Format text output
        const header = `📋 Cloud Logging 조회 결과\n프로젝트: ${projectId}\n시간 범위: ${timeRange}\n총 ${logEntries.length}개 로그\n`;
        const formattedLogs = formatLogEntries(logEntries);
    
        // 에러가 있으면 상세 리포트 (hi-ai 힌트 포함), 없으면 기본 요약
        const reportSection = errorReport.hasErrors
          ? createDetailedErrorReport(logEntries)
          : errorReport.summary;
    
        return {
          content: [
            {
              type: 'text',
              text: `${header}\n${reportSection}\n\n${formattedLogs}`,
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text',
              text: formatError(error),
            },
          ],
          isError: true,
        };
      }
    }
  • The tool definition object for gcp_logs_read, including name, description, annotations, and detailed inputSchema for parameters like filter, project_id, time_range, limit, and format.
    export const gcpLogsReadDefinition = {
      name: 'gcp_logs_read',
      description: '로그 조회|에러 확인|Cloud Logging|gcp logs|에러 로그 - GCP Cloud Logging에서 로그를 조회합니다',
      annotations: {
        title: 'GCP 로그 조회',
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: true,
      },
      inputSchema: {
        type: 'object' as const,
        properties: {
          filter: {
            type: 'string',
            description: '로그 필터 (예: "severity=ERROR", "resource.type=cloud_run_revision")',
          },
          project_id: {
            type: 'string',
            description: 'GCP 프로젝트 ID (기본: 현재 설정된 프로젝트)',
          },
          time_range: {
            type: 'string',
            description: '시간 범위 (예: "1h", "6h", "24h", "7d"). 기본: "1h"',
            default: '1h',
          },
          limit: {
            type: 'number',
            description: '최대 로그 수 (기본: 50, 최대: 500)',
            default: 50,
          },
          format: {
            type: 'string',
            enum: ['text', 'json'],
            description: '출력 형식 (기본: text)',
            default: 'text',
          },
        },
        required: [],
      },
    };
  • TypeScript interface defining the input arguments for the gcpLogsRead handler, matching the inputSchema.
    interface GcpLogsReadArgs {
      filter?: string;
      project_id?: string;
      time_range?: string;
      limit?: number;
      format?: 'text' | 'json';
    }
  • src/index.ts:77-89 (registration)
    The tools array where gcpLogsReadDefinition is registered among other tool definitions, provided to the MCP server's ListToolsRequest handler.
    const tools = [
      gcpSetupDefinition,
      gcpLogsReadDefinition,
      gcpRunStatusDefinition,
      gcpRunLogsDefinition,
      gcpSqlQueryDefinition,
      gcpSqlProxyDefinition,
      gcpStorageListDefinition,
      gcpSecretListDefinition,
      gcpAuthStatusDefinition,
      gcpServicesListDefinition,
      gcpBillingInfoDefinition,
    ];
  • src/index.ts:215-216 (registration)
    The switch case in the CallToolRequestSchema handler that routes calls to the gcp_logs_read tool to the gcpLogsRead function.
    case 'gcp_logs_read':
      return await gcpLogsRead(args as any) as CallToolResult;
Behavior3/5

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

Annotations already provide excellent behavioral information (readOnlyHint: true, openWorldHint: true, idempotentHint: true, destructiveHint: false). The description adds minimal behavioral context beyond this - it mentions '에러 확인' (error checking) as a use case, but doesn't provide additional behavioral details like rate limits, authentication requirements, or what happens with large result sets. 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.

Conciseness2/5

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

The description is poorly structured with pipe-separated keywords followed by the main description. This creates redundancy and confusion rather than clarity. While brief, the mixed Korean/English format and keyword spam at the beginning undermine effective communication. The core description sentence is clear but the overall structure is suboptimal.

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 rich annotations (covering safety, idempotency, and world openness) and comprehensive parameter documentation in the schema, the description provides adequate but minimal context. However, without an output schema, the description doesn't explain what format the logs will be returned in or what the response structure looks like. For a log retrieval tool, this is a moderate gap in completeness.

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?

With 100% schema description coverage, the input schema already fully documents all 5 parameters with clear descriptions and defaults. The description adds no parameter information beyond what's in the schema. The baseline score of 3 is appropriate when the schema does all the parameter documentation work.

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's purpose: 'GCP Cloud Logging에서 로그를 조회합니다' (retrieves logs from GCP Cloud Logging). It specifies the verb (조회/retrieve) and resource (로그/logs), but doesn't explicitly differentiate from sibling tools like 'gcp_run_logs' which might be more specific. The Korean/English mixed format is somewhat confusing but the core purpose is clear.

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. It doesn't mention sibling tools like 'gcp_run_logs' (which appears to be a more specific log tool) or explain the broader scope of this tool compared to more specialized ones. The pipe-separated keywords at the beginning ('로그 조회|에러 확인|Cloud Logging|gcp logs|에러 로그') suggest use cases but don't provide explicit when/when-not guidance.

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