Skip to main content
Glama

MCP Smart Filesystem Server

by lofcz
test-manual.js•2.51 kB
/** * Manual test script for MCP filesystem server * Run: node test-manual.js */ import { spawn } from 'child_process'; import readline from 'readline'; // Start the server const server = spawn('node', [ 'dist/index.js', process.cwd() // Allow access to current directory ]); let messageId = 1; // Handle server output server.stdout.on('data', (data) => { console.log('\nšŸ“„ SERVER RESPONSE:'); console.log(data.toString()); }); server.stderr.on('data', (data) => { console.log('šŸ”§ SERVER LOG:', data.toString().trim()); }); server.on('close', (code) => { console.log(`\nāŒ Server exited with code ${code}`); process.exit(code); }); // Send a request function sendRequest(method, params = {}) { const request = { jsonrpc: '2.0', id: messageId++, method: method, params: params }; console.log('\nšŸ“¤ SENDING REQUEST:'); console.log(JSON.stringify(request, null, 2)); server.stdin.write(JSON.stringify(request) + '\n'); } // Wait a moment for server to initialize setTimeout(() => { console.log('\n=== MCP Filesystem Server Test ===\n'); // Test 1: Initialize console.log('\n--- Test 1: Initialize ---'); sendRequest('initialize', { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'test-client', version: '1.0.0' } }); setTimeout(() => { // Test 2: List tools console.log('\n--- Test 2: List Tools ---'); sendRequest('tools/list'); }, 1000); setTimeout(() => { // Test 3: List allowed directories console.log('\n--- Test 3: List Allowed Directories ---'); sendRequest('tools/call', { name: 'list_allowed_directories', arguments: {} }); }, 2000); setTimeout(() => { // Test 4: List current directory console.log('\n--- Test 4: List Current Directory ---'); sendRequest('tools/call', { name: 'list_directory', arguments: { path: '.' } }); }, 3000); setTimeout(() => { // Test 5: Get file info console.log('\n--- Test 5: Get File Info (package.json) ---'); sendRequest('tools/call', { name: 'get_file_info', arguments: { path: 'package.json' } }); }, 4000); setTimeout(() => { console.log('\n\n=== Tests Complete ==='); console.log('Press Ctrl+C to exit\n'); }, 5000); }, 500); // Handle graceful shutdown process.on('SIGINT', () => { console.log('\n\nšŸ‘‹ Shutting down...'); server.kill(); process.exit(0); });

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/lofcz/mcp-filesystem-smart'

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