Update Entry
update_entryUpdate an existing content entry by specifying its collection, UUID, and new field values. Optionally change publication status or locale.
Instructions
Update an existing content entry
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection_slug | Yes | The collection slug | |
| uuid | Yes | The entry UUID | |
| data | Yes | Object with field names and their new values | |
| status | No | Publication status: 'published' or 'draft' | |
| locale | No | Locale code |
Implementation Reference
- src/tools/content.ts:155-164 (handler)The async handler function that executes the update_entry tool logic. It receives collection_slug, uuid, data, status, and locale parameters, builds a request body with optional status/locale, and calls client.put() to update the entry.
}, async ({ collection_slug, uuid, data, status, locale }) => { const body: Record<string, unknown> = { data }; if (status) body.status = status; if (locale) body.locale = locale; const result = await client.put(`/${collection_slug}/${uuid}`, body); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }); - src/tools/content.ts:143-154 (schema)Input schema for update_entry using Zod. Defines required fields: collection_slug (string), uuid (string), data (record of field values), plus optional status ('published' or 'draft') and locale.
inputSchema: { collection_slug: z.string().describe("The collection slug"), uuid: z.string().describe("The entry UUID"), data: z .record(z.string(), z.unknown()) .describe("Object with field names and their new values"), status: z .string() .optional() .describe("Publication status: 'published' or 'draft'"), locale: z.string().optional().describe("Locale code"), }, - src/tools/content.ts:140-164 (registration)Registration of the 'update_entry' tool via server.registerTool(), binding the name, title, description, inputSchema, and handler function.
server.registerTool("update_entry", { title: "Update Entry", description: "Update an existing content entry", inputSchema: { collection_slug: z.string().describe("The collection slug"), uuid: z.string().describe("The entry UUID"), data: z .record(z.string(), z.unknown()) .describe("Object with field names and their new values"), status: z .string() .optional() .describe("Publication status: 'published' or 'draft'"), locale: z.string().optional().describe("Locale code"), }, }, async ({ collection_slug, uuid, data, status, locale }) => { const body: Record<string, unknown> = { data }; if (status) body.status = status; if (locale) body.locale = locale; const result = await client.put(`/${collection_slug}/${uuid}`, body); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }); - src/client.ts:124-132 (helper)The ElmapiClient.put() method used by the handler to send a PUT request to /{collection_slug}/{uuid} with the update data in the body.
async put(path: string, body?: unknown): Promise<unknown> { const response = await fetch(`${this.baseUrl}${path}`, { method: "PUT", headers: this.headers(), body: body ? JSON.stringify(body) : undefined, }); return this.handleResponse(response); }