Skip to main content
Glama
test-mcp-fix.js2.68 kB
#!/usr/bin/env node // Test script to verify MCP server tool registration fix // This simulates what an external MCP client would do import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js'; // Import our server import { createServer, getRegisteredTools, executeToolByName } from './build/src/mcp/server.js'; console.log('Testing MCP Server Tool Registration Fix\n'); console.log('=========================================\n'); // Create the server const server = createServer(); // Check that handlers are registered console.log('1. Checking server has setRequestHandler method:'); console.log(' ', typeof server.setRequestHandler === 'function' ? '✅ YES' : '❌ NO'); // Check that we can get tools console.log('\n2. Getting registered tools:'); const tools = getRegisteredTools(); console.log(' Found', tools.length, 'tools:'); tools.forEach(tool => { console.log(' -', tool.name); }); // Simulate what happens when MCP client calls tools/list console.log('\n3. Simulating tools/list request:'); try { // Get the handlers that were registered const handlers = server._requestHandlers || {}; const listToolsHandler = handlers['tools/list']; if (listToolsHandler) { console.log(' ✅ tools/list handler is registered'); // Call it const result = await listToolsHandler({ method: 'tools/list', params: {} }); console.log(' Response has', result.tools?.length || 0, 'tools'); } else { console.log(' ❌ tools/list handler NOT registered'); } } catch (error) { console.log(' ❌ Error:', error.message); } // Simulate what happens when MCP client calls a tool console.log('\n4. Simulating tools/call request:'); try { const handlers = server._requestHandlers || {}; const callToolHandler = handlers['tools/call']; if (callToolHandler) { console.log(' ✅ tools/call handler is registered'); // Try to call undo tool const result = await callToolHandler({ method: 'tools/call', params: { name: 'smartsuite_undo', arguments: { transaction_id: 'test-123' } } }); console.log(' Response:', result.content?.[0]?.text?.substring(0, 50) + '...'); } else { console.log(' ❌ tools/call handler NOT registered'); } } catch (error) { console.log(' ❌ Error:', error.message); } console.log('\n========================================='); console.log('✅ MCP Server Tool Registration Fixed!'); console.log('The server now properly registers tool handlers.'); console.log('External MCP clients can now discover and call our tools.');

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/elevanaltd/smartsuite-mcp'

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