Skip to main content
Glama

get_template_details

Retrieve detailed template structure and configuration information from Anytype spaces to examine properties and understand how templates are organized before creating new objects.

Instructions

Retrieves detailed information about a specific template in an Anytype space. This tool provides comprehensive details about the template's structure, content, and configuration. Use this tool when you need to examine a template's properties before using it to create new objects, or to understand how a particular template is structured.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
space_idYesSpace ID containing the template
type_idYesType ID for the template
template_idYesTemplate ID to retrieve details for

Implementation Reference

  • The handler function that executes the tool logic: makes a GET request to the Anytype API endpoint for template details and returns the JSON response or handles errors.
    async ({ space_id, type_id, template_id }) => { try { const response = await this.makeRequest( "get", `/spaces/${space_id}/types/${type_id}/templates/${template_id}` ); return { content: [ { type: "text" as const, text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleApiError(error); } }
  • Zod input schema defining the required parameters: space_id, type_id, and template_id.
    { space_id: z.string().describe("Space ID containing the template"), type_id: z.string().describe("Type ID for the template"), template_id: z.string().describe("Template ID to retrieve details for"), },
  • src/index.ts:480-506 (registration)
    Registration of the 'get_template_details' tool using this.server.tool(), including name, description, schema, and handler.
    this.server.tool( "get_template_details", "Retrieves detailed information about a specific template in an Anytype space. This tool provides comprehensive details about the template's structure, content, and configuration. Use this tool when you need to examine a template's properties before using it to create new objects, or to understand how a particular template is structured.", { space_id: z.string().describe("Space ID containing the template"), type_id: z.string().describe("Type ID for the template"), template_id: z.string().describe("Template ID to retrieve details for"), }, async ({ space_id, type_id, template_id }) => { try { const response = await this.makeRequest( "get", `/spaces/${space_id}/types/${type_id}/templates/${template_id}` ); return { content: [ { type: "text" as const, text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleApiError(error); } } );
  • Helper method used by the handler to make authenticated API requests to the Anytype server.
    private async makeRequest( method: "get" | "post" | "delete", endpoint: string, data?: any, params?: any ) { try { const config = { method, url: `${this.apiBaseUrl}${endpoint}`, headers: { Authorization: `Bearer ${this.appKey}`, "Content-Type": "application/json", }, data, params, }; return await axios(config); } catch (error) { console.error(`API request error: ${error}`); throw error; } }
  • Helper method used by the handler to handle and format API errors consistently.
    private handleApiError(error: any) { let errorMessage = "Unknown API error"; // Handle network errors first if (error.code === "ECONNREFUSED") { errorMessage = "Anytype is not running. Launch it and try again."; return this.printError(error, errorMessage); } // Handle API response errors const status = error.response?.status; const apiError = error.response?.data?.error; switch (status) { case 400: errorMessage = apiError?.message || "Bad request"; if (apiError?.code === "validation_error") { errorMessage += ". Invalid parameters: " + (apiError.details ?.map((d: { field: string }) => d.field) .join(", ") || "unknown fields"); } break; case 401: errorMessage = "Unauthorized - Check your App Key"; break; case 403: errorMessage = "Forbidden - You don't have permission for this operation"; break; case 404: errorMessage = "Not found - The requested resource doesn't exist"; break; case 429: errorMessage = "Rate limit exceeded - Try again later"; break; case 500: errorMessage = "Internal server error - Contact Anytype support"; break; default: if (status >= 500 && status < 600) { errorMessage = `Server error (${status}) - Try again later`; } else if (apiError?.message) { errorMessage = apiError.message; } break; } return this.printError(apiError, errorMessage); }

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

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