Create Entry
create_entryCreates a new content entry in a specified collection, setting field values and publication status.
Instructions
Create a new content entry in a collection
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection_slug | Yes | The collection slug | |
| data | Yes | Object where keys are field names and values are the content (e.g. { title: 'My Post', slug: 'my-post' }) | |
| status | No | Publication status: 'published' or 'draft' (default) | |
| locale | No | Locale code (e.g. 'en') |
Implementation Reference
- src/tools/content.ts:128-137 (handler)The async handler function that executes the 'create_entry' tool logic: calls client.post with the collection_slug, data, status, and locale parameters and returns JSON result.
}, async ({ collection_slug, data, status, locale }) => { const body: Record<string, unknown> = { data }; if (status) body.status = status; if (locale) body.locale = locale; const result = await client.post(`/${collection_slug}`, body); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }); - src/tools/content.ts:115-127 (schema)Input schema for 'create_entry' using Zod: defines collection_slug (string), data (record of unknown), status (optional string: 'published' or 'draft'), and locale (optional string).
inputSchema: { collection_slug: z.string().describe("The collection slug"), data: z .record(z.string(), z.unknown()) .describe( "Object where keys are field names and values are the content (e.g. { title: 'My Post', slug: 'my-post' })" ), status: z .string() .optional() .describe("Publication status: 'published' or 'draft' (default)"), locale: z.string().optional().describe("Locale code (e.g. 'en')"), }, - src/tools/content.ts:112-137 (registration)Registration of the tool as 'create_entry' via server.registerTool(), with title 'Create Entry' and description 'Create a new content entry in a collection'.
server.registerTool("create_entry", { title: "Create Entry", description: "Create a new content entry in a collection", inputSchema: { collection_slug: z.string().describe("The collection slug"), data: z .record(z.string(), z.unknown()) .describe( "Object where keys are field names and values are the content (e.g. { title: 'My Post', slug: 'my-post' })" ), status: z .string() .optional() .describe("Publication status: 'published' or 'draft' (default)"), locale: z.string().optional().describe("Locale code (e.g. 'en')"), }, }, async ({ collection_slug, data, status, locale }) => { const body: Record<string, unknown> = { data }; if (status) body.status = status; if (locale) body.locale = locale; const result = await client.post(`/${collection_slug}`, body); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }); - src/client.ts:114-122 (helper)The client.post method used by create_entry's handler to send the HTTP POST request to the API endpoint.
async post(path: string, body?: unknown): Promise<unknown> { const response = await fetch(`${this.baseUrl}${path}`, { method: "POST", headers: this.headers(), body: body ? JSON.stringify(body) : undefined, }); return this.handleResponse(response); } - src/index.ts:38-39 (registration)Top-level registration call that invokes registerContentTools(server, client) from src/index.ts, which in turn registers the create_entry tool.
registerContentTools(server, client); registerAssetTools(server, client);