anytype_get_template
Retrieve a specific template from Anytype using space, type, and template IDs to access predefined object structures.
Instructions
Gets a specific template
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| space_id | Yes | Space ID | |
| type_id | Yes | Type ID (required - templates are associated with types) | |
| template_id | Yes | Template ID |
Implementation Reference
- src/handlers/types-tags.ts:323-363 (handler)Implements the core logic for retrieving a specific template via Anytype API, including input validation for space_id, type_id, template_id and error handling.export async function handleGetTemplate(args: any) { const { space_id, type_id, template_id } = args; // type_id is required according to official API docs if (!type_id) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'Missing required parameter', message: 'Field "type_id" is required for getting a template', provided_parameters: Object.keys(args), note: 'Templates are associated with specific types in Anytype API 2025-05-20' }, null, 2) }] }; } try { const response = await makeRequest(`/v1/spaces/${space_id}/types/${type_id}/templates/${template_id}`); return { content: [{ type: 'text', text: JSON.stringify(response, null, 2) }] }; } catch (error: any) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'Template retrieval error', message: 'Failed to get template using official API endpoint', endpoint: `/v1/spaces/${space_id}/types/${type_id}/templates/${template_id}`, error_details: error?.message || String(error), suggestions: [ 'Verify that the type_id exists in this space', 'Verify that the template_id exists for this type', 'Check API permissions for template access', 'Ensure space_id, type_id, and template_id are all correct' ] }, null, 2) }] }; } }
- src/tools/templates.ts:21-33 (schema)Defines the tool schema, description, and input validation schema for 'anytype_get_template'.{ name: 'anytype_get_template', description: 'Gets a specific template', inputSchema: { type: 'object', properties: { space_id: { type: 'string', description: 'Space ID' }, type_id: { type: 'string', description: 'Type ID (required - templates are associated with types)' }, template_id: { type: 'string', description: 'Template ID' }, }, required: ['space_id', 'type_id', 'template_id'], }, },
- src/index.ts:174-175 (registration)Registers the tool name in the main switch dispatcher, mapping it to the handleGetTemplate handler.case 'anytype_get_template': return await handleGetTemplate(args);
- src/index.ts:85-93 (registration)Combines all tool definitions including templateTools (which contains anytype_get_template) into the main tools list served via ListTools.const tools = [ ...spaceTools, ...objectTools, ...propertyTools, ...typeTools, ...tagTools, ...templateTools, ...listTools, ];