Labsco
parthloglogn logo

Github MCP Server Java

from parthloglogn

A production-ready MCP server that connects any MCP-compatible AI agent to the GitHub API. Manage repositories, issues, pull requests, and search β€” all through natural language.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeNeeds API keys

GitHub MCP Server β€” Java / Spring AI

Spring Boot Spring AI Java Lombok License: MIT

A production-ready MCP server that connects any MCP-compatible AI agent to the GitHub API. Manage repositories, issues, pull requests, and search β€” all through natural language.

Transport: HTTP/SSE on port 8080, compatible with Cursor and Claude Desktop out of the box.


Why this server?

CapabilityThis serverGitHub REST API
Repository managementβœ…βœ…
Issue & PR operationsβœ…βœ…
Branch & commit controlβœ…βœ…
Code & user searchβœ…βœ…
Natural language interfaceβœ…βŒ
MCP protocol (SSE)βœ…βŒ
Java / Spring AIβœ…βŒ
GitHub Enterprise supportβœ…βœ…

Tools (38 total)

CategoryCountTools
Repository11create_repository, fork_repository, get_repository, list_commits, get_commit, get_file_contents, create_or_update_file, delete_file, create_branch, list_branches, merge_branch
Issues11create_issue, update_issue, add_issue_comment, list_issues, get_issue, close_issue, reopen_issue, assign_issue, unassign_issue, add_issue_labels, remove_issue_label
Pull Requests10create_pull_request, update_pull_request, list_pull_requests, get_pull_request, merge_pull_request, close_pull_request, reopen_pull_request, add_pull_request_comment, create_pull_request_review, submit_pull_request_review
Search4search_code, search_issues, search_repositories, search_users
Users3get_authenticated_user, get_user, list_user_repositories

Architecture

MCP Client (Cursor / Claude Desktop / other)
    β”‚   HTTP/SSE transport (/sse + /mcp/message)
    β–Ό
Tool class  (@McpTool β€” thin delegation layer, validates required params)
    β–Ό
Service interface + impl  (business logic, error mapping, pagination)
    β–Ό
GitHubRestClient  (typed HTTP gateway, PAT auth, exception handling)
    β–Ό
GitHub REST API

The architecture is strictly layered:

  • client/ β€” GitHub integration boundary (HTTP, Bearer-Auth, error handling)
  • service/ β€” domain logic (filtering, mapping, pagination)
  • tools/ β€” MCP-facing surface (descriptions, param validation, delegation)
  • Spring Boot β€” runtime and transport wrapper only

Every tool returns a consistent ApiResponse<T> envelope:

{ "success": true,  "data": { ... } }
{ "success": false, "errorCode": "REPO_NOT_FOUND", "errorMessage": "..." }

Client config

Cursor (.cursor/mcp.json)

{
  "mcpServers": {
    "github": {
      "url": "http://localhost:8080/sse"
    }
  }
}

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "github": {
      "url": "http://localhost:8080/sse"
    }
  }
}

On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

VS Code / GitHub Copilot

URL mode (if your client supports it):

{
  "github.copilot.chat.mcp.servers": {
    "github": {
      "url": "http://localhost:8080/sse"
    }
  }
}

Command mode (stdio-only clients):

{
  "github.copilot.chat.mcp.servers": {
    "github": {
      "command": "java",
      "args": ["-jar", "/path/to/github-mcp-server-1.0.0.jar"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_..."
      }
    }
  }
}

Docker

# Build image
docker build -t github-mcp-server:latest .

# Run
docker run --rm -p 8080:8080 \
  -e GITHUB_PERSONAL_ACCESS_TOKEN=ghp_... \
  github-mcp-server:latest

If GitHub Enterprise runs in Docker on the same host, use host.docker.internal:

-e GITHUB_HOST=http://host.docker.internal:3000

Package structure

com.github.mcp
β”œβ”€β”€ GithubMcpApplication.java              @SpringBootApplication
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ GitHubProperties.java              @ConfigurationProperties β€” token, host, readOnly, toolsets
β”‚   └── WebConfig.java                     Web configuration
β”œβ”€β”€ client/
β”‚   β”œβ”€β”€ GitHubRestClient.java              GET/POST/PATCH/DELETE HTTP gateway; typed exceptions
β”‚   └── GitHubGraphqlClient.java           GraphQL client
β”œβ”€β”€ controller/
β”‚   └── HealthController.java              Health check endpoint (GET /health)
β”œβ”€β”€ exception/
β”‚   β”œβ”€β”€ GitHubMcpException.java            Base exception
β”‚   └── GlobalExceptionHandler.java        Global error handler
β”œβ”€β”€ dto/
β”‚   β”œβ”€β”€ common/   ApiResponse Β· PagedResponse
β”‚   β”œβ”€β”€ request/  *Request DTOs
β”‚   └── response/ *Response DTOs
β”œβ”€β”€ service/      Interfaces + impl β€” business logic, error mapping, pagination
└── tools/
    β”œβ”€β”€ RepositoryTools.java   (11 tools)
    β”œβ”€β”€ IssueTools.java        (11 tools)
    β”œβ”€β”€ PullRequestTools.java  (10 tools)
    β”œβ”€β”€ SearchTools.java       (4 tools)
    └── UserTools.java         (3 tools)