This document outlines the architecture for a Model Context Protocol (MCP) server that integrates with GitHub to provide comprehensive functionality for web-based projects in Cursor.
The GitHub MCP server follows a clean architecture approach with distinct layers:
The server supports both stdio and SSE transport options for flexibility.
github-mcp-server/
├── src/
│ ├── domain/ # Domain entities and interfaces
│ │ ├── entities/ # Core domain entities
│ │ └── repositories/ # Repository interfaces
│ ├── infrastructure/ # External integrations
│ │ ├── github/ # GitHub API integration
│ │ └── transport/ # Transport implementations
│ ├── services/ # Business logic services
│ ├── mcp/ # MCP protocol implementation
│ │ ├── tools/ # Tool definitions
│ │ └── handlers/ # Request handlers
│ ├── utils/ # Utility functions
│ ├── env.ts # Environment configuration
│ └── index.ts # Entry point
├── tests/ # Test suite
├── .env.example # Example environment variables
├── package.json # Dependencies and scripts
└── tsconfig.json # TypeScript configuration
The domain layer contains the core business entities and repository interfaces:
The infrastructure layer handles external integrations:
The service layer coordinates business logic:
The MCP layer defines tools and handles MCP protocol requests:
github_repository_info
: Get repository informationgithub_directory_structure
: Get repository directory structuregithub_read_file
: Read file contentgithub_list_branches
: List repository branchesgithub_list_issues
: List repository issuesgithub_create_issue
: Create a new issuegithub_update_issue
: Update an existing issuegithub_list_projects
: List GitHub projectsgithub_project_details
: Get project detailsgithub_create_project
: Create a new projectgithub_update_project
: Update an existing projectThe server supports two transport options:
The server requires GitHub authentication:
repo
(Full repository access)project
(Project access)write:org
(Organization access)GITHUB_TOKEN
: GitHub Personal Access TokenGITHUB_OWNER
: Default repository owner (optional)GITHUB_REPO
: Default repository name (optional)The server implements comprehensive error handling: