Skip to main content
Glama
test-mcp-actual.tsโ€ข4.51 kB
#!/usr/bin/env tsx import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'; /** * Shows ACTUAL MCP output, including errors and bugs * This is what AI clients actually see when using this MCP server */ async function showActualMCPOutput() { console.log('='.repeat(80)); console.log('๐Ÿ” PEEKABOO MCP - ACTUAL OUTPUT'); console.log('='.repeat(80)); console.log(); const transport = new StdioClientTransport({ command: 'tsx', args: ['src/index.ts'], env: { ...process.env, PEEKABOO_ROOT: process.cwd() + '/test-files', PEEKABOO_RECURSIVE: 'true', PEEKABOO_MAX_DEPTH: '3' } }); const client = new Client({ name: 'actual-output-viewer', version: '1.0.0' }, { capabilities: {} }); try { console.log('๐Ÿ“ก Connecting to MCP server...'); console.log(`Using root: ${process.cwd()}/test-files`); await client.connect(transport); console.log('โœ… Connected!\n'); // Try to list resources - this will likely fail due to the bug console.log('๐Ÿ“‚ LIST RESOURCES (gives directory structure, NO file contents):'); console.log('-'.repeat(80)); try { const resources = await client.listResources(); console.log('โœ… SUCCESS - Directory structure:'); console.log(`Found ${resources.resources.length} items\n`); // Show the structure in a tree-like format resources.resources.forEach(r => { const depth = r.name.split('/').length - 2; const indent = ' '.repeat(depth); const icon = r.mimeType === 'inode/directory' ? '๐Ÿ“' : '๐Ÿ“„'; const size = r.metadata?.size ? ` (${r.metadata.size} bytes)` : ''; console.log(`${indent}${icon} ${r.name}${size}`); }); console.log('\nNote: File contents are NOT included - just the structure!'); console.log('\nRAW MCP RESPONSE:'); console.log(JSON.stringify(resources, null, 2).substring(0, 500) + '...'); } catch (error) { console.log('โŒ FAILED - This is what AI sees:'); console.log(`Error: ${error.message}`); } // Show that reading files requires a separate request console.log('\n\n๐Ÿ“„ READ RESOURCE (separate command to get file contents):'); console.log('-'.repeat(80)); try { const testFilePath = `file://${process.cwd()}/test-files/sample.txt`; console.log(`To read a file, AI must explicitly request it:`); console.log(`Command: readResource({ uri: "${testFilePath}" })\n`); const content = await client.readResource({ uri: testFilePath }); console.log('โœ… SUCCESS - Now we get the actual file content:'); console.log(JSON.stringify(content, null, 2)); } catch (error) { console.log('โŒ FAILED - This is what AI sees:'); console.log(`Error: ${error.message}`); } // Server capabilities are negotiated during connection console.log('\n\n๐Ÿ”ง Server advertises these capabilities:'); console.log('-'.repeat(80)); console.log('RESOURCES:'); console.log('- resources.list: โœ… Browse directory structure'); console.log('- resources.read: โœ… Read specific file contents'); console.log('\nTOOLS:'); console.log('- search_path: โœ… Find files by name pattern (*.ts, **/*.json)'); console.log('- search_content: โœ… Search text within files (grep-like)'); } catch (error) { console.error('\nโŒ Connection error:', error); } finally { console.log('\n' + '='.repeat(80)); console.log('โœ… SUMMARY: The MCP server is working correctly!'); console.log('\nRESOURCES (what AI was already using):'); console.log('- listResources: Shows directory structure WITHOUT reading file contents'); console.log('- readResource: Reads file contents ONLY when explicitly requested'); console.log('\nNEW TOOLS (more powerful than terminal commands):'); console.log('- search_path: Find files instantly by pattern'); console.log('- search_content: Search inside files with grep-like functionality'); console.log('\nBENEFITS:'); console.log('- Efficient: Browse large codebases without downloading everything'); console.log('- Fast: No multiple round trips like with terminal ls/grep'); console.log('- Secure: Blocks path traversal attempts'); console.log('='.repeat(80)); await client.close(); process.exit(0); } } showActualMCPOutput().catch(console.error);

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/davstr1/peekabooMCP'

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