Skip to main content
Glama

get_templates

Retrieve available templates for specific object types to create new objects with pre-configured structures and content in your Anytype space.

Instructions

Retrieves all available templates for a specific object type in an Anytype space. Templates provide pre-configured structures and content for creating new objects. This tool returns a list of templates with their IDs, names, and metadata. Results are paginated for types with many templates. Use this tool when you need to find appropriate templates for creating new objects of a specific type.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
space_idYesSpace ID containing the type
type_idYesType ID to get templates for
offsetNoPagination offset
limitNoNumber of results per page (1-1000)

Implementation Reference

  • The handler function that implements the core logic of the 'get_templates' tool. It validates pagination parameters, calls the Anytype API to fetch templates for a specific type in a space, formats the response as JSON text, and handles errors using the shared handleApiError method.
    async ({ space_id, type_id, offset, limit }) => { try { // Validate limit const validLimit = Math.max(1, Math.min(1000, limit)); const response = await this.makeRequest( "get", `/spaces/${space_id}/types/${type_id}/templates`, null, { offset, limit: validLimit } ); return { content: [ { type: "text" as const, text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleApiError(error); } }
  • Zod input schema defining the parameters for the get_templates tool: required space_id and type_id, optional offset and limit for pagination.
    { space_id: z.string().describe("Space ID containing the type"), type_id: z.string().describe("Type ID to get templates for"), offset: z.number().optional().default(0).describe("Pagination offset"), limit: z .number() .optional() .default(100) .describe("Number of results per page (1-1000)"),
  • src/index.ts:441-477 (registration)
    Full registration of the 'get_templates' tool using McpServer.tool(), including name, description, input schema, and inline handler function.
    this.server.tool( "get_templates", "Retrieves all available templates for a specific object type in an Anytype space. Templates provide pre-configured structures and content for creating new objects. This tool returns a list of templates with their IDs, names, and metadata. Results are paginated for types with many templates. Use this tool when you need to find appropriate templates for creating new objects of a specific type.", { space_id: z.string().describe("Space ID containing the type"), type_id: z.string().describe("Type ID to get templates for"), offset: z.number().optional().default(0).describe("Pagination offset"), limit: z .number() .optional() .default(100) .describe("Number of results per page (1-1000)"), }, async ({ space_id, type_id, offset, limit }) => { try { // Validate limit const validLimit = Math.max(1, Math.min(1000, limit)); const response = await this.makeRequest( "get", `/spaces/${space_id}/types/${type_id}/templates`, null, { offset, limit: validLimit } ); return { content: [ { type: "text" as const, text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleApiError(error); } } );

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