create_object
Create new content objects like pages, notes, or tasks in Anytype spaces. Specify name, type, description, icon, and content to organize information effectively.
Instructions
Creates a new object within a specified Anytype space. This tool allows you to add various types of content (pages, notes, tasks, etc.) to your spaces. You can specify the object's name, type, description, icon, and content. Optionally, you can use a template to create pre-structured objects. Use this tool when you need to add new content to an existing space.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| space_id | Yes | Space ID to create the object in | |
| name | Yes | Object name | |
| type_key | Yes | Type key of object to create (e.g. 'ot-page') | |
| description | No | Object's short description | |
| icon | No | Object icon details (structure based on API docs) | |
| body | No | Object body/content (Markdown supported) | |
| template_id | No | Template ID to use | |
| source | No | Source URL (for bookmarks) |
Implementation Reference
- src/index.ts:237-274 (handler)The asynchronous handler function that executes the create_object tool. It constructs the object payload from input parameters and makes a POST request to the Anytype API endpoint `/spaces/${space_id}/objects` to create the new object.space_id, name, type_key, description, icon, body, template_id, source, }) => { try { const createObj: any = { name, type_key, }; if (description) createObj.description = description; if (icon) createObj.icon = icon; if (body) createObj.body = body; if (template_id) createObj.template_id = template_id; if (source) createObj.source = source; const response = await this.makeRequest( "post", `/spaces/${space_id}/objects`, createObj ); return { content: [ { type: "text" as const, text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleApiError(error); } }
- src/index.ts:194-236 (schema)Zod input schema defining parameters for create_object: required space_id, name, type_key; optional description, icon (with sub-schema), body, template_id, source.{ space_id: z.string().describe("Space ID to create the object in"), name: z.string().describe("Object name"), type_key: z .string() .describe("Type key of object to create (e.g. 'ot-page')"), description: z .string() .optional() .describe("Object's short description"), icon: z .object({ format: z .enum(["emoji", "file", "icon"]) .describe("Icon format (required if icon is provided)"), emoji: z .string() .optional() .describe("Emoji character (if format is 'emoji')"), file: z .string() .url() .optional() .describe("URL to the icon file (if format is 'file')"), name: z .string() .optional() .describe("Name of the built-in icon (if format is 'icon')"), color: z .string() .optional() .describe("Color of the icon (optional)"), }) .optional() .describe("Object icon details (structure based on API docs)"), body: z .string() .optional() .describe("Object body/content (Markdown supported)"), template_id: z.string().optional().describe("Template ID to use"), source: z.string().optional().describe("Source URL (for bookmarks)"), }, async ({
- src/index.ts:191-275 (registration)Registration of the create_object tool on the MCP server using this.server.tool(), providing name, description, input schema, and handler function.this.server.tool( "create_object", "Creates a new object within a specified Anytype space. This tool allows you to add various types of content (pages, notes, tasks, etc.) to your spaces. You can specify the object's name, type, description, icon, and content. Optionally, you can use a template to create pre-structured objects. Use this tool when you need to add new content to an existing space.", { space_id: z.string().describe("Space ID to create the object in"), name: z.string().describe("Object name"), type_key: z .string() .describe("Type key of object to create (e.g. 'ot-page')"), description: z .string() .optional() .describe("Object's short description"), icon: z .object({ format: z .enum(["emoji", "file", "icon"]) .describe("Icon format (required if icon is provided)"), emoji: z .string() .optional() .describe("Emoji character (if format is 'emoji')"), file: z .string() .url() .optional() .describe("URL to the icon file (if format is 'file')"), name: z .string() .optional() .describe("Name of the built-in icon (if format is 'icon')"), color: z .string() .optional() .describe("Color of the icon (optional)"), }) .optional() .describe("Object icon details (structure based on API docs)"), body: z .string() .optional() .describe("Object body/content (Markdown supported)"), template_id: z.string().optional().describe("Template ID to use"), source: z.string().optional().describe("Source URL (for bookmarks)"), }, async ({ space_id, name, type_key, description, icon, body, template_id, source, }) => { try { const createObj: any = { name, type_key, }; if (description) createObj.description = description; if (icon) createObj.icon = icon; if (body) createObj.body = body; if (template_id) createObj.template_id = template_id; if (source) createObj.source = source; const response = await this.makeRequest( "post", `/spaces/${space_id}/objects`, createObj ); return { content: [ { type: "text" as const, text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleApiError(error); } } );