Skip to main content
Glama
index.js976 B
// Create a map to store all registered tools const toolMap = new Map(); /** * Register a tool with the system * @param tool The tool instance to register * @returns The registered tool instance (for chaining) */ export function registerTool(tool) { const toolName = tool.tool.name; // Check for duplicate tool names if (toolMap.has(toolName)) { console.warn(`Tool with name '${toolName}' already registered. Overwriting.`); } // Add tool to the map toolMap.set(toolName, tool); return tool; } // Export all tools for registration export const getTools = () => Array.from(toolMap.values()).map(impl => impl.tool); /** * Handle tool calls by name */ export const handleToolCall = async (name, args) => { const toolImpl = toolMap.get(name); if (toolImpl) { return await toolImpl.handleRequest(args); } return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true, }; };

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/ajaystream/hubspot-mcp-custom'

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