Skip to main content
Glama

updateItem

Modify an existing item in a Directus collection by specifying the item’s ID and updated data. Enables precise updates within the MCP server for CMS management.

Instructions

Update an existing item in a collection

Input Schema

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

Implementation Reference

  • The handler for the 'updateItem' tool. It extracts parameters, constructs the Directus API endpoint for updating an item, sends a PATCH request using axios, and returns the response as JSON text content.
    case "updateItem": {
      const token = toolArgs.token || CONFIG.DIRECTUS_ACCESS_TOKEN;
      const collection = toolArgs.collection as string;
      const id = toolArgs.id as string | number;
      const data = toolArgs.data as Record<string, any>;
      
      const response = await axios.patch(
        `${url}/items/${collection}/${id}`,
        data,
        { headers: buildHeaders(token) }
      );
      
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(response.data, null, 2)
          }
        ]
      };
    }
  • The schema definition for the 'updateItem' tool, including name, description, and input schema as returned by the listTools handler.
    {
      name: "updateItem",
      description: "Update an existing item in 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"
          },
          data: { 
            type: "object", 
            description: "Updated item data"
          }
        },
        required: ["collection", "id", "data"]
      }
    },
  • index.ts:85-513 (registration)
    The listTools request handler where all tools, including 'updateItem', are registered by being listed in the tools array.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "getItems",
            description: "Get items from a collection in Directus",
            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" 
                },
                query: { 
                  type: "object", 
                  description: "Query parameters like filter, sort, limit, etc. (optional)"
                }
              },
              required: ["collection"]
            }
          },
          {
            name: "getItem",
            description: "Get a single item from a collection by ID",
            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"
                },
                query: { 
                  type: "object", 
                  description: "Query parameters (optional)"
                }
              },
              required: ["collection", "id"]
            }
          },
          {
            name: "createItem",
            description: "Create a new item in 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"
                },
                data: { 
                  type: "object", 
                  description: "Item data"
                }
              },
              required: ["collection", "data"]
            }
          },
          {
            name: "updateItem",
            description: "Update an existing item in 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"
                },
                data: { 
                  type: "object", 
                  description: "Updated item data"
                }
              },
              required: ["collection", "id", "data"]
            }
          },
          {
            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"]
            }
          },
          {
            name: "getSystemInfo",
            description: "Get system information from Directus",
            inputSchema: {
              type: "object",
              properties: {
                url: { 
                  type: "string", 
                  description: "Directus API URL (default from config)"
                },
                token: { 
                  type: "string", 
                  description: "Authentication token (default from config)"
                },
                endpoint: { 
                  type: "string", 
                  description: "System endpoint (e.g. 'health', 'info', 'activity')"
                }
              },
              required: ["endpoint"]
            }
          },
          {
            name: "getCollections",
            description: "Get all collection schemas from Directus",
            inputSchema: {
              type: "object",
              properties: {
                url: { 
                  type: "string", 
                  description: "Directus API URL (default from config)"
                },
                token: { 
                  type: "string", 
                  description: "Authentication token (default from config)"
                }
              },
              required: []
            }
          },
          {
            name: "login",
            description: "Login to Directus and get an access token",
            inputSchema: {
              type: "object",
              properties: {
                url: { 
                  type: "string", 
                  description: "Directus API URL (default from config)"
                },
                email: { 
                  type: "string", 
                  description: "User email (default from config)"
                },
                password: { 
                  type: "string", 
                  description: "User password (default from config)"
                }
              },
              required: []
            }
          },
          {
            name: "getActivity",
            description: "Get activity logs from Directus",
            inputSchema: {
              type: "object",
              properties: {
                url: { 
                  type: "string", 
                  description: "Directus API URL (default from config)"
                },
                token: { 
                  type: "string", 
                  description: "Authentication token (default from config)"
                },
                query: {
                  type: "object",
                  description: "Query parameters like filter, sort, limit, etc. (optional)"
                }
              },
              required: []
            }
          },
          {
            name: "getFields",
            description: "Get fields for 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"
                }
              },
              required: ["collection"]
            }
          },
          {
            name: "getRelations",
            description: "Get relations for 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 (optional)"
                }
              },
              required: []
            }
          },
          {
            name: "getFiles",
            description: "Get files from Directus",
            inputSchema: {
              type: "object",
              properties: {
                url: { 
                  type: "string", 
                  description: "Directus API URL (default from config)"
                },
                token: { 
                  type: "string", 
                  description: "Authentication token (default from config)"
                },
                query: {
                  type: "object",
                  description: "Query parameters like filter, sort, limit, etc. (optional)"
                }
              },
              required: []
            }
          },
          {
            name: "uploadFile",
            description: "Upload a file to Directus",
            inputSchema: {
              type: "object",
              properties: {
                url: { 
                  type: "string", 
                  description: "Directus API URL (default from config)"
                },
                token: { 
                  type: "string", 
                  description: "Authentication token (default from config)"
                },
                fileUrl: {
                  type: "string",
                  description: "URL of the file to upload (either fileUrl or fileData must be provided)"
                },
                fileData: {
                  type: "string",
                  description: "Base64 encoded file data (either fileUrl or fileData must be provided)"
                },
                fileName: {
                  type: "string",
                  description: "Name of the file"
                },
                mimeType: {
                  type: "string",
                  description: "MIME type of the file"
                },
                storage: {
                  type: "string",
                  description: "Storage location (optional)"
                },
                title: {
                  type: "string",
                  description: "File title (optional)"
                }
              },
              required: ["fileName"]
            }
          },
          {
            name: "getUsers",
            description: "Get users from Directus",
            inputSchema: {
              type: "object",
              properties: {
                url: { 
                  type: "string", 
                  description: "Directus API URL (default from config)"
                },
                token: { 
                  type: "string", 
                  description: "Authentication token (default from config)"
                },
                query: {
                  type: "object",
                  description: "Query parameters like filter, sort, limit, etc. (optional)"
                }
              },
              required: []
            }
          },
          {
            name: "getCurrentUser",
            description: "Get the current user info",
            inputSchema: {
              type: "object",
              properties: {
                url: { 
                  type: "string", 
                  description: "Directus API URL (default from config)"
                },
                token: { 
                  type: "string", 
                  description: "Authentication token (default from config)"
                }
              },
              required: []
            }
          },
          {
            name: "getRoles",
            description: "Get roles from Directus",
            inputSchema: {
              type: "object",
              properties: {
                url: { 
                  type: "string", 
                  description: "Directus API URL (default from config)"
                },
                token: { 
                  type: "string", 
                  description: "Authentication token (default from config)"
                },
                query: {
                  type: "object",
                  description: "Query parameters like filter, sort, limit, etc. (optional)"
                }
              },
              required: []
            }
          },
          {
            name: "getPermissions",
            description: "Get permissions from Directus",
            inputSchema: {
              type: "object",
              properties: {
                url: { 
                  type: "string", 
                  description: "Directus API URL (default from config)"
                },
                token: { 
                  type: "string", 
                  description: "Authentication token (default from config)"
                },
                query: {
                  type: "object",
                  description: "Query parameters like filter, sort, limit, etc. (optional)"
                }
              },
              required: []
            }
          },
          {
            name: "getConfig",
            description: "Get current configuration information (without secrets)",
            inputSchema: {
              type: "object",
              properties: {},
              required: []
            }
          }
        ]
      };
    });
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 only states it's an update operation. It doesn't disclose behavioral traits like authentication needs (implied by 'token' param but not explained), mutation effects, error handling, or rate limits, leaving significant gaps.

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, front-loading the core action. It's 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 the tool's complexity (mutation with 5 parameters, no annotations, no output schema), the description is inadequate. It doesn't cover return values, error cases, or behavioral context, leaving the agent with insufficient information to use the tool effectively.

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 meaning beyond the schema, as it doesn't explain parameter interactions or provide examples. Baseline 3 is appropriate since 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 verb ('Update') and resource ('existing item in a collection'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'createItem' or 'deleteItem' beyond the obvious verb difference, missing specific scope distinctions.

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?

The description provides no guidance on when to use this tool versus alternatives like 'createItem' for new items or 'getItem' for reading. It lacks context about prerequisites, such as needing an existing item ID, or exclusions, leaving usage ambiguous.

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

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