Skip to main content
Glama
alxspiker

AI Meta MCP Server

delete_function

Remove a custom MCP function by name to manage the AI Meta MCP Server's dynamic toolset.

Instructions

Delete a custom MCP function

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the function to delete

Implementation Reference

  • The handler function for the 'delete_function' tool. It checks if the specified function exists in the customTools object, deletes it if it does, saves the tools database, and returns appropriate success or error responses.
    async ({ name }) => {
      console.error(`Deleting function: ${name}`);
      
      // Check if function exists
      if (!customTools[name]) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: `No function named "${name}" exists.`,
            },
          ],
        };
      }
    
      // Delete the tool
      try {
        delete customTools[name];
        await saveToolsDatabase();
    
        return {
          content: [
            {
              type: "text",
              text: `Successfully deleted function "${name}".`,
            },
          ],
        };
      } catch (error) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: `Error deleting function: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • Input schema for the 'delete_function' tool, defining the 'name' parameter using Zod validation.
    {
      name: z.string().min(1).describe("Name of the function to delete"),
    },
  • src/index.ts:410-457 (registration)
    Registration of the 'delete_function' tool on the MCP server using server.tool(), specifying name, description, input schema, and handler.
    server.tool(
      "delete_function",
      "Delete a custom MCP function",
      {
        name: z.string().min(1).describe("Name of the function to delete"),
      },
      async ({ name }) => {
        console.error(`Deleting function: ${name}`);
        
        // Check if function exists
        if (!customTools[name]) {
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: `No function named "${name}" exists.`,
              },
            ],
          };
        }
    
        // Delete the tool
        try {
          delete customTools[name];
          await saveToolsDatabase();
    
          return {
            content: [
              {
                type: "text",
                text: `Successfully deleted function "${name}".`,
              },
            ],
          };
        } catch (error) {
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: `Error deleting function: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );

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