#!/usr/bin/env node
/**
* Demo script showing how to use all GitHub MCP tools
* This demonstrates the actual JSON-RPC calls to the server
*/
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("🎯 GitHub MCP Server - Tool Demo\n");
// Check if server is available
if (!process.env.GITHUB_TOKEN) {
console.error("❌ GITHUB_TOKEN is required!");
console.log("Please run: npm run setup");
process.exit(1);
}
// Demo tools with example calls
const demoTools = [
{
name: "get_my_info",
description: "Get your GitHub profile information",
example: { tool: "get_my_info", arguments: {} },
},
{
name: "get_repo_info",
description: "Get repository details",
example: {
tool: "get_repo_info",
arguments: { owner: "microsoft", repo: "vscode" },
},
},
{
name: "search_repositories",
description: "Search for repositories",
example: {
tool: "search_repositories",
arguments: { query: "language:typescript stars:>1000", limit: 5 },
},
},
{
name: "list_repo_issues",
description: "List repository issues",
example: {
tool: "list_repo_issues",
arguments: { owner: "facebook", repo: "react", state: "open" },
},
},
{
name: "get_github_stats",
description: "Get user statistics",
example: { tool: "get_github_stats", arguments: { username: "octocat" } },
},
];
console.log("📋 Available GitHub MCP Tools:\n");
demoTools.forEach((tool, index) => {
console.log(`${index + 1}. 🛠️ **${tool.name}**`);
console.log(` Description: ${tool.description}`);
console.log(` Example usage:`);
console.log(` \`\`\`json`);
console.log(` ${JSON.stringify(tool.example, null, 2)}`);
console.log(` \`\`\`\n`);
});
console.log("🔧 How to Use These Tools:\n");
console.log("### Method 1: With Claude Desktop");
console.log("1. Add your server to Claude Desktop configuration");
console.log(
"2. Ask Claude: 'Show me information about the VS Code repository'"
);
console.log("3. Claude will automatically use the appropriate tool\n");
console.log("### Method 2: Direct JSON-RPC Calls");
console.log("Send JSON-RPC requests to your running server:\n");
console.log("```json");
console.log(
JSON.stringify(
{
jsonrpc: "2.0",
id: 1,
method: "tools/call",
params: {
name: "get_repo_info",
arguments: {
owner: "microsoft",
repo: "vscode",
},
},
},
null,
2
)
);
console.log("```\n");
console.log("### Method 3: Natural Language Queries");
console.log("Use the github_query prompt for natural language requests:\n");
console.log("```json");
console.log(
JSON.stringify(
{
jsonrpc: "2.0",
id: 1,
method: "prompts/call",
params: {
name: "github_query",
arguments: {
query: "Show me my most starred repositories",
},
},
},
null,
2
)
);
console.log("```\n");
console.log("### Method 4: Resource Access");
console.log("Access GitHub data as resources:\n");
console.log("Repository resource: github://repository/microsoft/vscode");
console.log("User resource: github://user/octocat\n");
console.log("🎯 Practical Examples:\n");
console.log("1. **Research a Repository:**");
console.log(" - Get basic info: get_repo_info");
console.log(" - Check issues: list_repo_issues");
console.log(" - See recent changes: list_repo_commits\n");
console.log("2. **Find New Projects:**");
console.log(
" - Search by language: search_repositories with 'language:python'"
);
console.log(" - Filter by stars: 'stars:>1000'");
console.log(" - Recent projects: 'created:>2023-01-01'\n");
console.log("3. **Analyze Users:**");
console.log(" - Get profile: get_user_info");
console.log(" - See repositories: list_user_repos");
console.log(" - View stats: get_github_stats\n");
console.log("4. **Your Own Data:**");
console.log(" - Your profile: get_my_info");
console.log(" - Your repos: get_my_repos");
console.log(" - Your stats: get_github_stats with your username\n");
console.log(
"🚀 Your server is ready! Start using these tools with any MCP client.\n"
);
console.log("📖 For detailed examples, see TOOL_EXAMPLES.md");
console.log("📚 For setup instructions, see README.md");
console.log("🛠️ For usage guide, see USAGE.md");