Skip to main content
Glama

vulcan-file-ops

mcp-tools.test.js8.2 kB
#!/usr/bin/env node import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; import fs from "fs"; import path from "path"; async function testAllTools() { console.log("🧪 Testing ALL Vulcan File Ops MCP Tools"); console.log("=".repeat(50)); // Create MCP client transport const transport = new StdioClientTransport({ command: "node", args: ["dist/cli.js"], }); const client = new Client( { name: "test-client", version: "1.0.0", }, { capabilities: {}, } ); try { // Connect and initialize await client.connect(transport); console.log("✅ Connected to MCP server"); // Test directory for operations - use a temporary directory relative to project root const testDir = path.join(process.cwd(), "test-workspace", "mcp-test-" + Date.now()); // Create the test directory first console.log("\n📁 0. Creating test directory..."); try { fs.mkdirSync(testDir, { recursive: true }); console.log("✅ Test directory created:", testDir); } catch (error) { console.log("❌ Failed to create test directory:", error.message); return; } // 1. Register the test directory console.log("\n📁 1. Registering test directory..."); try { const registerResult = await client.callTool({ name: "register_directory", arguments: { path: testDir }, }); console.log("✅ Directory registered:", registerResult.content[0].text); } catch (error) { console.log("❌ Directory registration failed:", error.message); return; } // 2. List allowed directories console.log("\n📋 2. Listing allowed directories..."); const listAllowedResult = await client.callTool({ name: "list_allowed_directories", arguments: {}, }); console.log("✅ Allowed directories:", listAllowedResult.content[0].text); // 3. List directory contents console.log("\n📂 3. Listing directory contents..."); const listDirResult = await client.callTool({ name: "list_directory", arguments: { path: testDir }, }); console.log("✅ Directory listing:", listDirResult.content[0].text); // 4. Create a test file console.log("\n📝 4. Creating test file..."); const testFile = path.join(testDir, "test-file.txt"); const createFileResult = await client.callTool({ name: "write_file", arguments: { path: testFile, content: "This is a test file created by MCP tools!\nLine 2\nLine 3", }, }); console.log("✅ File created:", createFileResult.content[0].text); // 5. Read the file console.log("\n📖 5. Reading file..."); const readTextResult = await client.callTool({ name: "read_file", arguments: { path: testFile }, }); console.log( "✅ File content:", readTextResult.content[0].text.substring(0, 50) + "..." ); // 6. Read first 2 lines console.log("\n📖 6. Reading first 2 lines..."); const readHeadResult = await client.callTool({ name: "read_file", arguments: { path: testFile, mode: "head", lines: 2 }, }); console.log("✅ First 2 lines:", readHeadResult.content[0].text); // 7. Read last line console.log("\n📖 7. Reading last line..."); const readTailResult = await client.callTool({ name: "read_file", arguments: { path: testFile, mode: "tail", lines: 1 }, }); console.log("✅ Last line:", readTailResult.content[0].text); // 8. Get file info console.log("\nℹ️ 8. Getting file info..."); const fileInfoResult = await client.callTool({ name: "get_file_info", arguments: { path: testFile }, }); console.log("✅ File info:", fileInfoResult.content[0].text); // 9. List directory with sizes (using unified list_directory) console.log("\n📊 9. Listing directory with sizes..."); const listWithSizesResult = await client.callTool({ name: "list_directory", arguments: { path: testDir, format: "detailed", sortBy: "size" }, }); console.log( "✅ Directory with sizes:", listWithSizesResult.content[0].text ); // 10. Create a subdirectory console.log("\n📁 10. Creating subdirectory..."); const subDir = path.join(testDir, "test-subdir"); const createDirResult = await client.callTool({ name: "make_directory", arguments: { paths: subDir }, }); console.log("✅ Directory created:", createDirResult.content[0].text); // 10b. Create multiple directories at once (new batch feature) console.log("\n📁 10b. Creating multiple directories (batch)..."); const batchDirs = [ path.join(testDir, "batch-test-1"), path.join(testDir, "batch-test-2"), path.join(testDir, "nested", "batch-test-3"), ]; const batchResult = await client.callTool({ name: "make_directory", arguments: { paths: batchDirs }, }); console.log("✅ Batch directories created:", batchResult.content[0].text); // 11. Move file to subdirectory console.log("\n📦 11. Moving file to subdirectory..."); const movedFile = path.join(subDir, "moved-file.txt"); const moveResult = await client.callTool({ name: "move_file", arguments: { source: testFile, destination: movedFile, }, }); console.log("✅ File moved:", moveResult.content[0].text); // 12. Edit the moved file console.log("\n✏️ 12. Editing the moved file..."); const editResult = await client.callTool({ name: "edit_file", arguments: { path: movedFile, edits: [ { oldText: "This is a test file created by MCP tools!", newText: "This is an EDITED test file created by MCP tools!", }, ], dryRun: false, }, }); console.log("✅ File edited (check diff output)"); // 13. Search for files using glob console.log("\n🔍 13. Searching for files..."); const searchResult = await client.callTool({ name: "glob_files", arguments: { path: testDir, pattern: "**/*.txt", }, }); console.log("✅ Search results:", searchResult.content[0].text); // 14. Get directory tree (using unified list_directory with tree format) console.log("\n🌳 14. Getting directory tree..."); const treeResult = await client.callTool({ name: "list_directory", arguments: { path: testDir, format: "tree" }, }); console.log("✅ Directory tree (text):", treeResult.content[0].text); // 14b. Get directory structure as JSON (new format option) console.log("\n📊 14b. Getting directory as JSON..."); const jsonResult = await client.callTool({ name: "list_directory", arguments: { path: testDir, format: "json" }, }); const jsonData = JSON.parse(jsonResult.content[0].text); console.log( "✅ Directory JSON:", `Found ${jsonData.summary.totalFiles} files and ${jsonData.summary.totalDirectories} directories` ); // 15. Read multiple files console.log("\n📚 15. Reading multiple files..."); const multiReadResult = await client.callTool({ name: "read_multiple_files", arguments: { paths: [movedFile], }, }); console.log( "✅ Multiple files read:", multiReadResult.content[0].text.substring(0, 100) + "..." ); console.log("\n🎉 ALL TOOLS TESTED SUCCESSFULLY!"); console.log("✅ Vulcan File Ops MCP Server is working perfectly!"); console.log("\n📁 Test directory:", testDir); console.log("🧹 Cleaning up test directory..."); // Clean up test directory try { fs.rmSync(testDir, { recursive: true, force: true }); console.log("✅ Test directory cleaned up"); } catch (error) { console.log("⚠️ Failed to clean up test directory:", error.message); } } catch (error) { console.error("❌ Test failed:", error); console.error("Stack:", error.stack); } finally { client.close(); } } testAllTools();

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/n0zer0d4y/vulcan-file-ops'

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