Skip to main content
Glama
ToolRegistry.ts1.24 kB
/** * Tool Registry * Manages registration and lookup of tool handlers */ import type { IToolHandler } from './IToolHandler.js'; /** * Registry for managing tool handlers * Implements the Registry pattern for Open/Closed Principle compliance */ export class ToolRegistry { private handlers = new Map<string, IToolHandler>(); /** * Register a tool handler * @param handler - The handler to register */ register(handler: IToolHandler): void { const name = handler.getName(); if (this.handlers.has(name)) { throw new Error(`Tool handler '${name}' is already registered`); } this.handlers.set(name, handler); } /** * Get a tool handler by name * @param name - The tool name * @returns The handler if found, undefined otherwise */ get(name: string): IToolHandler | undefined { return this.handlers.get(name); } /** * Get all registered tool names * @returns Array of tool names */ getAllToolNames(): string[] { return Array.from(this.handlers.keys()); } /** * Check if a tool is registered * @param name - The tool name * @returns True if registered, false otherwise */ has(name: string): boolean { return this.handlers.has(name); } }

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/jcr82/bruno-mcp-server'

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