Skip to main content
Glama

update-function

Modify existing edge function code or metadata to update functionality, change status between draft and active, or revise descriptions and names.

Instructions

Update an existing edge function code or metadata

Input Schema

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

Implementation Reference

  • Core handler logic for updating an edge function. Reads optional code from file, builds update payload with name, description, status, code, performs PUT request to /api/functions/{slug}, handles response and errors.
    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, }; } })
  • Input schema using Zod: required 'slug', fields from external 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(...) }' ), },
  • MCP server.tool registration defining the tool name, description, input schema, and wrapped 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, }; } }) );

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