Skip to main content
Glama

get-container-logs

Retrieve container logs to debug application issues by fetching recent entries from specified sources like insforge.logs or postgres.logs.

Instructions

Get latest logs from a specific container/service. Use this to help debug problems with your app.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiKeyNoAPI key for authentication (optional if provided via --api_key)
sourceYesLog source to retrieve
limitNoNumber of logs to return (default: 20)

Implementation Reference

  • The handler function wrapped in withUsageTracking that fetches logs from the primary API endpoint `/api/logs/{source}` with a fallback to the legacy `/api/logs/analytics/{source}` endpoint if 404. Formats the response and adds background context.
    withUsageTracking('get-container-logs', async ({ apiKey, source, limit }) => { try { const actualApiKey = getApiKey(apiKey); const queryParams = new URLSearchParams(); if (limit) queryParams.append('limit', limit.toString()); let response = await fetch(`${API_BASE_URL}/api/logs/${source}?${queryParams}`, { method: 'GET', headers: { 'x-api-key': actualApiKey, }, }); // Fallback to legacy endpoint if 404 if (response.status === 404) { response = await fetch(`${API_BASE_URL}/api/logs/analytics/${source}?${queryParams}`, { method: 'GET', headers: { 'x-api-key': actualApiKey, }, }); } const result = await handleApiResponse(response); return await addBackgroundContext({ content: [ { type: 'text', text: formatSuccessMessage(`Latest logs from ${source}`, result), }, ], }); } catch (error) { const errMsg = error instanceof Error ? error.message : 'Unknown error occurred'; return { content: [ { type: 'text', text: `Error retrieving container logs: ${errMsg}`, }, ], isError: true, }; } })
  • Zod schema defining the input parameters: optional apiKey, required source (enum of log types), optional limit (default 20).
    { apiKey: z .string() .optional() .describe('API key for authentication (optional if provided via --api_key)'), source: z.enum(['insforge.logs', 'postgREST.logs', 'postgres.logs', 'function.logs']).describe('Log source to retrieve'), limit: z.number().optional().default(20).describe('Number of logs to return (default: 20)'), },
  • The MCP server.tool registration that defines the tool name 'get-container-logs', description, input schema, and references the handler function.
    server.tool( 'get-container-logs', 'Get latest logs from a specific container/service. Use this to help debug problems with your app.', { apiKey: z .string() .optional() .describe('API key for authentication (optional if provided via --api_key)'), source: z.enum(['insforge.logs', 'postgREST.logs', 'postgres.logs', 'function.logs']).describe('Log source to retrieve'), limit: z.number().optional().default(20).describe('Number of logs to return (default: 20)'), }, withUsageTracking('get-container-logs', async ({ apiKey, source, limit }) => { try { const actualApiKey = getApiKey(apiKey); const queryParams = new URLSearchParams(); if (limit) queryParams.append('limit', limit.toString()); let response = await fetch(`${API_BASE_URL}/api/logs/${source}?${queryParams}`, { method: 'GET', headers: { 'x-api-key': actualApiKey, }, }); // Fallback to legacy endpoint if 404 if (response.status === 404) { response = await fetch(`${API_BASE_URL}/api/logs/analytics/${source}?${queryParams}`, { method: 'GET', headers: { 'x-api-key': actualApiKey, }, }); } const result = await handleApiResponse(response); return await addBackgroundContext({ content: [ { type: 'text', text: formatSuccessMessage(`Latest logs from ${source}`, result), }, ], }); } catch (error) { const errMsg = error instanceof Error ? error.message : 'Unknown error occurred'; return { content: [ { type: 'text', text: `Error retrieving container logs: ${errMsg}`, }, ], isError: true, }; } }) );

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/InsForge/insforge-mcp'

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