get-function
Retrieve details and code for a specific edge function using its slug identifier. This tool helps developers access function information from the Insforge backend platform.
Instructions
Get details of a specific edge function including its code
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | Yes | The slug identifier of the function |
Implementation Reference
- src/shared/tools.ts:874-912 (registration)Full registration of the 'get-function' MCP tool, including description, Zod input schema, and handler wrapped with usage tracking.server.tool( 'get-function', 'Get details of a specific edge function including its code', { slug: z.string().describe('The slug identifier of the function'), }, withUsageTracking('get-function', async (args) => { try { const response = await fetch(`${API_BASE_URL}/api/functions/${args.slug}`, { method: 'GET', headers: { 'x-api-key': getApiKey(), }, }); const result = await handleApiResponse(response); return await addBackgroundContext({ content: [ { type: 'text', text: formatSuccessMessage(`Edge function '${args.slug}' details`, result), }, ], }); } catch (error) { const errMsg = error instanceof Error ? error.message : 'Unknown error occurred'; return { content: [ { type: 'text', text: `Error getting function: ${errMsg}`, }, ], isError: true, }; } }) );
- src/shared/tools.ts:880-911 (handler)Core handler logic for 'get-function': performs authenticated GET request to backend API /api/functions/{slug}, processes with handleApiResponse, adds context, formats output, and handles errors.withUsageTracking('get-function', async (args) => { try { const response = await fetch(`${API_BASE_URL}/api/functions/${args.slug}`, { method: 'GET', headers: { 'x-api-key': getApiKey(), }, }); const result = await handleApiResponse(response); return await addBackgroundContext({ content: [ { type: 'text', text: formatSuccessMessage(`Edge function '${args.slug}' details`, result), }, ], }); } catch (error) { const errMsg = error instanceof Error ? error.message : 'Unknown error occurred'; return { content: [ { type: 'text', text: `Error getting function: ${errMsg}`, }, ], isError: true, }; } })
- src/shared/tools.ts:877-879 (schema)Zod input schema for 'get-function' tool requiring a 'slug' parameter.{ slug: z.string().describe('The slug identifier of the function'), },
- src/shared/tools.ts:175-189 (helper)Helper wrapper 'withUsageTracking' used by 'get-function' handler to track tool usage success/failure.function withUsageTracking<T extends unknown[], R>( toolName: string, handler: (...args: T) => Promise<R> ): (...args: T) => Promise<R> { return async (...args: T): Promise<R> => { try { const result = await handler(...args); await trackToolUsage(toolName, true); return result; } catch (error) { await trackToolUsage(toolName, false); throw error; } }; }