Skip to main content
Glama

Claude MCP Server Integration

by mokemoke0821
tool-registry.ts1.19 kB
import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js'; import { MCPToolDefinition } from '../types/common.js'; export class ToolRegistry { private tools: Map<string, any> = new Map(); private toolDefinitions: MCPToolDefinition[] = []; constructor(private server: Server) { this.setupHandlers(); } registerToolGroup(toolGroup: any) { const definitions = toolGroup.getToolDefinitions(); this.toolDefinitions.push(...definitions); definitions.forEach((def: MCPToolDefinition) => { this.tools.set(def.name, toolGroup); }); } private setupHandlers() { this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: this.toolDefinitions })); this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const toolGroup = this.tools.get(name); if (!toolGroup) { throw new Error(`Tool not found: ${name}`); } return await toolGroup.handleTool(name, args || {}); }); } }

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/mokemoke0821/claude-mcp-integration'

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