Skip to main content
Glama

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
NameRequiredDescriptionDefault
space_idYesSpace ID
type_idYesType ID (required - templates are associated with types)
template_idYesTemplate ID

Implementation Reference

  • 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) 
          }] 
        };
      }
    }
  • 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,
    ];

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