Skip to main content
Glama

createDeck

Create a new Anki flashcard deck with a name and description to organize study materials for spaced repetition learning.

Instructions

Create a new Anki deck

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesDescription of the deck
isPublicNoWhether the deck should be public
nameYesName of the deck

Implementation Reference

  • The execute function that performs the core logic of the createDeck tool: sends a POST request to the Anki API endpoint '/api/v1/decks' with the provided name, description, and optional isPublic flag.
    execute: async args => { try { const data = await ankiApiRequest('POST', '/api/v1/decks', { description: args.description, isPublic: args.isPublic || false, name: args.name, }); return JSON.stringify(data, null, 2); } catch (error) { return `Error: ${error instanceof Error ? error.message : String(error)}`; } },
  • Zod schema defining the input parameters for the createDeck tool: required name and description (strings), optional isPublic (boolean).
    parameters: z.object({ description: z.string().describe('Description of the deck'), isPublic: z .boolean() .optional() .describe('Whether the deck should be public'), name: z.string().describe('Name of the deck'), }),
  • src/index.ts:93-116 (registration)
    The FastMCP server.addTool registration for the createDeck tool, including name, description, handler, and schema.
    server.addTool({ description: 'Create a new Anki deck', execute: async args => { try { const data = await ankiApiRequest('POST', '/api/v1/decks', { description: args.description, isPublic: args.isPublic || false, name: args.name, }); return JSON.stringify(data, null, 2); } catch (error) { return `Error: ${error instanceof Error ? error.message : String(error)}`; } }, name: 'createDeck', parameters: z.object({ description: z.string().describe('Description of the deck'), isPublic: z .boolean() .optional() .describe('Whether the deck should be public'), name: z.string().describe('Name of the deck'), }), });
  • Shared helper function for making authenticated HTTP requests to the Anki API, used by createDeck and other tools.
    async function ankiApiRequest( method: string, endpoint: string, body?: Record<string, unknown>, queryParams?: Record<string, boolean | number | string | undefined>, ) { const url = new URL(`${ANKI_BASE_URL}${endpoint}`); // Add query parameters if provided if (queryParams) { Object.entries(queryParams).forEach(([key, value]) => { if (value !== undefined && value !== '') { url.searchParams.append(key, String(value)); } }); } const options: RequestInit = { headers: { Authorization: `Bearer ${ANKI_API_KEY}`, 'Content-Type': 'application/json', }, method, }; if (body && method !== 'GET') { options.body = JSON.stringify(body); } const response = await fetch(url.toString(), options); const data = (await response.json()) as unknown; if (!response.ok) { const errorData = data as { error?: { message?: string } }; throw new Error( errorData.error?.message || `API request failed: ${response.statusText}`, ); } return data; }

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/zlatanpham/anki-mcp'

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