Skip to main content
Glama

anytype_create_object

Create a new object in a specified space with customizable attributes like name, type, content, icon, and properties using Markdown support. Define object structure and layout with optional templates.

Instructions

Crea un nuevo objeto en un espacio

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bodyNoContenido del objeto (soporta Markdown)
iconNoIcono del objeto
nameYesNombre del objeto
propertiesNoPropiedades del objeto
space_idYesID del espacio donde crear el objeto
template_idNoID de plantilla para usar como base (opcional)
type_keyNoTipo de objeto (ej: "page", "note")page

Implementation Reference

  • The main handler function that implements the 'anytype_create_object' tool. It processes input arguments, handles markdown alias, validates and processes properties/tags, makes a POST request to the Anytype API to create the object, and returns a formatted response.
    export async function handleCreateObject(args: any) { const { space_id, properties, ...objectData } = args; // Handle markdown alias if (objectData.markdown && !objectData.body) { objectData.body = objectData.markdown; delete objectData.markdown; } // Process and validate tags if properties are provided let processedProperties = []; if (properties && Array.isArray(properties)) { processedProperties = await validateAndProcessTags(space_id, properties); console.log(`Processed ${processedProperties.length} properties for new object`); } const finalObjectData = { ...objectData, ...(processedProperties.length > 0 && { properties: processedProperties }) }; const response = await makeRequest(`/v1/spaces/${space_id}/objects`, { method: 'POST', body: JSON.stringify(finalObjectData), }); return { content: [{ type: 'text', text: JSON.stringify({ message: 'Object created successfully', object: response, processed_properties: processedProperties.length, tag_assignments: processedProperties.filter(p => p.multi_select || p.select).length }, null, 2) }] }; }
  • Defines the input schema and metadata for the 'anytype_create_object' tool, including parameters like space_id, name, type_key, body/markdown, icon, properties, and template_id.
    { name: 'anytype_create_object', description: 'Crea un nuevo objeto en un espacio', inputSchema: { type: 'object', properties: { space_id: { type: 'string', description: 'ID del espacio' }, name: { type: 'string', description: 'Nombre del objeto' }, type_key: { type: 'string', description: 'Tipo de objeto', default: 'page' }, body: { type: 'string', description: 'Contenido del objeto (Markdown)' }, markdown: { type: 'string', description: 'Contenido del objeto (Markdown) - alias para body' }, icon: iconSchema, properties: objectPropertiesSchema, template_id: { type: 'string', description: 'ID de plantilla' }, }, required: ['space_id', 'name'], }, },
  • src/index.ts:128-129 (registration)
    Registers the tool call routing in the main server request handler switch statement, directing 'anytype_create_object' calls to the handleCreateObject function.
    case 'anytype_create_object': return await handleCreateObject(args);
  • Helper function used by the create and update handlers to process and log tag assignments in object properties (multi_select and select types).
    /** * Helper function to validate and process tag assignments * @param spaceId - Space ID * @param properties - Array of properties with potential tags * @returns Promise<any[]> - Validated properties array */ async function validateAndProcessTags(spaceId: string, properties: any[]): Promise<any[]> { if (!properties || !Array.isArray(properties)) { return []; } const processedProperties = []; for (const prop of properties) { const processedProp = { ...prop }; // Handle multi_select properties (tags) if (prop.multi_select && Array.isArray(prop.multi_select)) { try { // Validate that all tag IDs exist // Note: We can't easily validate individual tags without knowing the property_id // This is a limitation of the current API structure console.log(`Processing multi_select property "${prop.key}" with ${prop.multi_select.length} tags`); processedProp.multi_select = prop.multi_select; } catch (error) { console.warn(`Warning: Could not validate tags for property "${prop.key}":`, error); // Keep the tags anyway, let the API handle validation processedProp.multi_select = prop.multi_select; } } // Handle single select properties if (prop.select) { try { console.log(`Processing select property "${prop.key}" with tag: ${prop.select}`); processedProp.select = prop.select; } catch (error) { console.warn(`Warning: Could not validate tag for property "${prop.key}":`, error); processedProp.select = prop.select; } } processedProperties.push(processedProp); } return processedProperties; }

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/cryptonahue/mcp-anytype'

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