Skip to main content
Glama
InsForge

Insforge MCP Server

update-function

Modify an existing edge function's code or metadata in the Insforge MCP Server to adjust its behavior or configuration.

Instructions

Update an existing edge function code or metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
slugYesThe slug identifier of the function to update
nameNo
descriptionNo
statusNo
codeFileNoPath to JavaScript file containing the new function code. Must export: module.exports = async function(request) { return new Response(...) }

Implementation Reference

  • Core handler logic for the 'update-function' tool. Constructs update payload from args (including optional code file read), sends PUT request to backend API /api/functions/{slug}, handles response with success/error formatting and background context addition.
    withUsageTracking('update-function', async (args) => {
      try {
        const updateData: FunctionUpdateRequest = {};
        if (args.name) {
          updateData.name = args.name;
        }
    
        if (args.codeFile) {
          try {
            updateData.code = await fs.readFile(args.codeFile, 'utf-8');
          } catch (fileError) {
            throw new Error(
              `Failed to read code file '${args.codeFile}': ${fileError instanceof Error ? fileError.message : 'Unknown error'}`
            );
          }
        }
    
        if (args.description !== undefined) {
          updateData.description = args.description;
        }
        if (args.status) {
          updateData.status = args.status;
        }
    
        const response = await fetch(`${API_BASE_URL}/api/functions/${args.slug}`, {
          method: 'PUT',
          headers: {
            'Content-Type': 'application/json',
            'x-api-key': getApiKey(),
          },
          body: JSON.stringify(updateData),
        });
    
        const result = await handleApiResponse(response);
    
        const fileInfo = args.codeFile ? ` from ${args.codeFile}` : '';
    
        return await addBackgroundContext({
          content: [
            {
              type: 'text',
              text: formatSuccessMessage(
                `Edge function '${args.slug}' updated successfully${fileInfo}`,
                result
              ),
            },
          ],
        });
      } catch (error) {
        const errMsg = error instanceof Error ? error.message : 'Unknown error occurred';
        return {
          content: [
            {
              type: 'text',
              text: `Error updating function: ${errMsg}`,
            },
          ],
          isError: true,
        };
      }
    })
  • MCP server tool registration for 'update-function', defining name, description, input parameters schema, and handler function.
    server.tool(
      'update-function',
      'Update an existing edge function code or metadata',
      {
        slug: z.string().describe('The slug identifier of the function to update'),
        ...functionUpdateRequestSchema.omit({ code: true }).shape,
        codeFile: z
          .string()
          .optional()
          .describe(
            'Path to JavaScript file containing the new function code. Must export: module.exports = async function(request) { return new Response(...) }'
          ),
      },
      withUsageTracking('update-function', async (args) => {
        try {
          const updateData: FunctionUpdateRequest = {};
          if (args.name) {
            updateData.name = args.name;
          }
    
          if (args.codeFile) {
            try {
              updateData.code = await fs.readFile(args.codeFile, 'utf-8');
            } catch (fileError) {
              throw new Error(
                `Failed to read code file '${args.codeFile}': ${fileError instanceof Error ? fileError.message : 'Unknown error'}`
              );
            }
          }
    
          if (args.description !== undefined) {
            updateData.description = args.description;
          }
          if (args.status) {
            updateData.status = args.status;
          }
    
          const response = await fetch(`${API_BASE_URL}/api/functions/${args.slug}`, {
            method: 'PUT',
            headers: {
              'Content-Type': 'application/json',
              'x-api-key': getApiKey(),
            },
            body: JSON.stringify(updateData),
          });
    
          const result = await handleApiResponse(response);
    
          const fileInfo = args.codeFile ? ` from ${args.codeFile}` : '';
    
          return await addBackgroundContext({
            content: [
              {
                type: 'text',
                text: formatSuccessMessage(
                  `Edge function '${args.slug}' updated successfully${fileInfo}`,
                  result
                ),
              },
            ],
          });
        } catch (error) {
          const errMsg = error instanceof Error ? error.message : 'Unknown error occurred';
          return {
            content: [
              {
                type: 'text',
                text: `Error updating function: ${errMsg}`,
              },
            ],
            isError: true,
          };
        }
      })
    );
  • Zod input schema validation for the tool parameters: required slug, fields from imported functionUpdateRequestSchema (excluding code), optional codeFile path.
    {
      slug: z.string().describe('The slug identifier of the function to update'),
      ...functionUpdateRequestSchema.omit({ code: true }).shape,
      codeFile: z
        .string()
        .optional()
        .describe(
          'Path to JavaScript file containing the new function code. Must export: module.exports = async function(request) { return new Response(...) }'
        ),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden but only states it updates code or metadata. It doesn't disclose permission requirements, whether updates are reversible, rate limits, or what happens to unspecified fields. 'Update' implies mutation but lacks behavioral details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with core purpose, zero wasted words. Efficiently communicates the essential action without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with 5 parameters, 40% schema coverage, no annotations, and no output schema, the description is inadequate. It doesn't explain return values, error handling, or provide enough context for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 40% (only 'slug' and 'codeFile' have descriptions). The description adds no parameter-specific information beyond implying 'code' and 'metadata' updates, which partially maps to parameters but doesn't explain 'name', 'description', or 'status' semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('update') and target ('existing edge function'), specifying both code and metadata. It distinguishes from 'create-function' by focusing on existing functions, though it doesn't explicitly contrast with 'get-function' or other siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'create-function' or 'get-function'. The description implies it's for existing functions but doesn't specify prerequisites, error conditions, or contextual recommendations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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