Skip to main content
Glama
alxspiker

AI Meta MCP Server

update_function

Modify an existing custom function in the AI Meta MCP Server by updating its description, parameters schema, implementation code, or execution environment.

Instructions

Update an existing custom MCP function

Input Schema

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

Implementation Reference

  • The handler function for the 'update_function' tool. It checks if the function exists, validates the execution environment if changed, updates the tool definition, re-registers it with the server, saves to database, and returns success or 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)}`,
            },
          ],
        };
      }
    }
  • The input schema for the 'update_function' tool, defining optional parameters for updating name (required), description, schema, code, and 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)
    The registration of the 'update_function' tool using server.tool(), including name, description, schema, and handler.
    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)}`,
              },
            ],
          };
        }
      }
    );
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states it's an update operation, implying mutation, but doesn't disclose permissions needed, whether changes are reversible, error handling (e.g., if the function doesn't exist), or rate limits. This is inadequate for a mutation tool with zero annotation coverage.

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?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core purpose and appropriately sized for the tool's complexity, making it easy to parse quickly.

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?

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It lacks behavioral details (e.g., side effects, error cases) and doesn't explain what happens upon success (e.g., returns updated function details). For a 5-parameter update operation, more context is needed.

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 100%, so the schema fully documents all 5 parameters. The description adds no additional meaning beyond what's in the schema (e.g., it doesn't explain parameter interactions or constraints). Baseline 3 is appropriate when the schema does the heavy lifting.

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 resource ('an existing custom MCP function'), making the purpose immediately understandable. It distinguishes from sibling tools like 'define_function' (create) and 'delete_function' (remove), though it doesn't explicitly contrast with 'get_function_details' or 'list_functions'.

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 is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., the function must exist), when not to use it, or how it differs from 'define_function' for modifications versus creation. This leaves the agent without context for tool selection.

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

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