Skip to main content
Glama

update_function

Modify an existing custom MCP function by updating its name, description, parameters schema, implementation code, or execution environment to align with new requirements.

Instructions

Update an existing custom MCP function

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNoNew description of what the function does
execution_environmentNoNew environment to execute the code in
implementation_codeNoNew code to implement the function
nameYesName of the function to update
parameters_schemaNoNew JSON Schema for parameters

Implementation Reference

  • Handler function that updates an existing custom tool by modifying its properties (description, schema, code, environment), re-registers it with the MCP server, persists changes to database, and returns appropriate success/error response.
    async ({ name, description, parameters_schema, implementation_code, execution_environment }) => { console.error(`Updating function: ${name}`); // Check if function exists if (!customTools[name]) { return { isError: true, content: [ { type: "text", text: `No function named "${name}" exists. Use define_function to create it.`, }, ], }; } // Validate execution environment if changing if (execution_environment === "javascript" && !ALLOW_JS_EXECUTION) { return { isError: true, content: [ { type: "text", text: "JavaScript execution is not allowed in this environment.", }, ], }; } if (execution_environment === "python" && !ALLOW_PYTHON_EXECUTION) { return { isError: true, content: [ { type: "text", text: "Python execution is not allowed in this environment.", }, ], }; } if (execution_environment === "shell" && !ALLOW_SHELL_EXECUTION) { return { isError: true, content: [ { type: "text", text: "Shell execution is not allowed in this environment.", }, ], }; } // Update the tool definition const updatedTool = { ...customTools[name] }; if (description !== undefined) updatedTool.description = description; if (parameters_schema !== undefined) updatedTool.inputSchema = parameters_schema; if (implementation_code !== undefined) updatedTool.implementation = implementation_code; if (execution_environment !== undefined) updatedTool.executionEnvironment = execution_environment; updatedTool.updatedAt = new Date(); // Register the updated tool try { // The server doesn't have a way to update tools, so we'll just re-register it registerToolWithServer(updatedTool); // Store the updated tool customTools[name] = updatedTool; await saveToolsDatabase(); return { content: [ { type: "text", text: `Successfully updated function "${name}".`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Error updating function: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
  • Zod-based input schema defining optional parameters for updating a custom function: name (required), description, parameters_schema, implementation_code, execution_environment.
    { name: z.string().min(1).describe("Name of the function to update"), description: z.string().optional().describe("New description of what the function does"), parameters_schema: z.record(z.any()).optional().describe("New JSON Schema for parameters"), implementation_code: z.string().optional().describe("New code to implement the function"), execution_environment: z.enum(["javascript", "python", "shell"]).optional().describe("New environment to execute the code in"), },
  • src/index.ts:309-407 (registration)
    MCP server registration of the update_function tool, providing name, description, input schema, and handler function.
    server.tool( "update_function", "Update an existing custom MCP function", { name: z.string().min(1).describe("Name of the function to update"), description: z.string().optional().describe("New description of what the function does"), parameters_schema: z.record(z.any()).optional().describe("New JSON Schema for parameters"), implementation_code: z.string().optional().describe("New code to implement the function"), execution_environment: z.enum(["javascript", "python", "shell"]).optional().describe("New environment to execute the code in"), }, async ({ name, description, parameters_schema, implementation_code, execution_environment }) => { console.error(`Updating function: ${name}`); // Check if function exists if (!customTools[name]) { return { isError: true, content: [ { type: "text", text: `No function named "${name}" exists. Use define_function to create it.`, }, ], }; } // Validate execution environment if changing if (execution_environment === "javascript" && !ALLOW_JS_EXECUTION) { return { isError: true, content: [ { type: "text", text: "JavaScript execution is not allowed in this environment.", }, ], }; } if (execution_environment === "python" && !ALLOW_PYTHON_EXECUTION) { return { isError: true, content: [ { type: "text", text: "Python execution is not allowed in this environment.", }, ], }; } if (execution_environment === "shell" && !ALLOW_SHELL_EXECUTION) { return { isError: true, content: [ { type: "text", text: "Shell execution is not allowed in this environment.", }, ], }; } // Update the tool definition const updatedTool = { ...customTools[name] }; if (description !== undefined) updatedTool.description = description; if (parameters_schema !== undefined) updatedTool.inputSchema = parameters_schema; if (implementation_code !== undefined) updatedTool.implementation = implementation_code; if (execution_environment !== undefined) updatedTool.executionEnvironment = execution_environment; updatedTool.updatedAt = new Date(); // Register the updated tool try { // The server doesn't have a way to update tools, so we'll just re-register it registerToolWithServer(updatedTool); // Store the updated tool customTools[name] = updatedTool; await saveToolsDatabase(); return { content: [ { type: "text", text: `Successfully updated function "${name}".`, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Error updating function: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );

Other Tools

Related 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/alxspiker/ai-meta-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server