Skip to main content
Glama
InsForge

Insforge MCP Server

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

Implementation Reference

  • 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,
          };
        }
      })
    );
  • 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,
        };
      }
    })
  • Zod input schema for 'get-function' tool requiring a 'slug' parameter.
    {
      slug: z.string().describe('The slug identifier of the function'),
    },
  • 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;
        }
      };
    }

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