Skip to main content
Glama

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(...) }' ),

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