Skip to main content
Glama

anytype_create_object

Create a new object in an Anytype space with customizable properties, markdown content, and icons to organize information.

Instructions

Crea un nuevo objeto en un espacio

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
space_idYesID del espacio
nameYesNombre del objeto
type_keyNoTipo de objetopage
bodyNoContenido del objeto (Markdown)
markdownNoContenido del objeto (Markdown) - alias para body
iconNoIcono
propertiesNoPropiedades del objeto
template_idNoID de plantilla

Implementation Reference

  • The main handler function that implements the logic for creating a new Anytype object, processing properties including tags, making the API POST request, and formatting the 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) }] }; }
  • The tool schema definition including input parameters, descriptions, and validation rules for anytype_create_object.
    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)
    The dispatch case in the main MCP server request handler that routes calls to the anytype_create_object tool to its handler function.
    case 'anytype_create_object': return await handleCreateObject(args);
  • Helper function used by the handler to validate and process object properties, particularly handling multi-select and select tags.
    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; }

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