Skip to main content
Glama

get-logs

Retrieve Cloud Logging entries for your current GCP project using filters and pagination to monitor and debug applications.

Instructions

Get Cloud Logging entries for the current project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNoFilter for the log entries (see Cloud Logging query syntax)
pageSizeNoMaximum number of entries to return (default: 10)

Implementation Reference

  • Main handler for the 'get-logs' tool. Parses input arguments using Zod schema, checks if a project is selected, initializes the Google Cloud Logging client, retrieves log entries with optional filter and page size, formats the response, and handles errors.
    } else if (name === "get-logs") { const { filter, pageSize = 10 } = GetLogsSchema.parse(args); if (!selectedProject) { return createTextResponse("No project selected. Please select a project first."); } try { const logging = new Logging({ projectId: selectedProject }); const [entries] = await logging.getEntries({ pageSize, filter: filter || undefined, orderBy: 'timestamp desc' }); return createTextResponse(JSON.stringify({ entries: entries.map((entry: Entry) => ({ timestamp: entry.metadata.timestamp, severity: entry.metadata.severity, resource: entry.metadata.resource, textPayload: entry.data, jsonPayload: typeof entry.data === 'object' ? entry.data : null })) }, null, 2)); } catch (error: any) { console.error('Error getting logs:', error); return createTextResponse(`Error getting logs: ${error.message}`); }
  • index.ts:194-211 (registration)
    Registration of the 'get-logs' tool in the listTools response, defining its name, description, and input schema.
    { name: "get-logs", description: "Get Cloud Logging entries for the current project", inputSchema: { type: "object", properties: { filter: { type: "string", description: "Filter for the log entries (see Cloud Logging query syntax)", }, pageSize: { type: "number", description: "Maximum number of entries to return (default: 10)", } }, required: [], }, }
  • Zod schema used for input validation of the 'get-logs' tool arguments in the handler.
    const GetLogsSchema = z.object({ filter: z.string().optional(), pageSize: z.number().optional(), });

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/RadiumGu/gcp-ops-mcp'

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