Skip to main content
Glama
Om-Shree-0709

GitHub MCP TypeScript SDK Server

README.mdβ€’12.3 kB
# GitHub MCP TypeScript SDK Server A comprehensive Model Context Protocol (MCP) server for GitHub that provides access to repositories, issues, pull requests, commits, and user information through a standardized interface. Built with TypeScript and the official MCP SDK. ## πŸš€ Features ### πŸ“‹ Available Tools (10 Total) - **`get_my_info`** - Get information about the authenticated GitHub user - **`get_repo_info`** - Get detailed information about a GitHub repository - **`list_repo_issues`** - List issues in a repository (with state filtering) - **`list_repo_prs`** - List pull requests in a repository - **`list_repo_commits`** - List recent commits in a repository - **`search_repositories`** - Search for repositories on GitHub - **`get_user_info`** - Get information about any GitHub user - **`list_user_repos`** - List repositories belonging to a user - **`get_my_repos`** - List repositories belonging to the authenticated user - **`get_github_stats`** - Get comprehensive GitHub statistics for a user ### πŸ”§ Capabilities - βœ… **Repository Information** - Name, description, stars, forks, language, visibility - βœ… **Issue Management** - List, filter, and view issue details - βœ… **Pull Request Tracking** - View PR status, authors, and details - βœ… **Commit History** - Browse recent commits with author and message info - βœ… **User Profiles** - Access user information and statistics - βœ… **Repository Search** - Advanced search with filters and sorting - βœ… **Statistics & Analytics** - Comprehensive user and repository metrics - βœ… **Error Handling** - Robust error handling with descriptive messages - βœ… **Natural Language Queries** - Ask questions in plain English ## πŸ“¦ Installation ### Prerequisites - Node.js 18+ - npm or yarn - GitHub Personal Access Token ### Setup 1. **Clone the repository:** ```bash git clone <your-repo-url> cd github-mcp-ts-sdk ``` 2. **Install dependencies:** ```bash npm install ``` 3. **Set up environment variables:** ```bash cp env.example .env # Edit .env and add your GitHub token ``` 4. **Build the project:** ```bash npm run build ``` ## πŸ”‘ GitHub Token Setup 1. Go to [GitHub Settings > Personal Access Tokens](https://github.com/settings/tokens) 2. Click "Generate new token (classic)" 3. Select the following scopes: - `repo` (Full control of private repositories) - `user` (Read all user profile data) - `read:org` (Read org and team membership) 4. Copy the generated token and add it to your `.env` file: ```env GITHUB_TOKEN=your_github_token_here GITHUB_USERNAME=your_username_here # Optional ``` ## πŸš€ Usage ### Development Mode ```bash npm run dev ``` ### Production Mode ```bash npm run build npm start ``` ### Watch Mode (for development) ```bash npm run build:watch ``` ### Test the Server ```bash npm test npm run simple-test npm run interactive-test npm run demo ``` ## πŸ›  Tool Examples ### User Information #### Get Your GitHub Profile ```json { "tool": "get_my_info", "arguments": {} } ``` **Response:** ``` πŸ‘€ **My GitHub Profile** **Username:** Om-Shree-0709 **Name:** Om Shree **Bio:** Full Stack Developer **Followers:** 25 **Following:** 50 **Public Repositories:** 15 **Profile URL:** https://github.com/Om-Shree-0709 ``` #### Get User Information ```json { "tool": "get_user_info", "arguments": { "username": "microsoft" } } ``` ### Repository Information #### Get Repository Details ```json { "tool": "get_repo_info", "arguments": { "owner": "microsoft", "repo": "vscode" } } ``` **Response:** ``` πŸ“ **Repository: microsoft/vscode** **Description:** Visual Studio Code **Language:** TypeScript **Visibility:** public **Stars:** ⭐ 150000 **Forks:** 🍴 25000 **Watchers:** πŸ‘€ 5000 **Created:** 1/1/2015 **Updated:** 12/15/2024 **URL:** https://github.com/microsoft/vscode ``` #### Search Repositories ```json { "tool": "search_repositories", "arguments": { "query": "language:typescript stars:>1000", "limit": 10 } } ``` **Advanced search examples:** - `language:javascript` - Search by programming language - `stars:>5000` - Filter by minimum stars - `user:octocat` - Search within a specific user's repositories - `language:python stars:>1000 forks:>100` - Combined filters - `created:>2023-01-01` - Filter by creation date - `topic:react` - Search by topic tags ### Issues and Pull Requests #### List Repository Issues ```json { "tool": "list_repo_issues", "arguments": { "owner": "facebook", "repo": "react", "state": "open" } } ``` #### List Pull Requests ```json { "tool": "list_repo_prs", "arguments": { "owner": "microsoft", "repo": "vscode", "state": "open" } } ``` ### Commit History #### List Recent Commits ```json { "tool": "list_repo_commits", "arguments": { "owner": "nodejs", "repo": "node", "limit": 20 } } ``` ### Statistics #### Get User Statistics ```json { "tool": "get_github_stats", "arguments": { "username": "torvalds" } } ``` **Response:** ``` πŸ“Š **GitHub Statistics for torvalds** **User Info:** β€’ Followers: 50000 β€’ Following: 0 β€’ Public Repos: 1 **Repository Stats:** β€’ Total Repositories: 1 β€’ Total Stars Received: ⭐ 200000 β€’ Total Forks: 🍴 80000 β€’ Average Stars per Repo: 200000.0 **Top Languages:** C: 1 ``` ## πŸ“š Resources ### Repository Resource Access repository data via URI: `github://repository/{owner}/{repo}` **Examples:** - `github://repository/microsoft/vscode` - `github://repository/facebook/react` ### User Resource Access user data via URI: `github://user/{username}` **Examples:** - `github://user/octocat` - `github://user/Om-Shree-0709` ## πŸ’¬ Prompts ### Natural Language Queries Ask questions in natural language about GitHub data: ```json { "prompt": "github_query", "arguments": { "query": "Show me my most starred repositories" } } ``` **Supported queries:** - "Show me my most starred repositories" - "Search for TypeScript repositories" - "What are the open issues in microsoft/vscode?" - "List my repositories" - "Get statistics for user octocat" ## πŸ”§ Configuration ### Environment Variables Create a `.env` file with: ```env # Required GITHUB_TOKEN=your_github_token_here # Optional GITHUB_USERNAME=your_username_here ``` ### GitHub Token Scopes Your GitHub token needs these scopes: - `repo` - Full control of private repositories - `user` - Read all user profile data - `read:org` - Read org and team membership ## πŸ— Architecture The server is built using: - **TypeScript** - Type-safe development - **MCP SDK** - Model Context Protocol framework - **Octokit** - Official GitHub API client - **Zod** - Schema validation - **Stdio Transport** - Standard input/output communication ### Project Structure ``` src/ β”œβ”€β”€ server.ts # Main server implementation with all tools and resources dist/ # Compiled JavaScript node_modules/ # Dependencies ``` ## πŸ”— Integration ### With Claude Desktop Add to your Claude Desktop configuration: ```json { "mcpServers": { "github": { "command": "node", "args": ["/path/to/your/github-mcp-server/dist/server.js"], "env": { "GITHUB_TOKEN": "your_token_here" } } } } ``` ### With Other MCP Clients The server communicates via stdio and follows the MCP protocol specification. It works with any MCP-compatible client that can send JSON-RPC requests. ### Direct JSON-RPC Usage Send JSON-RPC 2.0 requests to your server: ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "get_repo_info", "arguments": { "owner": "microsoft", "repo": "vscode" } } } ``` ## πŸ›‘ Error Handling The server includes comprehensive error handling: - βœ… **Authentication errors** - Clear messages for invalid tokens - βœ… **Rate limiting** - Handles GitHub API rate limits gracefully - βœ… **Network errors** - Robust handling of connection issues - βœ… **Validation errors** - Input validation with helpful error messages - βœ… **GitHub API errors** - Detailed error reporting from GitHub ## πŸ“ˆ Performance Features - **Efficient API usage** - Optimized requests with proper pagination - **Caching-friendly** - Responses designed for easy caching - **Rate limit aware** - Respects GitHub API rate limits - **Batch operations** - Efficient handling of multiple requests ## 🎯 Practical Use Cases ### 1. Repository Research ```json {"tool": "get_repo_info", "arguments": {"owner": "microsoft", "repo": "vscode"}} {"tool": "list_repo_issues", "arguments": {"owner": "microsoft", "repo": "vscode", "state": "open"}} {"tool": "list_repo_prs", "arguments": {"owner": "microsoft", "repo": "vscode", "state": "open"}} ``` ### 2. User Analysis ```json {"tool": "get_user_info", "arguments": {"username": "torvalds"}} {"tool": "get_github_stats", "arguments": {"username": "torvalds"}} {"tool": "list_user_repos", "arguments": {"username": "torvalds", "type": "all"}} ``` ### 3. Project Discovery ```json {"tool": "search_repositories", "arguments": {"query": "language:typescript stars:>1000"}} {"tool": "search_repositories", "arguments": {"query": "topic:machine-learning created:>2023-01-01"}} ``` ### 4. Your Own Data ```json {"tool": "get_my_info", "arguments": {}} {"tool": "get_my_repos", "arguments": {"type": "all"}} {"tool": "get_github_stats", "arguments": {"username": "Om-Shree-0709"}} ``` ## πŸ“ Development ### Available Scripts - `npm run build` - Build the TypeScript project - `npm run build:watch` - Build with file watching - `npm run dev` - Run in development mode - `npm start` - Run the compiled server - `npm test` - Test the server - `npm run setup` - Run setup script - `npm run demo` - Run demo script - `npm run interactive-test` - Run interactive tests ### Adding New Tools 1. Create a new function in `src/server.ts` 2. Register the tool with `server.registerTool()` 3. Add proper error handling 4. Update this README ### Testing ```bash # Build and test npm run build npm start # Test with various scripts npm test npm run simple-test npm run interactive-test npm run demo ``` ## 🚨 Troubleshooting ### Common Issues 1. **"Cannot find module" errors** - Run `npm install` to install dependencies - Run `npm run build` to compile TypeScript 2. **Authentication failures** - Check your GitHub token is valid - Ensure token has required scopes - Verify `.env` file exists and is readable 3. **Rate limit errors** - Wait before making more requests - Consider using a token with higher rate limits 4. **Repository not found** - Check owner and repository names are correct - Ensure repository is public or you have access ### Debug Mode Run in development mode for detailed logging: ```bash npm run dev ``` ## πŸ“Š Response Format All tools return responses in the MCP standard format with `content` arrays containing text blocks: ```json { "content": [ { "type": "text", "text": "πŸ“ **Repository: microsoft/vscode**\n\n**Description:** Visual Studio Code\n**Stars:** ⭐ 150000\n..." } ] } ``` ## 🀝 Contributing 1. Fork the repository 2. Create a feature branch 3. Add your changes 4. Test thoroughly 5. Submit a pull request ## πŸ“„ License MIT License - see LICENSE file for details ## πŸ†˜ Support - **Issues**: Report bugs and feature requests via GitHub Issues - **Documentation**: Check the MCP specification for protocol details - **GitHub API**: Refer to [GitHub's API documentation](https://docs.github.com/en/rest) ## πŸ”— Related Links - [Model Context Protocol](https://modelcontextprotocol.io/) - [GitHub API Documentation](https://docs.github.com/en/rest) - [Octokit.js](https://octokit.github.io/rest.js/) - [TypeScript](https://www.typescriptlang.org/) --- **Happy coding! πŸš€** Your GitHub MCP Server is ready with 10 powerful tools! You can: - βœ… Get any repository information - βœ… Search repositories with advanced filters - βœ… List issues and pull requests - βœ… Browse commit history - βœ… Get user profiles and statistics - βœ… Access your own GitHub data - βœ… Use natural language queries

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