Skip to main content
Glama

deleteItem

Remove a specific item from a collection in Directus CMS by specifying the collection name and item ID, using the MCP Server to execute the deletion via an API call.

Instructions

Delete an item from a collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection name
idYesItem ID
tokenNoAuthentication token (default from config)
urlNoDirectus API URL (default from config)

Implementation Reference

  • The handler logic for deleteItem tool, which performs a DELETE request to the Directus API to remove the specified item from the collection.
    case "deleteItem": {
      const token = toolArgs.token || CONFIG.DIRECTUS_ACCESS_TOKEN;
      const collection = toolArgs.collection as string;
      const id = toolArgs.id as string | number;
      
      await axios.delete(
        `${url}/items/${collection}/${id}`,
        { headers: buildHeaders(token) }
      );
      
      return {
        content: [
          {
            type: "text",
            text: "Item deleted successfully"
          }
        ]
      };
    }
  • The input schema defining parameters for the deleteItem tool, including collection and id as required fields.
    {
      name: "deleteItem",
      description: "Delete an item from a collection",
      inputSchema: {
        type: "object",
        properties: {
          url: { 
            type: "string", 
            description: "Directus API URL (default from config)"
          },
          token: { 
            type: "string", 
            description: "Authentication token (default from config)"
          },
          collection: { 
            type: "string", 
            description: "Collection name"
          },
          id: { 
            type: "string", 
            description: "Item ID"
          }
        },
        required: ["collection", "id"]
      }
    },
  • Helper function to build HTTP headers with authentication token, used by the deleteItem handler.
    const buildHeaders = (token: string): Record<string, string> => {
      return {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${token}`
      };
    };
Install Server

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/pixelsock/directus-mcp'

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