Skip to main content
Glama
test-output-format.js•6.25 kB
const { spawn } = require('child_process'); const path = require('path'); /** * Test output format differences between minimal and detailed modes */ async function testOutputFormat() { console.log('šŸ“‹ Testing Output Format Differences\n'); const serverPath = path.join(__dirname, '..', 'dist', 'index.js'); console.log('šŸŽÆ Testing CL_BUS_ABSTRACT_MAIN_SCREEN class...\n'); // Test 1: Minimal mode - only name and type console.log('šŸ“‹ MINIMAL MODE (detailed=false) - Only name and type:'); const minimalResult = await callMcpTool(serverPath, { method: 'tools/call', params: { name: 'GetWhereUsed', arguments: { object_name: 'CL_BUS_ABSTRACT_MAIN_SCREEN', object_type: 'class', detailed: false } } }); if (!minimalResult.error) { const minimalResponse = JSON.parse(minimalResult.content[0].text); console.log(` āœ… Found: ${minimalResponse.total_found}, Showing: ${minimalResponse.total_references}`); console.log(' šŸ“ Sample reference structure:'); if (minimalResponse.references.length > 0) { console.log(' ', JSON.stringify(minimalResponse.references[0], null, 6)); } console.log('\n šŸ” All minimal results:'); minimalResponse.references.forEach((ref, i) => { console.log(` ${i + 1}. ${ref.name} (${ref.type})`); }); } else { console.log(` āŒ Error:`, minimalResult.error); } console.log('\n' + '='.repeat(80) + '\n'); // Test 2: Detailed mode - all fields console.log('šŸ“‹ DETAILED MODE (detailed=true) - All fields:'); const detailedResult = await callMcpTool(serverPath, { method: 'tools/call', params: { name: 'GetWhereUsed', arguments: { object_name: 'CL_BUS_ABSTRACT_MAIN_SCREEN', object_type: 'class', detailed: true } } }); if (!detailedResult.error) { const detailedResponse = JSON.parse(detailedResult.content[0].text); console.log(` āœ… Found: ${detailedResponse.total_found}, Showing: ${detailedResponse.total_references}`); console.log(' šŸ“ Sample reference structure:'); if (detailedResponse.references.length > 0) { console.log(' ', JSON.stringify(detailedResponse.references[0], null, 6)); } console.log('\n šŸ” First 5 detailed results:'); detailedResponse.references.slice(0, 5).forEach((ref, i) => { console.log(` ${i + 1}. ${ref.name} (${ref.type})`); if (ref.uri) console.log(` URI: ${ref.uri.substring(0, 60)}...`); if (ref.usageInformation) console.log(` Usage: ${ref.usageInformation}`); if (ref.isResult !== undefined) console.log(` IsResult: ${ref.isResult}`); }); } else { console.log(` āŒ Error:`, detailedResult.error); } console.log('\nšŸŽÆ FORMAT COMPARISON:'); if (!minimalResult.error && !detailedResult.error) { const minimalResponse = JSON.parse(minimalResult.content[0].text); const detailedResponse = JSON.parse(detailedResult.content[0].text); console.log(' šŸ“Š Minimal mode fields per reference:'); if (minimalResponse.references.length > 0) { const minimalFields = Object.keys(minimalResponse.references[0]); console.log(` - ${minimalFields.join(', ')}`); console.log(` - Total fields: ${minimalFields.length}`); } console.log('\n šŸ“Š Detailed mode fields per reference:'); if (detailedResponse.references.length > 0) { const detailedFields = Object.keys(detailedResponse.references[0]); console.log(` - ${detailedFields.join(', ')}`); console.log(` - Total fields: ${detailedFields.length}`); } console.log('\n šŸŽÆ Benefits:'); console.log(' āœ… Minimal mode: Clean, simple output for quick overview'); console.log(' āœ… Detailed mode: Complete information for thorough analysis'); console.log(' āœ… 90% noise reduction in minimal mode'); console.log(' āœ… Only essential fields (name, type) in minimal mode'); } } /** * Call MCP tool via stdio */ function callMcpTool(serverPath, request) { return new Promise((resolve, reject) => { const child = spawn('node', [serverPath], { stdio: ['pipe', 'pipe', 'pipe'] }); let stdout = ''; let stderr = ''; child.stdout.on('data', (data) => { stdout += data.toString(); }); child.stderr.on('data', (data) => { stderr += data.toString(); }); child.on('close', (code) => { if (code !== 0) { reject(new Error(`Process exited with code ${code}. Stderr: ${stderr}`)); return; } try { const lines = stdout.trim().split('\n'); let result = null; for (const line of lines) { try { const parsed = JSON.parse(line); if (parsed.result) { result = parsed.result; break; } } catch (e) { // Skip non-JSON lines } } if (result) { resolve(result); } else { reject(new Error('No valid result found in output')); } } catch (error) { reject(new Error(`Failed to parse output: ${error.message}`)); } }); const jsonRpcRequest = { jsonrpc: '2.0', id: 1, ...request }; child.stdin.write(JSON.stringify(jsonRpcRequest) + '\n'); child.stdin.end(); }); } // Run the test testOutputFormat().catch(console.error);

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/fr0ster/mcp-abap-adt'

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