UNPKG

mcp-server-anki

Version:

Model Context Protocol (MCP) server enabling AI assistants (Claude, GPT-4, Gemini, etc.) to interact with Anki flashcards through AnkiConnect.

72 lines 1.67 kB
"use strict"; /** * Tool Registry Implementation * Manages registration and lookup of MCP tools */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ToolRegistry = void 0; /** * Concrete implementation of the tool registry */ class ToolRegistry { constructor() { this.tools = new Map(); } /** * Register a single tool */ registerTool(name, toolDef) { if (this.tools.has(name)) { throw new Error(`Tool '${name}' is already registered`); } this.tools.set(name, toolDef); } /** * Register a category of tools */ registerCategory(category) { for (const tool of category.tools) { const toolName = tool.definition.name; this.registerTool(toolName, tool); } } /** * Get all registered tools for ListTools */ getAllTools() { return Array.from(this.tools.values()).map(toolDef => toolDef.definition); } /** * Get handler for a specific tool */ getHandler(toolName) { const toolDef = this.tools.get(toolName); return toolDef?.handler; } /** * Get all tool names */ getToolNames() { return Array.from(this.tools.keys()); } /** * Check if tool exists */ hasTool(toolName) { return this.tools.has(toolName); } /** * Get tool count */ getToolCount() { return this.tools.size; } /** * Clear all tools (useful for testing) */ clear() { this.tools.clear(); } } exports.ToolRegistry = ToolRegistry; //# sourceMappingURL=tool-registry.js.map