get-function
Retrieve detailed information and code for specific edge functions using their slug identifier to inspect implementation and configuration.
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:883-914 (handler)Handler function for the 'get-function' MCP tool. Fetches details of a specific edge function (including code) from the backend API endpoint /api/functions/{slug}, handles the response, adds background context, and formats the output.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-882 (schema)Input schema validation for 'get-function' tool using Zod: requires a 'slug' string parameter identifying the edge function.{ slug: z.string().describe('The slug identifier of the function'), },
- src/shared/tools.ts:877-915 (registration)Registration of the 'get-function' tool on the MCP server via server.tool(), including name, description, input schema, and handler function.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:174-188 (helper)Helper wrapper 'withUsageTracking' applied to the 'get-function' handler for automatic usage tracking and error handling.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; } }; }