Skip to main content
Glama

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
NameRequiredDescriptionDefault
slugYesThe slug identifier of the function

Implementation Reference

  • 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, }; } })
  • 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'), },
  • 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, }; } }) );
  • 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; } }; }

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