Skip to main content
Glama
Om-Shree-0709

GitHub MCP TypeScript SDK Server

interactive-test.js3.31 kB
#!/usr/bin/env node /** * Interactive test to demonstrate a GitHub MCP tool in action */ import { config } from "dotenv"; import { spawn } from "child_process"; import { fileURLToPath } from "url"; import { dirname, join } from "path"; // Load environment variables config(); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); console.log("🎮 Interactive GitHub MCP Tool Test\n"); if (!process.env.GITHUB_TOKEN) { console.error("❌ GITHUB_TOKEN is required!"); console.log("Please run: npm run setup"); process.exit(1); } // Start the server const serverPath = join(__dirname, "dist", "server.js"); const server = spawn("node", [serverPath], { stdio: ["pipe", "pipe", "pipe"], }); console.log("🚀 Server started, testing get_my_info tool...\n"); // Send MCP initialization const initMessage = { jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: "2024-11-05", capabilities: { tools: {}, }, clientInfo: { name: "interactive-test", version: "1.0.0", }, }, }; // Send tool call for get_my_info const toolMessage = { jsonrpc: "2.0", id: 2, method: "tools/call", params: { name: "get_my_info", arguments: {}, }, }; let initComplete = false; let toolResponseReceived = false; server.stdout.on("data", (data) => { const output = data.toString(); // Skip the startup messages if ( output.includes("GitHub MCP Server is running") || output.includes("Available tools") || output.includes("Available resources") || output.includes("Available prompts") ) { return; } try { const response = JSON.parse(output.trim()); if (response.id === 1) { console.log("✅ Server initialized successfully!"); console.log( "📋 Server info:", response.result.serverInfo.name, response.result.serverInfo.version ); initComplete = true; // Send tool call after init setTimeout(() => { console.log("\n🔧 Calling get_my_info tool..."); server.stdin.write(JSON.stringify(toolMessage) + "\n"); }, 500); } if (response.id === 2) { console.log("\n🎯 Tool Response:"); if (response.result && response.result.content) { response.result.content.forEach((item) => { if (item.type === "text") { console.log("\n" + item.text); } }); } toolResponseReceived = true; setTimeout(() => { console.log("\n✅ Test completed successfully!"); console.log("🎉 Your GitHub MCP Server is working perfectly!"); server.kill(); }, 1000); } } catch (e) { // Ignore non-JSON output } }); server.stderr.on("data", (data) => { console.error("❌ Server error:", data.toString()); }); server.on("close", (code) => { if (code !== 0) { console.error(`❌ Server exited with code ${code}`); } }); // Send initialization message setTimeout(() => { console.log("📡 Initializing MCP connection..."); server.stdin.write(JSON.stringify(initMessage) + "\n"); }, 1000); // Timeout after 10 seconds setTimeout(() => { if (!toolResponseReceived) { console.log("\n⏰ Test timeout"); server.kill(); process.exit(1); } }, 10000);

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/Om-Shree-0709/Github-MCP-Ts-SDK'

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