Skip to main content
Glama

GitHub Repos Manager MCP Server

test-all-tools.js16.5 kB
#!/usr/bin/env node /** * Comprehensive Test Suite for GitHub MCP Server * Tests all tools to ensure they are properly implemented and accessible */ const toolsConfig = require("./src/utils/tools-config.cjs"); class GitHubMCPTester { constructor() { this.testResults = []; this.totalTests = 0; this.passedTests = 0; this.failedTests = 0; } log(message, type = "info") { const symbols = { info: "ℹ️", success: "✅", error: "❌", warning: "⚠️", test: "🧪", }; console.log(`${symbols[type]} ${message}`); } async testToolDefinition(toolName) { this.totalTests++; try { const tool = toolsConfig[toolName]; if (!tool) { this.failedTests++; this.log( `Tool '${toolName}' not found in tools configuration`, "error" ); return false; } if (!tool.name || tool.name !== toolName) { this.failedTests++; this.log( `Tool '${toolName}' has incorrect name property: expected '${toolName}', got '${tool.name}'`, "error" ); return false; } if (!tool.description) { this.failedTests++; this.log(`Tool '${toolName}' missing description`, "error"); return false; } if (!tool.inputSchema) { this.failedTests++; this.log(`Tool '${toolName}' missing input schema`, "error"); return false; } this.passedTests++; this.log(`Tool '${toolName}' definition is valid`, "success"); return true; } catch (error) { this.failedTests++; this.log( `Error testing tool definition '${toolName}': ${error.message}`, "error" ); return false; } } async testHandlerMethod(toolName, expectedMethodName) { this.totalTests++; try { if (toolName === "set_default_repo") { this.log( `Skipping handler method check for server-level tool '${toolName}'`, "info" ); this.passedTests++; return true; } let handlerModulePath; if ( [ "list_repos", "get_repo_info", "search_repos", "get_repo_contents", "list_repo_collaborators", ].includes(toolName) ) { handlerModulePath = "./src/handlers/repository.cjs"; } else if ( [ "list_issues", "create_issue", "edit_issue", "get_issue_details", "lock_issue", "unlock_issue", "add_assignees_to_issue", "remove_assignees_from_issue", ].includes(toolName) ) { handlerModulePath = "./src/handlers/issues.cjs"; } else if ( [ "list_issue_comments", "create_issue_comment", "edit_issue_comment", "delete_issue_comment", ].includes(toolName) ) { handlerModulePath = "./src/handlers/comments.cjs"; } else if (toolName === "list_prs") { handlerModulePath = "./src/handlers/pull-requests.cjs"; } else if (toolName === "get_user_info") { handlerModulePath = "./src/handlers/users.cjs"; } else if ( [ "list_repo_labels", "create_label", "edit_label", "delete_label", ].includes(toolName) ) { handlerModulePath = "./src/handlers/labels.cjs"; } else if ( [ "list_milestones", "create_milestone", "edit_milestone", "delete_milestone", ].includes(toolName) ) { handlerModulePath = "./src/handlers/milestones.cjs"; } else if ( [ "list_branches", "create_branch", "list_commits", "get_commit_details", "compare_commits", ].includes(toolName) ) { handlerModulePath = "./src/handlers/branches-commits.cjs"; } else if ( [ "create_pull_request", "edit_pull_request", "get_pr_details", "list_pr_reviews", "create_pr_review", "list_pr_files", ].includes(toolName) ) { handlerModulePath = "./src/handlers/enhanced-pull-requests.cjs"; } else if ( ["create_file", "update_file", "upload_file", "delete_file"].includes( toolName ) ) { handlerModulePath = "./src/handlers/file-management.cjs"; } else if ( [ "list_deploy_keys", "create_deploy_key", "delete_deploy_key", "list_webhooks", "create_webhook", "edit_webhook", "delete_webhook", "list_secrets", "update_secret", ].includes(toolName) ) { handlerModulePath = "./src/handlers/security.cjs"; } else if ( [ "list_workflows", "list_workflow_runs", "get_workflow_run_details", "trigger_workflow", "download_workflow_artifacts", "cancel_workflow_run", ].includes(toolName) ) { handlerModulePath = "./src/handlers/workflows.cjs"; } else if ( [ "get_repo_stats", "list_repo_topics", "update_repo_topics", "get_repo_languages", "list_stargazers", "list_watchers", "list_forks", "get_repo_traffic", ].includes(toolName) ) { handlerModulePath = "./src/handlers/analytics.cjs"; } else if ( [ "search_issues", "search_commits", "search_code", "search_users", "search_topics", ].includes(toolName) ) { handlerModulePath = "./src/handlers/search.cjs"; } else if ( [ "list_org_repos", "list_org_members", "get_org_info", "list_org_teams", "get_team_members", "manage_team_repos", ].includes(toolName) ) { handlerModulePath = "./src/handlers/organizations.cjs"; } else if ( [ "list_repo_projects", "create_project", "list_project_columns", "list_project_cards", "create_project_card", "move_project_card", ].includes(toolName) ) { handlerModulePath = "./src/handlers/projects.cjs"; } else if ( [ "code_quality_checks", "custom_dashboards", "automated_reporting", "notification_management", "release_management", "dependency_analysis", ].includes(toolName) ) { handlerModulePath = "./src/handlers/advanced-features.cjs"; } if (!handlerModulePath) { this.failedTests++; this.log( `No handler module path determined for tool '${toolName}'`, "error" ); return false; } let handlerModule; try { handlerModule = require(handlerModulePath); } catch (e) { this.failedTests++; this.log( `Failed to require handler module '${handlerModulePath}' for tool '${toolName}': ${e.message}`, "error" ); return false; } if (typeof handlerModule[expectedMethodName] !== "function") { this.failedTests++; this.log( `Method '${expectedMethodName}' not found in handler module ${handlerModulePath} for tool '${toolName}'`, "error" ); return false; } this.passedTests++; this.log( `Handler method '${expectedMethodName}' exists for tool '${toolName}' in ${handlerModulePath}`, "success" ); return true; } catch (error) { this.failedTests++; this.log( `Error testing handler for '${toolName}': ${error.message}`, "error" ); return false; } } // testSwitchCase is removed as it's unreliable and its core purpose is covered by other tests. async runAllTests() { this.log("Starting comprehensive GitHub MCP Server test suite", "test"); console.log("=".repeat(60)); this.log("\n📋 Phase 1: Testing Tool Definitions", "info"); const toolsToTest = [ // Repository Management { name: "list_repos", method: "listRepos" }, { name: "get_repo_info", method: "getRepoInfo" }, { name: "search_repos", method: "searchRepos" }, { name: "get_repo_contents", method: "getRepoContents" }, { name: "set_default_repo", method: "setDefaultRepo" }, { name: "list_repo_collaborators", method: "listRepoCollaborators" }, // Issue Management { name: "list_issues", method: "listIssues" }, { name: "create_issue", method: "createIssue" }, { name: "edit_issue", method: "editIssue" }, { name: "get_issue_details", method: "getIssueDetails" }, { name: "lock_issue", method: "lockIssue" }, { name: "unlock_issue", method: "unlockIssue" }, { name: "add_assignees_to_issue", method: "addAssigneesToIssue" }, { name: "remove_assignees_from_issue", method: "removeAssigneesFromIssue", }, // Comments { name: "list_issue_comments", method: "listIssueComments" }, { name: "create_issue_comment", method: "createIssueComment" }, { name: "edit_issue_comment", method: "editIssueComment" }, { name: "delete_issue_comment", method: "deleteIssueComment" }, // Pull Requests { name: "list_prs", method: "listPRs" }, // Enhanced Pull Requests { name: "create_pull_request", method: "create_pull_request" }, { name: "edit_pull_request", method: "edit_pull_request" }, { name: "get_pr_details", method: "get_pr_details" }, { name: "list_pr_reviews", method: "list_pr_reviews" }, { name: "create_pr_review", method: "create_pr_review" }, { name: "list_pr_files", method: "list_pr_files" }, // Users { name: "get_user_info", method: "getUserInfo" }, // Labels { name: "list_repo_labels", method: "listRepoLabels" }, // Corrected { name: "create_label", method: "createLabel" }, // Corrected { name: "edit_label", method: "editLabel" }, // Corrected { name: "delete_label", method: "deleteLabel" }, // Corrected // Milestones { name: "list_milestones", method: "listMilestones" }, { name: "create_milestone", method: "createMilestone" }, { name: "edit_milestone", method: "editMilestone" }, { name: "delete_milestone", method: "deleteMilestone" }, // Branch and Commit Management { name: "list_branches", method: "listBranches" }, { name: "create_branch", method: "createBranch" }, { name: "list_commits", method: "listCommits" }, { name: "get_commit_details", method: "getCommitDetails" }, { name: "compare_commits", method: "compareCommits" }, // File & Content Management { name: "create_file", method: "createFileHandler" }, { name: "update_file", method: "updateFileHandler" }, { name: "upload_file", method: "uploadFileHandler" }, { name: "delete_file", method: "deleteFileHandler" }, // Security & Access Management { name: "list_deploy_keys", method: "list_deploy_keys" }, { name: "create_deploy_key", method: "create_deploy_key" }, { name: "delete_deploy_key", method: "delete_deploy_key" }, { name: "list_webhooks", method: "list_webhooks" }, { name: "create_webhook", method: "create_webhook" }, { name: "edit_webhook", method: "edit_webhook" }, { name: "delete_webhook", method: "delete_webhook" }, { name: "list_secrets", method: "list_secrets" }, { name: "update_secret", method: "update_secret" }, // GitHub Actions & Workflows { name: "list_workflows", method: "list_workflows" }, { name: "list_workflow_runs", method: "list_workflow_runs" }, { name: "get_workflow_run_details", method: "get_workflow_run_details" }, { name: "trigger_workflow", method: "trigger_workflow" }, { name: "download_workflow_artifacts", method: "download_workflow_artifacts", }, { name: "cancel_workflow_run", method: "cancel_workflow_run" }, // Repository Analytics & Insights { name: "get_repo_stats", method: "get_repo_stats" }, { name: "list_repo_topics", method: "list_repo_topics" }, { name: "update_repo_topics", method: "update_repo_topics" }, { name: "get_repo_languages", method: "get_repo_languages" }, { name: "list_stargazers", method: "list_stargazers" }, { name: "list_watchers", method: "list_watchers" }, { name: "list_forks", method: "list_forks" }, { name: "get_repo_traffic", method: "get_repo_traffic" }, // Advanced Search & Discovery { name: "search_issues", method: "search_issues" }, { name: "search_commits", method: "search_commits" }, { name: "search_code", method: "search_code" }, { name: "search_users", method: "search_users" }, { name: "search_topics", method: "search_topics" }, // Organization Management { name: "list_org_repos", method: "listOrgRepos" }, { name: "list_org_members", method: "listOrgMembers" }, { name: "get_org_info", method: "getOrgInfo" }, { name: "list_org_teams", method: "listOrgTeams" }, { name: "get_team_members", method: "getTeamMembers" }, { name: "manage_team_repos", method: "manageTeamRepos" }, // Projects & Boards { name: "list_repo_projects", method: "list_repo_projects" }, { name: "create_project", method: "create_project" }, { name: "list_project_columns", method: "list_project_columns" }, { name: "list_project_cards", method: "list_project_cards" }, { name: "create_project_card", method: "create_project_card" }, { name: "move_project_card", method: "move_project_card" }, // Advanced Features { name: "code_quality_checks", method: "handleCodeQualityChecks" }, { name: "custom_dashboards", method: "handleCustomDashboards" }, { name: "automated_reporting", method: "handleAutomatedReporting" }, { name: "notification_management", method: "handleNotificationManagement", }, { name: "release_management", method: "handleReleaseManagement" }, { name: "dependency_analysis", method: "handleDependencyAnalysis" }, ]; for (const tool of toolsToTest) { await this.testToolDefinition(tool.name); } this.log("\n🔧 Phase 2: Testing Handler Methods", "info"); for (const tool of toolsToTest) { await this.testHandlerMethod(tool.name, tool.method); } // Phase 3 (Tool Invocation / Switch Case) is removed for now. // this.log("\n🔌 Phase 3: Testing Server Switch Cases (Tool Invocation)", "info"); // for (const tool of toolsToTest) { // if (tool.name !== "set_default_repo") { // await this.testSwitchCase(tool.name); // } else { // this.log(`Skipping invocation test for server-level tool '${tool.name}'`, "info"); // } // } this.printResults(); } printResults() { console.log("\n" + "=".repeat(60)); this.log("Test Suite Complete!", "test"); console.log("\n" + "=".repeat(60)); this.log(`Total Tests: ${this.totalTests}`, "info"); this.log(`Passed: ${this.passedTests}`, "success"); this.log(`Failed: ${this.failedTests}`, "error"); const successRate = this.totalTests > 0 ? ((this.passedTests / this.totalTests) * 100).toFixed(2) : "N/A"; this.log( `Success Rate: ${successRate}%`, this.failedTests === 0 ? "success" : "warning" ); if (this.failedTests > 0) { this.log( `\n⚠️ ${this.failedTests} test(s) failed. Check the errors above.`, "warning" ); } console.log("=".repeat(60)); } } async function main() { if (!process.env.GH_TOKEN) { console.warn( "⚠️ GH_TOKEN not set, tests requiring authentication might fail or be skipped by server logic. Using a dummy token for structural tests." ); process.env.GH_TOKEN = "dummy_token_for_structural_tests"; } const tester = new GitHubMCPTester(); await tester.runAllTests(); if (tester.failedTests > 0) { process.exit(1); } } main().catch((error) => { console.error("Unhandled error in test suite:", error); process.exit(1); });

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/kurdin/github-repos-manager-mcp'

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