Spaces:
Build error
Build error
Upload folder using huggingface_hub
Browse files- Dockerfile +28 -27
- PUSH_DESCRIPTION.md +43 -0
- README.md +1147 -37
- app.py +22 -161
- cmd/github-mcp-server/main.go +101 -99
- requirements.txt +0 -1
Dockerfile
CHANGED
|
@@ -1,40 +1,41 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
|
|
|
|
| 4 |
WORKDIR /build
|
| 5 |
|
| 6 |
-
# Install git
|
| 7 |
-
RUN
|
|
|
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
|
| 27 |
-
# Copy the
|
| 28 |
-
COPY --from=builder /build/github-mcp-server .
|
| 29 |
-
|
| 30 |
-
# Copy the Python proxy script
|
| 31 |
COPY app.py .
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
# Expose port
|
| 37 |
-
EXPOSE 8080
|
| 38 |
|
| 39 |
-
# Run the
|
| 40 |
-
CMD ["
|
|
|
|
| 1 |
+
FROM golang:1.24.4-alpine AS build
|
| 2 |
+
ARG VERSION="dev"
|
| 3 |
|
| 4 |
+
# Set the working directory
|
| 5 |
WORKDIR /build
|
| 6 |
|
| 7 |
+
# Install git
|
| 8 |
+
RUN --mount=type=cache,target=/var/cache/apk \
|
| 9 |
+
apk add git
|
| 10 |
|
| 11 |
+
# Build the server
|
| 12 |
+
# go build automatically download required module dependencies to /go/pkg/mod
|
| 13 |
+
RUN --mount=type=cache,target=/go/pkg/mod \
|
| 14 |
+
--mount=type=cache,target=/root/.cache/go-build \
|
| 15 |
+
--mount=type=bind,target=. \
|
| 16 |
+
CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION} -X main.commit=$(git rev-parse HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
| 17 |
+
-o /bin/github-mcp-server cmd/github-mcp-server/main.go
|
| 18 |
|
| 19 |
+
# Make a stage to run the app
|
| 20 |
+
FROM python:3.9-slim
|
| 21 |
|
| 22 |
+
# Set the working directory
|
| 23 |
+
WORKDIR /app
|
| 24 |
|
| 25 |
+
# Copy the binary from the build stage
|
| 26 |
+
COPY --from=build /bin/github-mcp-server /usr/local/bin/github-mcp-server
|
| 27 |
|
| 28 |
+
# Copy the requirements file
|
| 29 |
+
COPY requirements.txt .
|
| 30 |
|
| 31 |
+
# Install the dependencies
|
| 32 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 33 |
|
| 34 |
+
# Copy the app
|
|
|
|
|
|
|
|
|
|
| 35 |
COPY app.py .
|
| 36 |
|
| 37 |
+
# Expose the port the app will run on
|
| 38 |
+
EXPOSE 7860
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
# Run the web server
|
| 41 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
PUSH_DESCRIPTION.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# How Pushing to Hugging Face Spaces Works
|
| 2 |
+
|
| 3 |
+
When you interact with a Hugging Face Space that is backed by a Git repository, pushing changes typically follows the standard Git workflow. However, there are some nuances specific to Hugging Face Spaces.
|
| 4 |
+
|
| 5 |
+
## Standard Git Workflow
|
| 6 |
+
|
| 7 |
+
1. **Clone the Repository:** You start by cloning the Git repository associated with the Hugging Face Space to your local machine.
|
| 8 |
+
```bash
|
| 9 |
+
git clone https://huggingface.co/spaces/<your-username>/<your-space-name>
|
| 10 |
+
```
|
| 11 |
+
2. **Make Changes:** You make your desired modifications to the files in your local repository.
|
| 12 |
+
3. **Commit Changes:** You commit your changes to your local Git history.
|
| 13 |
+
```bash
|
| 14 |
+
git add .
|
| 15 |
+
git commit -m "Your commit message"
|
| 16 |
+
```
|
| 17 |
+
4. **Pull Latest Changes (Optional but Recommended):** Before pushing, it's good practice to pull any changes that might have been made to the remote repository by others (or by the Space itself if it has automated processes). This helps prevent merge conflicts.
|
| 18 |
+
```bash
|
| 19 |
+
git pull origin main # or whatever your branch name is
|
| 20 |
+
```
|
| 21 |
+
5. **Push Changes:** You push your local committed changes to the remote Git repository.
|
| 22 |
+
```bash
|
| 23 |
+
git push origin main # or whatever your branch name is
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
## Hugging Face Spaces Specifics
|
| 27 |
+
|
| 28 |
+
* **Automatic Deployment:** One of the key features of Hugging Face Spaces is automatic deployment. When you push changes to the main branch of your Space's Git repository, Hugging Face automatically detects these changes and attempts to rebuild and redeploy your Space.
|
| 29 |
+
* **Authentication:** When pushing to a Hugging Face Space, you typically authenticate using a Hugging Face token. This token is usually provided in the URL when you clone the repository or when you configure your Git remote.
|
| 30 |
+
```bash
|
| 31 |
+
# Example remote URL with token for pushing
|
| 32 |
+
https://hf_<your-token>@huggingface.co/spaces/<your-username>/<your-space-name>
|
| 33 |
+
```
|
| 34 |
+
Alternatively, you can configure Git credential helpers to store your token securely.
|
| 35 |
+
* **Space URL vs. Git Repository URL:** The URL you use to access the running Space (`https://<username>-<space-name>.hf.space`) is different from the Git repository URL (`https://huggingface.co/spaces/<username>/<space-name>`). When performing Git operations (clone, pull, push), you must use the Git repository URL.
|
| 36 |
+
* **Direct Editing:** Hugging Face Spaces also offer a web-based interface for direct file editing. Changes made through this interface are automatically committed and pushed to the repository. If you are also working locally, you should `git pull` frequently to ensure your local repository is up-to-date with any web-based edits.
|
| 37 |
+
|
| 38 |
+
## Common Issues
|
| 39 |
+
|
| 40 |
+
* **Merge Conflicts:** If changes are made both locally and on the remote (e.g., through web editing or by others), a `git pull` might result in merge conflicts. These must be resolved manually in your local repository before you can push.
|
| 41 |
+
* **Rejected Pushes:** A push might be rejected if the remote repository contains changes you don't have locally (a "non-fast-forward" error). This usually means you need to `git pull` first.
|
| 42 |
+
* **Authentication Errors:** Ensure your Hugging Face token is correct and has the necessary permissions to push to the Space.
|
| 43 |
+
* **Build Failures:** After a successful push, if your Space doesn't update, check the build logs on the Hugging Face Space page. There might be an issue with your code or environment setup that prevents the Space from building successfully.
|
README.md
CHANGED
|
@@ -1,59 +1,1169 @@
|
|
| 1 |
---
|
| 2 |
title: GitHub MCP Server
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
| 7 |
-
sdk_version: "3.9"
|
| 8 |
-
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
-
# GitHub MCP Server
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
```
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
```
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
-
- Updated import path from `github.com/mark3labs/mcp-go` to `github.com/mark3labs/mcp-go/mcp`
|
| 31 |
-
- Added all necessary imports (`bytes`, `io`)
|
| 32 |
-
- Maintained all existing functionality with enhanced logging
|
| 33 |
|
| 34 |
-
|
| 35 |
-
- Removed the problematic `go mod edit -replace` command
|
| 36 |
-
- Implemented proper multi-stage build process
|
| 37 |
-
- Ensures the github-mcp-server binary is correctly built and copied
|
| 38 |
-
- Uses proper dependency management with `go mod download`
|
| 39 |
|
| 40 |
-
##
|
| 41 |
|
| 42 |
-
|
| 43 |
-
2. Replace the original `Dockerfile` with the fixed version
|
| 44 |
-
3. Build the Docker image normally
|
| 45 |
|
| 46 |
-
##
|
| 47 |
|
| 48 |
-
|
| 49 |
-
- Changed import path to use the correct module structure
|
| 50 |
-
- Added missing imports for `bytes` and `io` packages
|
| 51 |
-
- Preserved all existing functionality
|
| 52 |
|
| 53 |
-
|
| 54 |
-
- Removed problematic module replacement
|
| 55 |
-
- Used standard multi-stage build approach
|
| 56 |
-
- Properly copies the built binary to final image
|
| 57 |
-
- Ensures the binary is executable
|
| 58 |
|
| 59 |
-
|
|
|
|
| 1 |
---
|
| 2 |
title: GitHub MCP Server
|
| 3 |
+
emoji: 🐙
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: docker
|
|
|
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
+
# GitHub MCP Server
|
| 11 |
|
| 12 |
+
The GitHub MCP Server connects AI tools directly to GitHub's platform. This gives AI agents, assistants, and chatbots the ability to read repositories and code files, manage issues and PRs, analyze code, and automate workflows. All through natural language interactions.
|
| 13 |
|
| 14 |
+
### Use Cases
|
| 15 |
|
| 16 |
+
- Repository Management: Browse and query code, search files, analyze commits, and understand project structure across any repository you have access to.
|
| 17 |
+
- Issue & PR Automation: Create, update, and manage issues and pull requests. Let AI help triage bugs, review code changes, and maintain project boards.
|
| 18 |
+
- CI/CD & Workflow Intelligence: Monitor GitHub Actions workflow runs, analyze build failures, manage releases, and get insights into your development pipeline.
|
| 19 |
+
- Code Analysis: Examine security findings, review Dependabot alerts, understand code patterns, and get comprehensive insights into your codebase.
|
| 20 |
+
- Team Collaboration: Access discussions, manage notifications, analyze team activity, and streamline processes for your team.
|
| 21 |
+
|
| 22 |
+
Built for developers who want to connect their AI tools to GitHub context and capabilities, from simple natural language queries to complex multi-step agent workflows.
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## Remote GitHub MCP Server
|
| 27 |
+
|
| 28 |
+
[](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) [](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D&quality=insiders)
|
| 29 |
+
|
| 30 |
+
The remote GitHub MCP Server is hosted by GitHub and provides the easiest method for getting up and running. If your MCP host does not support remote MCP servers, don't worry! You can use the [local version of the GitHub MCP Server](https://github.com/github/github-mcp-server?tab=readme-ov-file#local-github-mcp-server) instead.
|
| 31 |
+
|
| 32 |
+
### Prerequisites
|
| 33 |
+
|
| 34 |
+
1. A compatible MCP host with remote server support (VS Code 1.101+, Claude Desktop, Cursor, Windsurf, etc.)
|
| 35 |
+
2. Any applicable [policies enabled](https://github.com/github/github-mcp-server/blob/main/docs/policies-and-governance.md)
|
| 36 |
+
|
| 37 |
+
### Install in VS Code
|
| 38 |
+
|
| 39 |
+
For quick installation, use one of the one-click install buttons above. Once you complete that flow, toggle Agent mode (located by the Copilot Chat text input) and the server will start. Make sure you're using [VS Code 1.101](https://code.visualstudio.com/updates/v1_101) or [later](https://code.visualstudio.com/updates) for remote MCP and OAuth support.
|
| 40 |
+
|
| 41 |
+
Alternatively, to manually configure VS Code, choose the appropriate JSON block from the examples below and add it to your host configuration:
|
| 42 |
+
|
| 43 |
+
<table>
|
| 44 |
+
<tr><th>Using OAuth</th><th>Using a GitHub PAT</th></tr>
|
| 45 |
+
<tr><th align=left colspan=2>VS Code (version 1.101 or greater)</th></tr>
|
| 46 |
+
<tr valign=top>
|
| 47 |
+
<td>
|
| 48 |
+
|
| 49 |
+
```json
|
| 50 |
+
{
|
| 51 |
+
"servers": {
|
| 52 |
+
"github": {
|
| 53 |
+
"type": "http",
|
| 54 |
+
"url": "https://api.githubcopilot.com/mcp/"
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
</td>
|
| 61 |
+
<td>
|
| 62 |
+
|
| 63 |
+
```json
|
| 64 |
+
{
|
| 65 |
+
"servers": {
|
| 66 |
+
"github": {
|
| 67 |
+
"type": "http",
|
| 68 |
+
"url": "https://api.githubcopilot.com/mcp/",
|
| 69 |
+
"headers": {
|
| 70 |
+
"Authorization": "Bearer ${input:github_mcp_pat}"
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
"inputs": [
|
| 75 |
+
{
|
| 76 |
+
"type": "promptString",
|
| 77 |
+
"id": "github_mcp_pat",
|
| 78 |
+
"description": "GitHub Personal Access Token",
|
| 79 |
+
"password": true
|
| 80 |
+
}
|
| 81 |
+
]
|
| 82 |
+
}
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
</td>
|
| 86 |
+
</tr>
|
| 87 |
+
</table>
|
| 88 |
+
|
| 89 |
+
### Install in other MCP hosts
|
| 90 |
+
- **[GitHub Copilot in other IDEs](/docs/installation-guides/install-other-copilot-ides.md)** - Installation for JetBrains, Visual Studio, Eclipse, and Xcode with GitHub Copilot
|
| 91 |
+
- **[Claude Applications](/docs/installation-guides/install-claude.md)** - Installation guide for Claude Web, Claude Desktop and Claude Code CLI
|
| 92 |
+
- **[Cursor](/docs/installation-guides/install-cursor.md)** - Installation guide for Cursor IDE
|
| 93 |
+
- **[Windsurf](/docs/installation-guides/install-windsurf.md)** - Installation guide for Windsurf IDE
|
| 94 |
+
|
| 95 |
+
> **Note:** Each MCP host application needs to configure a GitHub App or OAuth App to support remote access via OAuth. Any host application that supports remote MCP servers should support the remote GitHub server with PAT authentication. Configuration details and support levels vary by host. Make sure to refer to the host application's documentation for more info.
|
| 96 |
+
|
| 97 |
+
> ⚠️ **Public Preview Status:** The **remote** GitHub MCP Server is currently in Public Preview. During preview, access may be gated depending on authentication type and surface:
|
| 98 |
+
> - OAuth: Subject to GitHub Copilot Editor Preview Policy until GA
|
| 99 |
+
> - PAT: Controlled via your organization's PAT policies
|
| 100 |
+
> - MCP Servers in Copilot policy: Enables/disables access to all MCP servers in VS Code, with other Copilot editors migrating to this policy in the coming months.
|
| 101 |
+
|
| 102 |
+
### Configuration
|
| 103 |
+
See [Remote Server Documentation](/docs/remote-server.md) on how to pass additional configuration settings to the remote GitHub MCP Server.
|
| 104 |
+
|
| 105 |
+
---
|
| 106 |
+
|
| 107 |
+
## Local GitHub MCP Server
|
| 108 |
+
|
| 109 |
+
[](https://insiders.vscode.dev/redirect/mcp/install?name=github&inputs=%5B%7B%22id%22%3A%22github_token%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22GitHub%20Personal%20Access%20Token%22%2C%22password%22%3Atrue%7D%5D&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22-e%22%2C%22GITHUB_PERSONAL_ACCESS_TOKEN%22%2C%22ghcr.io%2Fgithub%2Fgithub-mcp-server%22%5D%2C%22env%22%3A%7B%22GITHUB_PERSONAL_ACCESS_TOKEN%22%3A%22%24%7Binput%3Agithub_token%7D%22%7D%7D) [](https://insiders.vscode.dev/redirect/mcp/install?name=github&inputs=%5B%7B%22id%22%3A%22github_token%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22GitHub%20Personal%20Access%20Token%22%2C%22password%22%3Atrue%7D%5D&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22-e%22%2C%22GITHUB_PERSONAL_ACCESS_TOKEN%22%2C%22ghcr.io%2Fgithub%2Fgithub-mcp-server%22%5D%2C%22env%22%3A%7B%22GITHUB_PERSONAL_ACCESS_TOKEN%22%3A%22%24%7Binput%3Agithub_token%7D%22%7D%7D&quality=insiders)
|
| 110 |
+
|
| 111 |
+
### Prerequisites
|
| 112 |
+
|
| 113 |
+
1. To run the server in a container, you will need to have [Docker](https://www.docker.com/) installed.
|
| 114 |
+
2. Once Docker is installed, you will also need to ensure Docker is running. The image is public; if you get errors on pull, you may have an expired token and need to `docker logout ghcr.io`.
|
| 115 |
+
3. Lastly you will need to [Create a GitHub Personal Access Token](https://github.com/settings/personal-access-tokens/new).
|
| 116 |
+
The MCP server can use many of the GitHub APIs, so enable the permissions that you feel comfortable granting your AI tools (to learn more about access tokens, please check out the [documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)).
|
| 117 |
+
|
| 118 |
+
<details><summary><b>Handling PATs Securely</b></summary>
|
| 119 |
+
|
| 120 |
+
### Environment Variables (Recommended)
|
| 121 |
+
To keep your GitHub PAT secure and reusable across different MCP hosts:
|
| 122 |
+
|
| 123 |
+
1. **Store your PAT in environment variables**
|
| 124 |
+
```bash
|
| 125 |
+
export GITHUB_PAT=your_token_here
|
| 126 |
+
```
|
| 127 |
+
Or create a `.env` file:
|
| 128 |
+
```env
|
| 129 |
+
GITHUB_PAT=your_token_here
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
2. **Protect your `.env` file**
|
| 133 |
+
```bash
|
| 134 |
+
# Add to .gitignore to prevent accidental commits
|
| 135 |
+
echo ".env" >> .gitignore
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
3. **Reference the token in configurations**
|
| 139 |
+
```bash
|
| 140 |
+
# CLI usage
|
| 141 |
+
claude mcp update github -e GITHUB_PERSONAL_ACCESS_TOKEN=$GITHUB_PAT
|
| 142 |
+
|
| 143 |
+
# In config files (where supported)
|
| 144 |
+
"env": {
|
| 145 |
+
"GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_PAT"
|
| 146 |
+
}
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
> **Note**: Environment variable support varies by host app and IDE. Some applications (like Windsurf) require hardcoded tokens in config files.
|
| 150 |
+
|
| 151 |
+
### Token Security Best Practices
|
| 152 |
+
|
| 153 |
+
- **Minimum scopes**: Only grant necessary permissions
|
| 154 |
+
- `repo` - Repository operations
|
| 155 |
+
- `read:packages` - Docker image access
|
| 156 |
+
- `read:org` - Organization team access
|
| 157 |
+
- **Separate tokens**: Use different PATs for different projects/environments
|
| 158 |
+
- **Regular rotation**: Update tokens periodically
|
| 159 |
+
- **Never commit**: Keep tokens out of version control
|
| 160 |
+
- **File permissions**: Restrict access to config files containing tokens
|
| 161 |
+
```bash
|
| 162 |
+
chmod 600 ~/.your-app/config.json
|
| 163 |
+
```
|
| 164 |
+
|
| 165 |
+
</details>
|
| 166 |
+
|
| 167 |
+
## Installation
|
| 168 |
+
|
| 169 |
+
### Install in GitHub Copilot on VS Code
|
| 170 |
+
|
| 171 |
+
For quick installation, use one of the one-click install buttons above. Once you complete that flow, toggle Agent mode (located by the Copilot Chat text input) and the server will start.
|
| 172 |
+
|
| 173 |
+
More about using MCP server tools in VS Code's [agent mode documentation](https://code.visualstudio.com/docs/copilot/chat/mcp-servers).
|
| 174 |
+
|
| 175 |
+
Install in GitHub Copilot on other IDEs (JetBrains, Visual Studio, Eclipse, etc.)
|
| 176 |
+
|
| 177 |
+
Add the following JSON block to your IDE's MCP settings.
|
| 178 |
+
|
| 179 |
+
```json
|
| 180 |
+
{
|
| 181 |
+
"mcp": {
|
| 182 |
+
"inputs": [
|
| 183 |
+
{
|
| 184 |
+
"type": "promptString",
|
| 185 |
+
"id": "github_token",
|
| 186 |
+
"description": "GitHub Personal Access Token",
|
| 187 |
+
"password": true
|
| 188 |
+
}
|
| 189 |
+
],
|
| 190 |
+
"servers": {
|
| 191 |
+
"github": {
|
| 192 |
+
"command": "docker",
|
| 193 |
+
"args": [
|
| 194 |
+
"run",
|
| 195 |
+
"-i",
|
| 196 |
+
"--rm",
|
| 197 |
+
"-e",
|
| 198 |
+
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
| 199 |
+
"ghcr.io/github/github-mcp-server"
|
| 200 |
+
],
|
| 201 |
+
"env": {
|
| 202 |
+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
```
|
| 209 |
+
|
| 210 |
+
Optionally, you can add a similar example (i.e. without the mcp key) to a file called `.vscode/mcp.json` in your workspace. This will allow you to share the configuration with other host applications that accept the same format.
|
| 211 |
+
|
| 212 |
+
<details>
|
| 213 |
+
<summary><b>Example JSON block without the MCP key included</b></summary>
|
| 214 |
+
<br>
|
| 215 |
+
|
| 216 |
+
```json
|
| 217 |
+
{
|
| 218 |
+
"inputs": [
|
| 219 |
+
{
|
| 220 |
+
"type": "promptString",
|
| 221 |
+
"id": "github_token",
|
| 222 |
+
"description": "GitHub Personal Access Token",
|
| 223 |
+
"password": true
|
| 224 |
+
}
|
| 225 |
+
],
|
| 226 |
+
"servers": {
|
| 227 |
+
"github": {
|
| 228 |
+
"command": "docker",
|
| 229 |
+
"args": [
|
| 230 |
+
"run",
|
| 231 |
+
"-i",
|
| 232 |
+
"--rm",
|
| 233 |
+
"-e",
|
| 234 |
+
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
| 235 |
+
"ghcr.io/github/github-mcp-server"
|
| 236 |
+
],
|
| 237 |
+
"env": {
|
| 238 |
+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
|
| 239 |
+
}
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
```
|
| 244 |
+
|
| 245 |
+
</details>
|
| 246 |
+
|
| 247 |
+
### Install in Other MCP Hosts
|
| 248 |
+
|
| 249 |
+
For other MCP host applications, please refer to our installation guides:
|
| 250 |
+
|
| 251 |
+
- **[GitHub Copilot in other IDEs](/docs/installation-guides/install-other-copilot-ides.md)** - Installation for JetBrains, Visual Studio, Eclipse, and Xcode with GitHub Copilot
|
| 252 |
+
- **[Claude Code & Claude Desktop](docs/installation-guides/install-claude.md)** - Installation guide for Claude Code and Claude Desktop
|
| 253 |
+
- **[Cursor](docs/installation-guides/install-cursor.md)** - Installation guide for Cursor IDE
|
| 254 |
+
- **[Windsurf](docs/installation-guides/install-windsurf.md)** - Installation guide for Windsurf IDE
|
| 255 |
+
|
| 256 |
+
For a complete overview of all installation options, see our **[Installation Guides Index](docs/installation-guides)**.
|
| 257 |
+
|
| 258 |
+
> **Note:** Any host application that supports local MCP servers should be able to access the local GitHub MCP server. However, the specific configuration process, syntax and stability of the integration will vary by host application. While many may follow a similar format to the examples above, this is not guaranteed. Please refer to your host application's documentation for the correct MCP configuration syntax and setup process.
|
| 259 |
+
|
| 260 |
+
### Build from source
|
| 261 |
+
|
| 262 |
+
If you don't have Docker, you can use `go build` to build the binary in the
|
| 263 |
+
`cmd/github-mcp-server` directory, and use the `github-mcp-server stdio` command with the `GITHUB_PERSONAL_ACCESS_TOKEN` environment variable set to your token. To specify the output location of the build, use the `-o` flag. You should configure your server to use the built executable as its `command`. For example:
|
| 264 |
+
|
| 265 |
+
```JSON
|
| 266 |
+
{
|
| 267 |
+
"mcp": {
|
| 268 |
+
"servers": {
|
| 269 |
+
"github": {
|
| 270 |
+
"command": "/path/to/github-mcp-server",
|
| 271 |
+
"args": ["stdio"],
|
| 272 |
+
"env": {
|
| 273 |
+
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
}
|
| 279 |
+
```
|
| 280 |
+
|
| 281 |
+
## Tool Configuration
|
| 282 |
+
|
| 283 |
+
The GitHub MCP Server supports enabling or disabling specific groups of functionalities via the `--toolsets` flag. This allows you to control which GitHub API capabilities are available to your AI tools. Enabling only the toolsets that you need can help the LLM with tool choice and reduce the context size.
|
| 284 |
+
|
| 285 |
+
_Toolsets are not limited to Tools. Relevant MCP Resources and Prompts are also included where applicable._
|
| 286 |
+
|
| 287 |
+
### Available Toolsets
|
| 288 |
+
|
| 289 |
+
The following sets of tools are available (all are on by default):
|
| 290 |
+
|
| 291 |
+
<!-- START AUTOMATED TOOLSETS -->
|
| 292 |
+
| Toolset | Description |
|
| 293 |
+
| ----------------------- | ------------------------------------------------------------- |
|
| 294 |
+
| `context` | **Strongly recommended**: Tools that provide context about the current user and GitHub context you are operating in |
|
| 295 |
+
| `actions` | GitHub Actions workflows and CI/CD operations |
|
| 296 |
+
| `code_security` | Code security related tools, such as GitHub Code Scanning |
|
| 297 |
+
| `dependabot` | Dependabot tools |
|
| 298 |
+
| `discussions` | GitHub Discussions related tools |
|
| 299 |
+
| `experiments` | Experimental features that are not considered stable yet |
|
| 300 |
+
| `gists` | GitHub Gist related tools |
|
| 301 |
+
| `issues` | GitHub Issues related tools |
|
| 302 |
+
| `notifications` | GitHub Notifications related tools |
|
| 303 |
+
| `orgs` | GitHub Organization related tools |
|
| 304 |
+
| `pull_requests` | GitHub Pull Request related tools |
|
| 305 |
+
| `repos` | GitHub Repository related tools |
|
| 306 |
+
| `secret_protection` | Secret protection related tools, such as GitHub Secret Scanning |
|
| 307 |
+
| `security_advisories` | Security advisories related tools |
|
| 308 |
+
| `users` | GitHub User related tools |
|
| 309 |
+
<!-- END AUTOMATED TOOLSETS -->
|
| 310 |
+
|
| 311 |
+
## Tools
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
<!-- START AUTOMATED TOOLS -->
|
| 315 |
+
<details>
|
| 316 |
+
|
| 317 |
+
<summary>Actions</summary>
|
| 318 |
+
|
| 319 |
+
- **cancel_workflow_run** - Cancel workflow run
|
| 320 |
+
- `owner`: Repository owner (string, required)
|
| 321 |
+
- `repo`: Repository name (string, required)
|
| 322 |
+
- `run_id`: The unique identifier of the workflow run (number, required)
|
| 323 |
+
|
| 324 |
+
- **delete_workflow_run_logs** - Delete workflow logs
|
| 325 |
+
- `owner`: Repository owner (string, required)
|
| 326 |
+
- `repo`: Repository name (string, required)
|
| 327 |
+
- `run_id`: The unique identifier of the workflow run (number, required)
|
| 328 |
+
|
| 329 |
+
- **download_workflow_run_artifact** - Download workflow artifact
|
| 330 |
+
- `artifact_id`: The unique identifier of the artifact (number, required)
|
| 331 |
+
- `owner`: Repository owner (string, required)
|
| 332 |
+
- `repo`: Repository name (string, required)
|
| 333 |
+
|
| 334 |
+
- **get_job_logs** - Get job logs
|
| 335 |
+
- `failed_only`: When true, gets logs for all failed jobs in run_id (boolean, optional)
|
| 336 |
+
- `job_id`: The unique identifier of the workflow job (required for single job logs) (number, optional)
|
| 337 |
+
- `owner`: Repository owner (string, required)
|
| 338 |
+
- `repo`: Repository name (string, required)
|
| 339 |
+
- `return_content`: Returns actual log content instead of URLs (boolean, optional)
|
| 340 |
+
- `run_id`: Workflow run ID (required when using failed_only) (number, optional)
|
| 341 |
+
- `tail_lines`: Number of lines to return from the end of the log (number, optional)
|
| 342 |
+
|
| 343 |
+
- **get_workflow_run** - Get workflow run
|
| 344 |
+
- `owner`: Repository owner (string, required)
|
| 345 |
+
- `repo`: Repository name (string, required)
|
| 346 |
+
- `run_id`: The unique identifier of the workflow run (number, required)
|
| 347 |
+
|
| 348 |
+
- **get_workflow_run_logs** - Get workflow run logs
|
| 349 |
+
- `owner`: Repository owner (string, required)
|
| 350 |
+
- `repo`: Repository name (string, required)
|
| 351 |
+
- `run_id`: The unique identifier of the workflow run (number, required)
|
| 352 |
+
|
| 353 |
+
- **get_workflow_run_usage** - Get workflow usage
|
| 354 |
+
- `owner`: Repository owner (string, required)
|
| 355 |
+
- `repo`: Repository name (string, required)
|
| 356 |
+
- `run_id`: The unique identifier of the workflow run (number, required)
|
| 357 |
+
|
| 358 |
+
- **list_workflow_jobs** - List workflow jobs
|
| 359 |
+
- `filter`: Filters jobs by their completed_at timestamp (string, optional)
|
| 360 |
+
- `owner`: Repository owner (string, required)
|
| 361 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 362 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 363 |
+
- `repo`: Repository name (string, required)
|
| 364 |
+
- `run_id`: The unique identifier of the workflow run (number, required)
|
| 365 |
+
|
| 366 |
+
- **list_workflow_run_artifacts** - List workflow artifacts
|
| 367 |
+
- `owner`: Repository owner (string, required)
|
| 368 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 369 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 370 |
+
- `repo`: Repository name (string, required)
|
| 371 |
+
- `run_id`: The unique identifier of the workflow run (number, required)
|
| 372 |
+
|
| 373 |
+
- **list_workflow_runs** - List workflow runs
|
| 374 |
+
- `actor`: Returns someone's workflow runs. Use the login for the user who created the workflow run. (string, optional)
|
| 375 |
+
- `branch`: Returns workflow runs associated with a branch. Use the name of the branch. (string, optional)
|
| 376 |
+
- `event`: Returns workflow runs for a specific event type (string, optional)
|
| 377 |
+
- `owner`: Repository owner (string, required)
|
| 378 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 379 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 380 |
+
- `repo`: Repository name (string, required)
|
| 381 |
+
- `status`: Returns workflow runs with the check run status (string, optional)
|
| 382 |
+
- `workflow_id`: The workflow ID or workflow file name (string, required)
|
| 383 |
+
|
| 384 |
+
- **list_workflows** - List workflows
|
| 385 |
+
- `owner`: Repository owner (string, required)
|
| 386 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 387 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 388 |
+
- `repo`: Repository name (string, required)
|
| 389 |
+
|
| 390 |
+
- **rerun_failed_jobs** - Rerun failed jobs
|
| 391 |
+
- `owner`: Repository owner (string, required)
|
| 392 |
+
- `repo`: Repository name (string, required)
|
| 393 |
+
- `run_id`: The unique identifier of the workflow run (number, required)
|
| 394 |
+
|
| 395 |
+
- **rerun_workflow_run** - Rerun workflow run
|
| 396 |
+
- `owner`: Repository owner (string, required)
|
| 397 |
+
- `repo`: Repository name (string, required)
|
| 398 |
+
- `run_id`: The unique identifier of the workflow run (number, required)
|
| 399 |
+
|
| 400 |
+
- **run_workflow** - Run workflow
|
| 401 |
+
- `inputs`: Inputs the workflow accepts (object, optional)
|
| 402 |
+
- `owner`: Repository owner (string, required)
|
| 403 |
+
- `ref`: The git reference for the workflow. The reference can be a branch or tag name. (string, required)
|
| 404 |
+
- `repo`: Repository name (string, required)
|
| 405 |
+
- `workflow_id`: The workflow ID (numeric) or workflow file name (e.g., main.yml, ci.yaml) (string, required)
|
| 406 |
+
|
| 407 |
+
</details>
|
| 408 |
+
|
| 409 |
+
<details>
|
| 410 |
+
|
| 411 |
+
<summary>Code Security</summary>
|
| 412 |
+
|
| 413 |
+
- **get_code_scanning_alert** - Get code scanning alert
|
| 414 |
+
- `alertNumber`: The number of the alert. (number, required)
|
| 415 |
+
- `owner`: The owner of the repository. (string, required)
|
| 416 |
+
- `repo`: The name of the repository. (string, required)
|
| 417 |
+
|
| 418 |
+
- **list_code_scanning_alerts** - List code scanning alerts
|
| 419 |
+
- `owner`: The owner of the repository. (string, required)
|
| 420 |
+
- `ref`: The Git reference for the results you want to list. (string, optional)
|
| 421 |
+
- `repo`: The name of the repository. (string, required)
|
| 422 |
+
- `severity`: Filter code scanning alerts by severity (string, optional)
|
| 423 |
+
- `state`: Filter code scanning alerts by state. Defaults to open (string, optional)
|
| 424 |
+
- `tool_name`: The name of the tool used for code scanning. (string, optional)
|
| 425 |
+
|
| 426 |
+
</details>
|
| 427 |
+
|
| 428 |
+
<details>
|
| 429 |
+
|
| 430 |
+
<summary>Context</summary>
|
| 431 |
+
|
| 432 |
+
- **get_me** - Get my user profile
|
| 433 |
+
- No parameters required
|
| 434 |
+
|
| 435 |
+
- **get_team_members** - Get team members
|
| 436 |
+
- `org`: Organization login (owner) that contains the team. (string, required)
|
| 437 |
+
- `team_slug`: Team slug (string, required)
|
| 438 |
+
|
| 439 |
+
- **get_teams** - Get teams
|
| 440 |
+
- `user`: Username to get teams for. If not provided, uses the authenticated user. (string, optional)
|
| 441 |
+
|
| 442 |
+
</details>
|
| 443 |
+
|
| 444 |
+
<details>
|
| 445 |
+
|
| 446 |
+
<summary>Dependabot</summary>
|
| 447 |
+
|
| 448 |
+
- **get_dependabot_alert** - Get dependabot alert
|
| 449 |
+
- `alertNumber`: The number of the alert. (number, required)
|
| 450 |
+
- `owner`: The owner of the repository. (string, required)
|
| 451 |
+
- `repo`: The name of the repository. (string, required)
|
| 452 |
+
|
| 453 |
+
- **list_dependabot_alerts** - List dependabot alerts
|
| 454 |
+
- `owner`: The owner of the repository. (string, required)
|
| 455 |
+
- `repo`: The name of the repository. (string, required)
|
| 456 |
+
- `severity`: Filter dependabot alerts by severity (string, optional)
|
| 457 |
+
- `state`: Filter dependabot alerts by state. Defaults to open (string, optional)
|
| 458 |
+
|
| 459 |
+
</details>
|
| 460 |
+
|
| 461 |
+
<details>
|
| 462 |
+
|
| 463 |
+
<summary>Discussions</summary>
|
| 464 |
+
|
| 465 |
+
- **get_discussion** - Get discussion
|
| 466 |
+
- `discussionNumber`: Discussion Number (number, required)
|
| 467 |
+
- `owner`: Repository owner (string, required)
|
| 468 |
+
- `repo`: Repository name (string, required)
|
| 469 |
+
|
| 470 |
+
- **get_discussion_comments** - Get discussion comments
|
| 471 |
+
- `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional)
|
| 472 |
+
- `discussionNumber`: Discussion Number (number, required)
|
| 473 |
+
- `owner`: Repository owner (string, required)
|
| 474 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 475 |
+
- `repo`: Repository name (string, required)
|
| 476 |
+
|
| 477 |
+
- **list_discussion_categories** - List discussion categories
|
| 478 |
+
- `owner`: Repository owner (string, required)
|
| 479 |
+
- `repo`: Repository name. If not provided, discussion categories will be queried at the organisation level. (string, optional)
|
| 480 |
+
|
| 481 |
+
- **list_discussions** - List discussions
|
| 482 |
+
- `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional)
|
| 483 |
+
- `category`: Optional filter by discussion category ID. If provided, only discussions with this category are listed. (string, optional)
|
| 484 |
+
- `direction`: Order direction. (string, optional)
|
| 485 |
+
- `orderBy`: Order discussions by field. If provided, the 'direction' also needs to be provided. (string, optional)
|
| 486 |
+
- `owner`: Repository owner (string, required)
|
| 487 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 488 |
+
- `repo`: Repository name. If not provided, discussions will be queried at the organisation level. (string, optional)
|
| 489 |
+
|
| 490 |
+
</details>
|
| 491 |
+
|
| 492 |
+
<details>
|
| 493 |
+
|
| 494 |
+
<summary>Gists</summary>
|
| 495 |
+
|
| 496 |
+
- **create_gist** - Create Gist
|
| 497 |
+
- `content`: Content for simple single-file gist creation (string, required)
|
| 498 |
+
- `description`: Description of the gist (string, optional)
|
| 499 |
+
- `filename`: Filename for simple single-file gist creation (string, required)
|
| 500 |
+
- `public`: Whether the gist is public (boolean, optional)
|
| 501 |
+
|
| 502 |
+
- **list_gists** - List Gists
|
| 503 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 504 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 505 |
+
- `since`: Only gists updated after this time (ISO 8601 timestamp) (string, optional)
|
| 506 |
+
- `username`: GitHub username (omit for authenticated user's gists) (string, optional)
|
| 507 |
+
|
| 508 |
+
- **update_gist** - Update Gist
|
| 509 |
+
- `content`: Content for the file (string, required)
|
| 510 |
+
- `description`: Updated description of the gist (string, optional)
|
| 511 |
+
- `filename`: Filename to update or create (string, required)
|
| 512 |
+
- `gist_id`: ID of the gist to update (string, required)
|
| 513 |
+
|
| 514 |
+
</details>
|
| 515 |
+
|
| 516 |
+
<details>
|
| 517 |
+
|
| 518 |
+
<summary>Issues</summary>
|
| 519 |
+
|
| 520 |
+
- **add_issue_comment** - Add comment to issue
|
| 521 |
+
- `body`: Comment content (string, required)
|
| 522 |
+
- `issue_number`: Issue number to comment on (number, required)
|
| 523 |
+
- `owner`: Repository owner (string, required)
|
| 524 |
+
- `repo`: Repository name (string, required)
|
| 525 |
+
|
| 526 |
+
- **add_sub_issue** - Add sub-issue
|
| 527 |
+
- `issue_number`: The number of the parent issue (number, required)
|
| 528 |
+
- `owner`: Repository owner (string, required)
|
| 529 |
+
- `replace_parent`: When true, replaces the sub-issue's current parent issue (boolean, optional)
|
| 530 |
+
- `repo`: Repository name (string, required)
|
| 531 |
+
- `sub_issue_id`: The ID of the sub-issue to add. ID is not the same as issue number (number, required)
|
| 532 |
+
|
| 533 |
+
- **assign_copilot_to_issue** - Assign Copilot to issue
|
| 534 |
+
- `issueNumber`: Issue number (number, required)
|
| 535 |
+
- `owner`: Repository owner (string, required)
|
| 536 |
+
- `repo`: Repository name (string, required)
|
| 537 |
+
|
| 538 |
+
- **create_issue** - Open new issue
|
| 539 |
+
- `assignees`: Usernames to assign to this issue (string[], optional)
|
| 540 |
+
- `body`: Issue body content (string, optional)
|
| 541 |
+
- `labels`: Labels to apply to this issue (string[], optional)
|
| 542 |
+
- `milestone`: Milestone number (number, optional)
|
| 543 |
+
- `owner`: Repository owner (string, required)
|
| 544 |
+
- `repo`: Repository name (string, required)
|
| 545 |
+
- `title`: Issue title (string, required)
|
| 546 |
+
- `type`: Type of this issue (string, optional)
|
| 547 |
+
|
| 548 |
+
- **get_issue** - Get issue details
|
| 549 |
+
- `issue_number`: The number of the issue (number, required)
|
| 550 |
+
- `owner`: The owner of the repository (string, required)
|
| 551 |
+
- `repo`: The name of the repository (string, required)
|
| 552 |
+
|
| 553 |
+
- **get_issue_comments** - Get issue comments
|
| 554 |
+
- `issue_number`: Issue number (number, required)
|
| 555 |
+
- `owner`: Repository owner (string, required)
|
| 556 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 557 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 558 |
+
- `repo`: Repository name (string, required)
|
| 559 |
+
|
| 560 |
+
- **list_issue_types** - List available issue types
|
| 561 |
+
- `owner`: The organization owner of the repository (string, required)
|
| 562 |
+
|
| 563 |
+
- **list_issues** - List issues
|
| 564 |
+
- `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional)
|
| 565 |
+
- `direction`: Order direction. If provided, the 'orderBy' also needs to be provided. (string, optional)
|
| 566 |
+
- `labels`: Filter by labels (string[], optional)
|
| 567 |
+
- `orderBy`: Order issues by field. If provided, the 'direction' also needs to be provided. (string, optional)
|
| 568 |
+
- `owner`: Repository owner (string, required)
|
| 569 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 570 |
+
- `repo`: Repository name (string, required)
|
| 571 |
+
- `since`: Filter by date (ISO 8601 timestamp) (string, optional)
|
| 572 |
+
- `state`: Filter by state, by default both open and closed issues are returned when not provided (string, optional)
|
| 573 |
+
|
| 574 |
+
- **list_sub_issues** - List sub-issues
|
| 575 |
+
- `issue_number`: Issue number (number, required)
|
| 576 |
+
- `owner`: Repository owner (string, required)
|
| 577 |
+
- `page`: Page number for pagination (default: 1) (number, optional)
|
| 578 |
+
- `per_page`: Number of results per page (max 100, default: 30) (number, optional)
|
| 579 |
+
- `repo`: Repository name (string, required)
|
| 580 |
+
|
| 581 |
+
- **remove_sub_issue** - Remove sub-issue
|
| 582 |
+
- `issue_number`: The number of the parent issue (number, required)
|
| 583 |
+
- `owner`: Repository owner (string, required)
|
| 584 |
+
- `repo`: Repository name (string, required)
|
| 585 |
+
- `sub_issue_id`: The ID of the sub-issue to remove. ID is not the same as issue number (number, required)
|
| 586 |
+
|
| 587 |
+
- **reprioritize_sub_issue** - Reprioritize sub-issue
|
| 588 |
+
- `after_id`: The ID of the sub-issue to be prioritized after (either after_id OR before_id should be specified) (number, optional)
|
| 589 |
+
- `before_id`: The ID of the sub-issue to be prioritized before (either after_id OR before_id should be specified) (number, optional)
|
| 590 |
+
- `issue_number`: The number of the parent issue (number, required)
|
| 591 |
+
- `owner`: Repository owner (string, required)
|
| 592 |
+
- `repo`: Repository name (string, required)
|
| 593 |
+
- `sub_issue_id`: The ID of the sub-issue to reprioritize. ID is not the same as issue number (number, required)
|
| 594 |
+
|
| 595 |
+
- **search_issues** - Search issues
|
| 596 |
+
- `order`: Sort order (string, optional)
|
| 597 |
+
- `owner`: Optional repository owner. If provided with repo, only issues for this repository are listed. (string, optional)
|
| 598 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 599 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 600 |
+
- `query`: Search query using GitHub issues search syntax (string, required)
|
| 601 |
+
- `repo`: Optional repository name. If provided with owner, only issues for this repository are listed. (string, optional)
|
| 602 |
+
- `sort`: Sort field by number of matches of categories, defaults to best match (string, optional)
|
| 603 |
+
|
| 604 |
+
- **update_issue** - Edit issue
|
| 605 |
+
- `assignees`: New assignees (string[], optional)
|
| 606 |
+
- `body`: New description (string, optional)
|
| 607 |
+
- `issue_number`: Issue number to update (number, required)
|
| 608 |
+
- `labels`: New labels (string[], optional)
|
| 609 |
+
- `milestone`: New milestone number (number, optional)
|
| 610 |
+
- `owner`: Repository owner (string, required)
|
| 611 |
+
- `repo`: Repository name (string, required)
|
| 612 |
+
- `state`: New state (string, optional)
|
| 613 |
+
- `title`: New title (string, optional)
|
| 614 |
+
- `type`: New issue type (string, optional)
|
| 615 |
+
|
| 616 |
+
</details>
|
| 617 |
+
|
| 618 |
+
<details>
|
| 619 |
+
|
| 620 |
+
<summary>Notifications</summary>
|
| 621 |
+
|
| 622 |
+
- **dismiss_notification** - Dismiss notification
|
| 623 |
+
- `state`: The new state of the notification (read/done) (string, optional)
|
| 624 |
+
- `threadID`: The ID of the notification thread (string, required)
|
| 625 |
+
|
| 626 |
+
- **get_notification_details** - Get notification details
|
| 627 |
+
- `notificationID`: The ID of the notification (string, required)
|
| 628 |
+
|
| 629 |
+
- **list_notifications** - List notifications
|
| 630 |
+
- `before`: Only show notifications updated before the given time (ISO 8601 format) (string, optional)
|
| 631 |
+
- `filter`: Filter notifications to, use default unless specified. Read notifications are ones that have already been acknowledged by the user. Participating notifications are those that the user is directly involved in, such as issues or pull requests they have commented on or created. (string, optional)
|
| 632 |
+
- `owner`: Optional repository owner. If provided with repo, only notifications for this repository are listed. (string, optional)
|
| 633 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 634 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 635 |
+
- `repo`: Optional repository name. If provided with owner, only notifications for this repository are listed. (string, optional)
|
| 636 |
+
- `since`: Only show notifications updated after the given time (ISO 8601 format) (string, optional)
|
| 637 |
+
|
| 638 |
+
- **manage_notification_subscription** - Manage notification subscription
|
| 639 |
+
- `action`: Action to perform: ignore, watch, or delete the notification subscription. (string, required)
|
| 640 |
+
- `notificationID`: The ID of the notification thread. (string, required)
|
| 641 |
+
|
| 642 |
+
- **manage_repository_notification_subscription** - Manage repository notification subscription
|
| 643 |
+
- `action`: Action to perform: ignore, watch, or delete the repository notification subscription. (string, required)
|
| 644 |
+
- `owner`: The account owner of the repository. (string, required)
|
| 645 |
+
- `repo`: The name of the repository. (string, required)
|
| 646 |
+
|
| 647 |
+
- **mark_all_notifications_read** - Mark all notifications as read
|
| 648 |
+
- `lastReadAt`: Describes the last point that notifications were checked (optional). Default: Now (string, optional)
|
| 649 |
+
- `owner`: Optional repository owner. If provided with repo, only notifications for this repository are marked as read. (string, optional)
|
| 650 |
+
- `repo`: Optional repository name. If provided with owner, only notifications for this repository are marked as read. (string, optional)
|
| 651 |
+
|
| 652 |
+
</details>
|
| 653 |
+
|
| 654 |
+
<details>
|
| 655 |
+
|
| 656 |
+
<summary>Organizations</summary>
|
| 657 |
+
|
| 658 |
+
- **search_orgs** - Search organizations
|
| 659 |
+
- `order`: Sort order (string, optional)
|
| 660 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 661 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 662 |
+
- `query`: Organization search query. Examples: 'microsoft', 'location:california', 'created:>=2025-01-01'. Search is automatically scoped to type:org. (string, required)
|
| 663 |
+
- `sort`: Sort field by category (string, optional)
|
| 664 |
+
|
| 665 |
+
</details>
|
| 666 |
+
|
| 667 |
+
<details>
|
| 668 |
+
|
| 669 |
+
<summary>Pull Requests</summary>
|
| 670 |
+
|
| 671 |
+
- **add_comment_to_pending_review** - Add review comment to the requester's latest pending pull request review
|
| 672 |
+
- `body`: The text of the review comment (string, required)
|
| 673 |
+
- `line`: The line of the blob in the pull request diff that the comment applies to. For multi-line comments, the last line of the range (number, optional)
|
| 674 |
+
- `owner`: Repository owner (string, required)
|
| 675 |
+
- `path`: The relative path to the file that necessitates a comment (string, required)
|
| 676 |
+
- `pullNumber`: Pull request number (number, required)
|
| 677 |
+
- `repo`: Repository name (string, required)
|
| 678 |
+
- `side`: The side of the diff to comment on. LEFT indicates the previous state, RIGHT indicates the new state (string, optional)
|
| 679 |
+
- `startLine`: For multi-line comments, the first line of the range that the comment applies to (number, optional)
|
| 680 |
+
- `startSide`: For multi-line comments, the starting side of the diff that the comment applies to. LEFT indicates the previous state, RIGHT indicates the new state (string, optional)
|
| 681 |
+
- `subjectType`: The level at which the comment is targeted (string, required)
|
| 682 |
+
|
| 683 |
+
- **create_and_submit_pull_request_review** - Create and submit a pull request review without comments
|
| 684 |
+
- `body`: Review comment text (string, required)
|
| 685 |
+
- `commitID`: SHA of commit to review (string, optional)
|
| 686 |
+
- `event`: Review action to perform (string, required)
|
| 687 |
+
- `owner`: Repository owner (string, required)
|
| 688 |
+
- `pullNumber`: Pull request number (number, required)
|
| 689 |
+
- `repo`: Repository name (string, required)
|
| 690 |
+
|
| 691 |
+
- **create_pending_pull_request_review** - Create pending pull request review
|
| 692 |
+
- `commitID`: SHA of commit to review (string, optional)
|
| 693 |
+
- `owner`: Repository owner (string, required)
|
| 694 |
+
- `pullNumber`: Pull request number (number, required)
|
| 695 |
+
- `repo`: Repository name (string, required)
|
| 696 |
+
|
| 697 |
+
- **create_pull_request** - Open new pull request
|
| 698 |
+
- `base`: Branch to merge into (string, required)
|
| 699 |
+
- `body`: PR description (string, optional)
|
| 700 |
+
- `draft`: Create as draft PR (boolean, optional)
|
| 701 |
+
- `head`: Branch containing changes (string, required)
|
| 702 |
+
- `maintainer_can_modify`: Allow maintainer edits (boolean, optional)
|
| 703 |
+
- `owner`: Repository owner (string, required)
|
| 704 |
+
- `repo`: Repository name (string, required)
|
| 705 |
+
- `title`: PR title (string, required)
|
| 706 |
+
|
| 707 |
+
- **delete_pending_pull_request_review** - Delete the requester's latest pending pull request review
|
| 708 |
+
- `owner`: Repository owner (string, required)
|
| 709 |
+
- `pullNumber`: Pull request number (number, required)
|
| 710 |
+
- `repo`: Repository name (string, required)
|
| 711 |
+
|
| 712 |
+
- **get_pull_request** - Get pull request details
|
| 713 |
+
- `owner`: Repository owner (string, required)
|
| 714 |
+
- `pullNumber`: Pull request number (number, required)
|
| 715 |
+
- `repo`: Repository name (string, required)
|
| 716 |
+
|
| 717 |
+
- **get_pull_request_comments** - Get pull request comments
|
| 718 |
+
- `owner`: Repository owner (string, required)
|
| 719 |
+
- `pullNumber`: Pull request number (number, required)
|
| 720 |
+
- `repo`: Repository name (string, required)
|
| 721 |
+
|
| 722 |
+
- **get_pull_request_diff** - Get pull request diff
|
| 723 |
+
- `owner`: Repository owner (string, required)
|
| 724 |
+
- `pullNumber`: Pull request number (number, required)
|
| 725 |
+
- `repo`: Repository name (string, required)
|
| 726 |
+
|
| 727 |
+
- **get_pull_request_files** - Get pull request files
|
| 728 |
+
- `owner`: Repository owner (string, required)
|
| 729 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 730 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 731 |
+
- `pullNumber`: Pull request number (number, required)
|
| 732 |
+
- `repo`: Repository name (string, required)
|
| 733 |
+
|
| 734 |
+
- **get_pull_request_reviews** - Get pull request reviews
|
| 735 |
+
- `owner`: Repository owner (string, required)
|
| 736 |
+
- `pullNumber`: Pull request number (number, required)
|
| 737 |
+
- `repo`: Repository name (string, required)
|
| 738 |
+
|
| 739 |
+
- **get_pull_request_status** - Get pull request status checks
|
| 740 |
+
- `owner`: Repository owner (string, required)
|
| 741 |
+
- `pullNumber`: Pull request number (number, required)
|
| 742 |
+
- `repo`: Repository name (string, required)
|
| 743 |
+
|
| 744 |
+
- **list_pull_requests** - List pull requests
|
| 745 |
+
- `base`: Filter by base branch (string, optional)
|
| 746 |
+
- `direction`: Sort direction (string, optional)
|
| 747 |
+
- `head`: Filter by head user/org and branch (string, optional)
|
| 748 |
+
- `owner`: Repository owner (string, required)
|
| 749 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 750 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 751 |
+
- `repo`: Repository name (string, required)
|
| 752 |
+
- `sort`: Sort by (string, optional)
|
| 753 |
+
- `state`: Filter by state (string, optional)
|
| 754 |
+
|
| 755 |
+
- **merge_pull_request** - Merge pull request
|
| 756 |
+
- `commit_message`: Extra detail for merge commit (string, optional)
|
| 757 |
+
- `commit_title`: Title for merge commit (string, optional)
|
| 758 |
+
- `merge_method`: Merge method (string, optional)
|
| 759 |
+
- `owner`: Repository owner (string, required)
|
| 760 |
+
- `pullNumber`: Pull request number (number, required)
|
| 761 |
+
- `repo`: Repository name (string, required)
|
| 762 |
+
|
| 763 |
+
- **request_copilot_review** - Request Copilot review
|
| 764 |
+
- `owner`: Repository owner (string, required)
|
| 765 |
+
- `pullNumber`: Pull request number (number, required)
|
| 766 |
+
- `repo`: Repository name (string, required)
|
| 767 |
+
|
| 768 |
+
- **search_pull_requests** - Search pull requests
|
| 769 |
+
- `order`: Sort order (string, optional)
|
| 770 |
+
- `owner`: Optional repository owner. If provided with repo, only pull requests for this repository are listed. (string, optional)
|
| 771 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 772 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 773 |
+
- `query`: Search query using GitHub pull request search syntax (string, required)
|
| 774 |
+
- `repo`: Optional repository name. If provided with owner, only pull requests for this repository are listed. (string, optional)
|
| 775 |
+
- `sort`: Sort field by number of matches of categories, defaults to best match (string, optional)
|
| 776 |
+
|
| 777 |
+
- **submit_pending_pull_request_review** - Submit the requester's latest pending pull request review
|
| 778 |
+
- `body`: The text of the review comment (string, optional)
|
| 779 |
+
- `event`: The event to perform (string, required)
|
| 780 |
+
- `owner`: Repository owner (string, required)
|
| 781 |
+
- `pullNumber`: Pull request number (number, required)
|
| 782 |
+
- `repo`: Repository name (string, required)
|
| 783 |
+
|
| 784 |
+
- **update_pull_request** - Edit pull request
|
| 785 |
+
- `base`: New base branch name (string, optional)
|
| 786 |
+
- `body`: New description (string, optional)
|
| 787 |
+
- `draft`: Mark pull request as draft (true) or ready for review (false) (boolean, optional)
|
| 788 |
+
- `maintainer_can_modify`: Allow maintainer edits (boolean, optional)
|
| 789 |
+
- `owner`: Repository owner (string, required)
|
| 790 |
+
- `pullNumber`: Pull request number to update (number, required)
|
| 791 |
+
- `repo`: Repository name (string, required)
|
| 792 |
+
- `reviewers`: GitHub usernames to request reviews from (string[], optional)
|
| 793 |
+
- `state`: New state (string, optional)
|
| 794 |
+
- `title`: New title (string, optional)
|
| 795 |
+
|
| 796 |
+
- **update_pull_request_branch** - Update pull request branch
|
| 797 |
+
- `expectedHeadSha`: The expected SHA of the pull request's HEAD ref (string, optional)
|
| 798 |
+
- `owner`: Repository owner (string, required)
|
| 799 |
+
- `pullNumber`: Pull request number (number, required)
|
| 800 |
+
- `repo`: Repository name (string, required)
|
| 801 |
+
|
| 802 |
+
</details>
|
| 803 |
+
|
| 804 |
+
<details>
|
| 805 |
+
|
| 806 |
+
<summary>Repositories</summary>
|
| 807 |
+
|
| 808 |
+
- **create_branch** - Create branch
|
| 809 |
+
- `branch`: Name for new branch (string, required)
|
| 810 |
+
- `from_branch`: Source branch (defaults to repo default) (string, optional)
|
| 811 |
+
- `owner`: Repository owner (string, required)
|
| 812 |
+
- `repo`: Repository name (string, required)
|
| 813 |
+
|
| 814 |
+
- **create_or_update_file** - Create or update file
|
| 815 |
+
- `branch`: Branch to create/update the file in (string, required)
|
| 816 |
+
- `content`: Content of the file (string, required)
|
| 817 |
+
- `message`: Commit message (string, required)
|
| 818 |
+
- `owner`: Repository owner (username or organization) (string, required)
|
| 819 |
+
- `path`: Path where to create/update the file (string, required)
|
| 820 |
+
- `repo`: Repository name (string, required)
|
| 821 |
+
- `sha`: Required if updating an existing file. The blob SHA of the file being replaced. (string, optional)
|
| 822 |
+
|
| 823 |
+
- **create_repository** - Create repository
|
| 824 |
+
- `autoInit`: Initialize with README (boolean, optional)
|
| 825 |
+
- `description`: Repository description (string, optional)
|
| 826 |
+
- `name`: Repository name (string, required)
|
| 827 |
+
- `private`: Whether repo should be private (boolean, optional)
|
| 828 |
+
|
| 829 |
+
- **delete_file** - Delete file
|
| 830 |
+
- `branch`: Branch to delete the file from (string, required)
|
| 831 |
+
- `message`: Commit message (string, required)
|
| 832 |
+
- `owner`: Repository owner (username or organization) (string, required)
|
| 833 |
+
- `path`: Path to the file to delete (string, required)
|
| 834 |
+
- `repo`: Repository name (string, required)
|
| 835 |
+
|
| 836 |
+
- **fork_repository** - Fork repository
|
| 837 |
+
- `organization`: Organization to fork to (string, optional)
|
| 838 |
+
- `owner`: Repository owner (string, required)
|
| 839 |
+
- `repo`: Repository name (string, required)
|
| 840 |
+
|
| 841 |
+
- **get_commit** - Get commit details
|
| 842 |
+
- `owner`: Repository owner (string, required)
|
| 843 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 844 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 845 |
+
- `repo`: Repository name (string, required)
|
| 846 |
+
- `sha`: Commit SHA, branch name, or tag name (string, required)
|
| 847 |
+
|
| 848 |
+
- **get_file_contents** - Get file or directory contents
|
| 849 |
+
- `owner`: Repository owner (username or organization) (string, required)
|
| 850 |
+
- `path`: Path to file/directory (directories must end with a slash '/') (string, optional)
|
| 851 |
+
- `ref`: Accepts optional git refs such as `refs/tags/{tag}`, `refs/heads/{branch}` or `refs/pull/{pr_number}/head` (string, optional)
|
| 852 |
+
- `repo`: Repository name (string, required)
|
| 853 |
+
- `sha`: Accepts optional commit SHA. If specified, it will be used instead of ref (string, optional)
|
| 854 |
+
|
| 855 |
+
- **get_latest_release** - Get latest release
|
| 856 |
+
- `owner`: Repository owner (string, required)
|
| 857 |
+
- `repo`: Repository name (string, required)
|
| 858 |
+
|
| 859 |
+
- **get_release_by_tag** - Get a release by tag name
|
| 860 |
+
- `owner`: Repository owner (string, required)
|
| 861 |
+
- `repo`: Repository name (string, required)
|
| 862 |
+
- `tag`: Tag name (e.g., 'v1.0.0') (string, required)
|
| 863 |
+
|
| 864 |
+
- **get_tag** - Get tag details
|
| 865 |
+
- `owner`: Repository owner (string, required)
|
| 866 |
+
- `repo`: Repository name (string, required)
|
| 867 |
+
- `tag`: Tag name (string, required)
|
| 868 |
+
|
| 869 |
+
- **list_branches** - List branches
|
| 870 |
+
- `owner`: Repository owner (string, required)
|
| 871 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 872 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 873 |
+
- `repo`: Repository name (string, required)
|
| 874 |
+
|
| 875 |
+
- **list_commits** - List commits
|
| 876 |
+
- `author`: Author username or email address to filter commits by (string, optional)
|
| 877 |
+
- `owner`: Repository owner (string, required)
|
| 878 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 879 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 880 |
+
- `repo`: Repository name (string, required)
|
| 881 |
+
- `sha`: Commit SHA, branch or tag name to list commits of. If not provided, uses the default branch of the repository. If a commit SHA is provided, will list commits up to that SHA. (string, optional)
|
| 882 |
+
|
| 883 |
+
- **list_releases** - List releases
|
| 884 |
+
- `owner`: Repository owner (string, required)
|
| 885 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 886 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 887 |
+
- `repo`: Repository name (string, required)
|
| 888 |
+
|
| 889 |
+
- **list_tags** - List tags
|
| 890 |
+
- `owner`: Repository owner (string, required)
|
| 891 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 892 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 893 |
+
- `repo`: Repository name (string, required)
|
| 894 |
+
|
| 895 |
+
- **push_files** - Push files to repository
|
| 896 |
+
- `branch`: Branch to push to (string, required)
|
| 897 |
+
- `files`: Array of file objects to push, each object with path (string) and content (string) (object[], required)
|
| 898 |
+
- `message`: Commit message (string, required)
|
| 899 |
+
- `owner`: Repository owner (string, required)
|
| 900 |
+
- `repo`: Repository name (string, required)
|
| 901 |
+
|
| 902 |
+
- **search_code** - Search code
|
| 903 |
+
- `order`: Sort order for results (string, optional)
|
| 904 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 905 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 906 |
+
- `query`: Search query using GitHub's powerful code search syntax. Examples: 'content:Skill language:Java org:github', 'NOT is:archived language:Python OR language:go', 'repo:github/github-mcp-server'. Supports exact matching, language filters, path filters, and more. (string, required)
|
| 907 |
+
- `sort`: Sort field ('indexed' only) (string, optional)
|
| 908 |
+
|
| 909 |
+
- **search_repositories** - Search repositories
|
| 910 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 911 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 912 |
+
- `query`: Repository search query. Examples: 'machine learning in:name stars:>1000 language:python', 'topic:react', 'user:facebook'. Supports advanced search syntax for precise filtering. (string, required)
|
| 913 |
+
|
| 914 |
+
</details>
|
| 915 |
+
|
| 916 |
+
<details>
|
| 917 |
+
|
| 918 |
+
<summary>Secret Protection</summary>
|
| 919 |
+
|
| 920 |
+
- **get_secret_scanning_alert** - Get secret scanning alert
|
| 921 |
+
- `alertNumber`: The number of the alert. (number, required)
|
| 922 |
+
- `owner`: The owner of the repository. (string, required)
|
| 923 |
+
- `repo`: The name of the repository. (string, required)
|
| 924 |
+
|
| 925 |
+
- **list_secret_scanning_alerts** - List secret scanning alerts
|
| 926 |
+
- `owner`: The owner of the repository. (string, required)
|
| 927 |
+
- `repo`: The name of the repository. (string, required)
|
| 928 |
+
- `resolution`: Filter by resolution (string, optional)
|
| 929 |
+
- `secret_type`: A comma-separated list of secret types to return. All default secret patterns are returned. To return generic patterns, pass the token name(s) in the parameter. (string, optional)
|
| 930 |
+
- `state`: Filter by state (string, optional)
|
| 931 |
+
|
| 932 |
+
</details>
|
| 933 |
+
|
| 934 |
+
<details>
|
| 935 |
+
|
| 936 |
+
<summary>Security Advisories</summary>
|
| 937 |
+
|
| 938 |
+
- **get_global_security_advisory** - Get a global security advisory
|
| 939 |
+
- `ghsaId`: GitHub Security Advisory ID (format: GHSA-xxxx-xxxx-xxxx). (string, required)
|
| 940 |
+
|
| 941 |
+
- **list_global_security_advisories** - List global security advisories
|
| 942 |
+
- `affects`: Filter advisories by affected package or version (e.g. "package1,package2@1.0.0"). (string, optional)
|
| 943 |
+
- `cveId`: Filter by CVE ID. (string, optional)
|
| 944 |
+
- `cwes`: Filter by Common Weakness Enumeration IDs (e.g. ["79", "284", "22"]). (string[], optional)
|
| 945 |
+
- `ecosystem`: Filter by package ecosystem. (string, optional)
|
| 946 |
+
- `ghsaId`: Filter by GitHub Security Advisory ID (format: GHSA-xxxx-xxxx-xxxx). (string, optional)
|
| 947 |
+
- `isWithdrawn`: Whether to only return withdrawn advisories. (boolean, optional)
|
| 948 |
+
- `modified`: Filter by publish or update date or date range (ISO 8601 date or range). (string, optional)
|
| 949 |
+
- `published`: Filter by publish date or date range (ISO 8601 date or range). (string, optional)
|
| 950 |
+
- `severity`: Filter by severity. (string, optional)
|
| 951 |
+
- `type`: Advisory type. (string, optional)
|
| 952 |
+
- `updated`: Filter by update date or date range (ISO 8601 date or range). (string, optional)
|
| 953 |
+
|
| 954 |
+
- **list_org_repository_security_advisories** - List org repository security advisories
|
| 955 |
+
- `direction`: Sort direction. (string, optional)
|
| 956 |
+
- `org`: The organization login. (string, required)
|
| 957 |
+
- `sort`: Sort field. (string, optional)
|
| 958 |
+
- `state`: Filter by advisory state. (string, optional)
|
| 959 |
+
|
| 960 |
+
- **list_repository_security_advisories** - List repository security advisories
|
| 961 |
+
- `direction`: Sort direction. (string, optional)
|
| 962 |
+
- `owner`: The owner of the repository. (string, required)
|
| 963 |
+
- `repo`: The name of the repository. (string, required)
|
| 964 |
+
- `sort`: Sort field. (string, optional)
|
| 965 |
+
- `state`: Filter by advisory state. (string, optional)
|
| 966 |
+
|
| 967 |
+
</details>
|
| 968 |
+
|
| 969 |
+
<details>
|
| 970 |
+
|
| 971 |
+
<summary>Users</summary>
|
| 972 |
+
|
| 973 |
+
- **search_users** - Search users
|
| 974 |
+
- `order`: Sort order (string, optional)
|
| 975 |
+
- `page`: Page number for pagination (min 1) (number, optional)
|
| 976 |
+
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
| 977 |
+
- `query`: User search query. Examples: 'john smith', 'location:seattle', 'followers:>100'. Search is automatically scoped to type:user. (string, required)
|
| 978 |
+
- `sort`: Sort users by number of followers or repositories, or when the person joined GitHub. (string, optional)
|
| 979 |
+
|
| 980 |
+
</details>
|
| 981 |
+
<!-- END AUTOMATED TOOLS -->
|
| 982 |
+
|
| 983 |
+
### Additional Tools in Remote Github MCP Server
|
| 984 |
+
|
| 985 |
+
<details>
|
| 986 |
+
|
| 987 |
+
<summary>Copilot coding agent</summary>
|
| 988 |
+
|
| 989 |
+
- **create_pull_request_with_copilot** - Perform task with GitHub Copilot coding agent
|
| 990 |
+
- `owner`: Repository owner. You can guess the owner, but confirm it with the user before proceeding. (string, required)
|
| 991 |
+
- `repo`: Repository name. You can guess the repository name, but confirm it with the user before proceeding. (string, required)
|
| 992 |
+
- `problem_statement`: Detailed description of the task to be performed (e.g., 'Implement a feature that does X', 'Fix bug Y', etc.) (string, required)
|
| 993 |
+
- `title`: Title for the pull request that will be created (string, required)
|
| 994 |
+
- `base_ref`: Git reference (e.g., branch) that the agent will start its work from. If not specified, defaults to the repository's default branch (string, optional)
|
| 995 |
+
|
| 996 |
+
</details>
|
| 997 |
+
|
| 998 |
+
#### Specifying Toolsets
|
| 999 |
+
|
| 1000 |
+
To specify toolsets you want available to the LLM, you can pass an allow-list in two ways:
|
| 1001 |
+
|
| 1002 |
+
1. **Using Command Line Argument**:
|
| 1003 |
+
|
| 1004 |
+
```bash
|
| 1005 |
+
github-mcp-server --toolsets repos,issues,pull_requests,actions,code_security
|
| 1006 |
+
```
|
| 1007 |
+
|
| 1008 |
+
2. **Using Environment Variable**:
|
| 1009 |
+
```bash
|
| 1010 |
+
GITHUB_TOOLSETS="repos,issues,pull_requests,actions,code_security" ./github-mcp-server
|
| 1011 |
+
```
|
| 1012 |
+
|
| 1013 |
+
The environment variable `GITHUB_TOOLSETS` takes precedence over the command line argument if both are provided.
|
| 1014 |
+
|
| 1015 |
+
### Using Toolsets With Docker
|
| 1016 |
+
|
| 1017 |
+
When using Docker, you can pass the toolsets as environment variables:
|
| 1018 |
+
|
| 1019 |
+
```bash
|
| 1020 |
+
docker run -i --rm \
|
| 1021 |
+
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
|
| 1022 |
+
-e GITHUB_TOOLSETS="repos,issues,pull_requests,actions,code_security,experiments" \
|
| 1023 |
+
ghcr.io/github/github-mcp-server
|
| 1024 |
+
```
|
| 1025 |
+
|
| 1026 |
+
### The "all" Toolset
|
| 1027 |
+
|
| 1028 |
+
The special toolset `all` can be provided to enable all available toolsets regardless of any other configuration:
|
| 1029 |
+
|
| 1030 |
+
```bash
|
| 1031 |
+
./github-mcp-server --toolsets all
|
| 1032 |
+
```
|
| 1033 |
+
|
| 1034 |
+
Or using the environment variable:
|
| 1035 |
+
|
| 1036 |
+
```bash
|
| 1037 |
+
GITHUB_TOOLSETS="all" ./github-mcp-server
|
| 1038 |
+
```
|
| 1039 |
+
|
| 1040 |
+
## Dynamic Tool Discovery
|
| 1041 |
+
|
| 1042 |
+
**Note**: This feature is currently in beta and may not be available in all environments. Please test it out and let us know if you encounter any issues.
|
| 1043 |
+
|
| 1044 |
+
Instead of starting with all tools enabled, you can turn on dynamic toolset discovery. Dynamic toolsets allow the MCP host to list and enable toolsets in response to a user prompt. This should help to avoid situations where the model gets confused by the sheer number of tools available.
|
| 1045 |
+
|
| 1046 |
+
### Using Dynamic Tool Discovery
|
| 1047 |
+
|
| 1048 |
+
When using the binary, you can pass the `--dynamic-toolsets` flag.
|
| 1049 |
+
|
| 1050 |
+
```bash
|
| 1051 |
+
./github-mcp-server --dynamic-toolsets
|
| 1052 |
+
```
|
| 1053 |
+
|
| 1054 |
+
When using Docker, you can pass the toolsets as environment variables:
|
| 1055 |
+
|
| 1056 |
+
```bash
|
| 1057 |
+
docker run -i --rm \
|
| 1058 |
+
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
|
| 1059 |
+
-e GITHUB_DYNAMIC_TOOLSETS=1 \
|
| 1060 |
+
ghcr.io/github/github-mcp-server
|
| 1061 |
+
```
|
| 1062 |
+
|
| 1063 |
+
## Read-Only Mode
|
| 1064 |
+
|
| 1065 |
+
To run the server in read-only mode, you can use the `--read-only` flag. This will only offer read-only tools, preventing any modifications to repositories, issues, pull requests, etc.
|
| 1066 |
+
|
| 1067 |
+
```bash
|
| 1068 |
+
./github-mcp-server --read-only
|
| 1069 |
+
```
|
| 1070 |
+
|
| 1071 |
+
When using Docker, you can pass the read-only mode as an environment variable:
|
| 1072 |
+
|
| 1073 |
+
```bash
|
| 1074 |
+
docker run -i --rm \
|
| 1075 |
+
-e GITHUB_PERSONAL_ACCESS_TOKEN=<your-token> \
|
| 1076 |
+
-e GITHUB_READ_ONLY=1 \
|
| 1077 |
+
ghcr.io/github/github-mcp-server
|
| 1078 |
+
```
|
| 1079 |
+
|
| 1080 |
+
## GitHub Enterprise Server and Enterprise Cloud with data residency (ghe.com)
|
| 1081 |
+
|
| 1082 |
+
The flag `--gh-host` and the environment variable `GITHUB_HOST` can be used to set
|
| 1083 |
+
the hostname for GitHub Enterprise Server or GitHub Enterprise Cloud with data residency.
|
| 1084 |
+
|
| 1085 |
+
- For GitHub Enterprise Server, prefix the hostname with the `https://` URI scheme, as it otherwise defaults to `http://`, which GitHub Enterprise Server does not support.
|
| 1086 |
+
- For GitHub Enterprise Cloud with data residency, use `https://YOURSUBDOMAIN.ghe.com` as the hostname.
|
| 1087 |
+
``` json
|
| 1088 |
+
"github": {
|
| 1089 |
+
"command": "docker",
|
| 1090 |
+
"args": [
|
| 1091 |
+
"run",
|
| 1092 |
+
"-i",
|
| 1093 |
+
"--rm",
|
| 1094 |
+
"-e",
|
| 1095 |
+
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
| 1096 |
+
"-e",
|
| 1097 |
+
"GITHUB_HOST",
|
| 1098 |
+
"ghcr.io/github/github-mcp-server"
|
| 1099 |
+
],
|
| 1100 |
+
"env": {
|
| 1101 |
+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}",
|
| 1102 |
+
"GITHUB_HOST": "https://<your GHES or ghe.com domain name>"
|
| 1103 |
+
}
|
| 1104 |
+
}
|
| 1105 |
+
```
|
| 1106 |
+
|
| 1107 |
+
## i18n / Overriding Descriptions
|
| 1108 |
+
|
| 1109 |
+
The descriptions of the tools can be overridden by creating a
|
| 1110 |
+
`github-mcp-server-config.json` file in the same directory as the binary.
|
| 1111 |
+
|
| 1112 |
+
The file should contain a JSON object with the tool names as keys and the new
|
| 1113 |
+
descriptions as values. For example:
|
| 1114 |
+
|
| 1115 |
+
```json
|
| 1116 |
+
{
|
| 1117 |
+
"TOOL_ADD_ISSUE_COMMENT_DESCRIPTION": "an alternative description",
|
| 1118 |
+
"TOOL_CREATE_BRANCH_DESCRIPTION": "Create a new branch in a GitHub repository"
|
| 1119 |
+
}
|
| 1120 |
+
```
|
| 1121 |
+
|
| 1122 |
+
You can create an export of the current translations by running the binary with
|
| 1123 |
+
the `--export-translations` flag.
|
| 1124 |
+
|
| 1125 |
+
This flag will preserve any translations/overrides you have made, while adding
|
| 1126 |
+
any new translations that have been added to the binary since the last time you
|
| 1127 |
+
exported.
|
| 1128 |
+
|
| 1129 |
+
```sh
|
| 1130 |
+
./github-mcp-server --export-translations
|
| 1131 |
+
cat github-mcp-server-config.json
|
| 1132 |
```
|
| 1133 |
+
|
| 1134 |
+
You can also use ENV vars to override the descriptions. The environment
|
| 1135 |
+
variable names are the same as the keys in the JSON file, prefixed with
|
| 1136 |
+
`GITHUB_MCP_` and all uppercase.
|
| 1137 |
+
|
| 1138 |
+
For example, to override the `TOOL_ADD_ISSUE_COMMENT_DESCRIPTION` tool, you can
|
| 1139 |
+
set the following environment variable:
|
| 1140 |
+
|
| 1141 |
+
```sh
|
| 1142 |
+
export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description"
|
| 1143 |
```
|
| 1144 |
|
| 1145 |
+
## Library Usage
|
| 1146 |
+
|
| 1147 |
+
The exported Go API of this module should currently be considered unstable, and subject to breaking changes. In the future, we may offer stability; please file an issue if there is a use case where this would be valuable.
|
| 1148 |
+
|
| 1149 |
+
## License
|
| 1150 |
|
| 1151 |
+
This project is licensed under the terms of the MIT open source license. Please refer to [MIT](./LICENSE) for the full terms.
|
| 1152 |
|
| 1153 |
+
```json
|
| 1154 |
|
| 1155 |
+
## Contributing
|
|
|
|
|
|
|
|
|
|
| 1156 |
|
| 1157 |
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1158 |
|
| 1159 |
+
## Support
|
| 1160 |
|
| 1161 |
+
See [SUPPORT.md](SUPPORT.md).
|
|
|
|
|
|
|
| 1162 |
|
| 1163 |
+
## Security
|
| 1164 |
|
| 1165 |
+
See [SECURITY.md](SECURITY.md).
|
|
|
|
|
|
|
|
|
|
| 1166 |
|
| 1167 |
+
## Third-Party Licenses
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1168 |
|
| 1169 |
+
See [third-party-licenses.linux.md](third-party-licenses.linux.md), [third-party-licenses.darwin.md](third-party-licenses.darwin.md), and [third-party-licenses.windows.md](third-party-licenses.windows.md).
|
app.py
CHANGED
|
@@ -1,199 +1,60 @@
|
|
| 1 |
import asyncio
|
| 2 |
import os
|
| 3 |
-
import logging
|
| 4 |
-
import requests
|
| 5 |
-
import json
|
| 6 |
from fastapi import FastAPI, Request, Response
|
| 7 |
|
| 8 |
-
# Set up logging with more detailed configuration
|
| 9 |
-
logging.basicConfig(
|
| 10 |
-
level=logging.DEBUG,
|
| 11 |
-
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
| 12 |
-
)
|
| 13 |
-
logger = logging.getLogger(__name__)
|
| 14 |
-
|
| 15 |
app = FastAPI()
|
| 16 |
proc = None
|
| 17 |
|
| 18 |
@app.on_event("startup")
|
| 19 |
async def startup_event():
|
| 20 |
global proc
|
| 21 |
-
logger.info("=== STARTUP EVENT ===")
|
| 22 |
# Get the token from an environment variable on the Hugging Face Space
|
|
|
|
| 23 |
token = os.environ.get("GITHUB_PERSONAL_ACCESS_TOKEN")
|
| 24 |
-
logger.info("Attempting to start subprocess...")
|
| 25 |
-
logger.info("Token environment variable exists: %s", token is not None)
|
| 26 |
-
|
| 27 |
if not token:
|
| 28 |
-
|
| 29 |
return
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
env={"GITHUB_PERSONAL_ACCESS_TOKEN": token}
|
| 40 |
-
)
|
| 41 |
-
logger.info("Subprocess created successfully with PID: %s", proc.pid)
|
| 42 |
-
|
| 43 |
-
# Check if subprocess is actually running
|
| 44 |
-
if proc.returncode is None:
|
| 45 |
-
logger.info("Subprocess appears to be running")
|
| 46 |
-
else:
|
| 47 |
-
logger.warning("Subprocess may have exited immediately with code: %s", proc.returncode)
|
| 48 |
-
|
| 49 |
-
# Start the background task to log stderr
|
| 50 |
-
asyncio.create_task(log_stderr())
|
| 51 |
-
logger.info("=== STARTUP COMPLETE ===")
|
| 52 |
-
except Exception as e:
|
| 53 |
-
logger.error("Failed to create subprocess: %s", str(e))
|
| 54 |
-
# Re-raise to crash the application startup, as the proxy cannot function without the subprocess
|
| 55 |
-
raise
|
| 56 |
|
| 57 |
async def log_stderr():
|
| 58 |
-
"""Reads and logs output from the subprocess's stderr stream."""
|
| 59 |
if proc and proc.stderr:
|
| 60 |
-
logger.info("Starting stderr logging task")
|
| 61 |
while not proc.stderr.at_eof():
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
if line:
|
| 66 |
-
logger.debug("github-mcp-server stderr: %s", line.decode().strip())
|
| 67 |
-
else:
|
| 68 |
-
logger.debug("Empty line from stderr")
|
| 69 |
-
except Exception as e:
|
| 70 |
-
logger.error("Error reading stderr: %s", str(e))
|
| 71 |
-
break
|
| 72 |
|
| 73 |
@app.post("/")
|
| 74 |
async def proxy(request: Request):
|
| 75 |
-
logger.info("=== NEW REQUEST RECEIVED ===")
|
| 76 |
-
logger.info("Request method: %s", request.method)
|
| 77 |
-
logger.info("Request headers: %s", dict(request.headers))
|
| 78 |
-
|
| 79 |
-
# 1. Check subprocess health
|
| 80 |
if not proc or not proc.stdin or not proc.stdout:
|
| 81 |
-
logger.error("Subprocess not running - returning 500")
|
| 82 |
return Response(status_code=500, content="Subprocess not running")
|
| 83 |
|
| 84 |
-
# 2. Log incoming request body
|
| 85 |
body = await request.body()
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
# 3. Token verification for debugging (Synchronous call to external API)
|
| 90 |
-
token = os.environ.get("GITHUB_PERSONAL_ACCESS_TOKEN")
|
| 91 |
-
if token:
|
| 92 |
-
try:
|
| 93 |
-
logger.info("Testing GitHub token with API call...")
|
| 94 |
-
# Note: requests.get is blocking, but typically fast enough here.
|
| 95 |
-
response_gh = requests.get("https://api.github.com/user", headers={"Authorization": f"token {token}"}, timeout=5)
|
| 96 |
-
logger.info("Token verification response status: %s", response_gh.status_code)
|
| 97 |
-
if response_gh.status_code == 200:
|
| 98 |
-
logger.info("GitHub token verification successful")
|
| 99 |
-
else:
|
| 100 |
-
logger.error("GitHub token verification failed with status code: %s", response_gh.status_code)
|
| 101 |
-
except Exception as e:
|
| 102 |
-
logger.error("Error verifying GitHub token: %s", str(e))
|
| 103 |
-
else:
|
| 104 |
-
logger.warning("No GitHub token found in environment")
|
| 105 |
-
|
| 106 |
-
# 4. Send request to subprocess
|
| 107 |
-
logger.info("Sending request to subprocess...")
|
| 108 |
-
try:
|
| 109 |
-
proc.stdin.write(body)
|
| 110 |
-
await proc.stdin.drain()
|
| 111 |
-
logger.info("Successfully wrote request body to subprocess stdin")
|
| 112 |
-
except Exception as e:
|
| 113 |
-
logger.error("Error writing to subprocess stdin: %s", str(e))
|
| 114 |
-
return Response(status_code=500, content=f"Error writing to subprocess: {str(e)}")
|
| 115 |
|
| 116 |
-
# 5. Read response with timeout and robust JSON detection
|
| 117 |
-
logger.info("Reading response from subprocess with timeout...")
|
| 118 |
response = bytearray()
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
while True:
|
| 124 |
-
elapsed = asyncio.get_event_loop().time() - start_time
|
| 125 |
-
if elapsed > timeout_seconds:
|
| 126 |
-
logger.error("Timeout reading response from subprocess after %d seconds", timeout_seconds)
|
| 127 |
break
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
# Use wait_for to enforce a per-read timeout
|
| 131 |
-
chunk = await asyncio.wait_for(proc.stdout.read(1024), timeout=5.0)
|
| 132 |
-
logger.debug("Received chunk of size: %d", len(chunk))
|
| 133 |
-
|
| 134 |
-
if not chunk:
|
| 135 |
-
logger.info("EOF reached from subprocess")
|
| 136 |
-
break
|
| 137 |
-
|
| 138 |
-
response.extend(chunk)
|
| 139 |
-
logger.debug("Extended response with chunk, total size: %d", len(response))
|
| 140 |
-
|
| 141 |
-
# Check for complete JSON-RPC message
|
| 142 |
-
try:
|
| 143 |
-
response_str = bytes(response).decode("utf-8")
|
| 144 |
-
|
| 145 |
-
if len(response_str.strip()) > 0:
|
| 146 |
-
# Attempt to parse as JSON
|
| 147 |
-
try:
|
| 148 |
-
json_data = json.loads(response_str)
|
| 149 |
-
|
| 150 |
-
# Check for mandatory JSON-RPC fields in a response
|
| 151 |
-
if isinstance(json_data, dict) and "jsonrpc" in json_data:
|
| 152 |
-
if "id" in json_data or "error" in json_data:
|
| 153 |
-
logger.info("Complete JSON-RPC response detected")
|
| 154 |
-
# Log only a preview of the full response
|
| 155 |
-
logger.info("Full response preview: %s", response_str[:200] + "..." if len(response_str) > 200 else response_str)
|
| 156 |
-
break
|
| 157 |
-
# If it's a request, we keep reading (though the subprocess should only send responses)
|
| 158 |
-
else:
|
| 159 |
-
logger.debug("JSON-RPC object found, but not a final response (missing 'id' or 'error'). Continuing to read.")
|
| 160 |
-
|
| 161 |
-
except json.JSONDecodeError as e:
|
| 162 |
-
# Expected when reading partial JSON data. Continue reading.
|
| 163 |
-
logger.debug("JSON parsing failed (partial read): %s", str(e))
|
| 164 |
-
continue
|
| 165 |
-
else:
|
| 166 |
-
logger.debug("Empty response, continuing to read")
|
| 167 |
-
continue
|
| 168 |
-
except UnicodeDecodeError as e:
|
| 169 |
-
logger.warning("Decoding failed (partial multi-byte char): %s", str(e))
|
| 170 |
-
continue
|
| 171 |
-
except asyncio.TimeoutError:
|
| 172 |
-
logger.warning("Timeout waiting for chunk from subprocess, continuing loop.")
|
| 173 |
-
# This timeout is okay, it allows the main timeout check to fire if needed.
|
| 174 |
-
continue
|
| 175 |
-
except Exception as e:
|
| 176 |
-
logger.error("Error reading chunk from subprocess: %s", str(e))
|
| 177 |
break
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
logger.error("Error in primary response reading loop: %s", str(e))
|
| 181 |
-
return Response(status_code=500, content=f"Error reading response: {str(e)}")
|
| 182 |
-
|
| 183 |
-
# 6. Final response check and return
|
| 184 |
-
logger.info("Final response size: %d bytes", len(response))
|
| 185 |
-
if len(response) == 0:
|
| 186 |
-
logger.error("Final response is empty after reading loop.")
|
| 187 |
|
| 188 |
-
logger.info("=== REQUEST PROCESSING COMPLETE ===")
|
| 189 |
return Response(content=bytes(response))
|
| 190 |
|
| 191 |
@app.on_event("shutdown")
|
| 192 |
async def shutdown_event():
|
| 193 |
-
logger.info("=== SHUTDOWN EVENT ===")
|
| 194 |
if proc:
|
| 195 |
-
logger.info("Shutting down subprocess...")
|
| 196 |
proc.kill()
|
| 197 |
await proc.wait()
|
| 198 |
-
logger.info("Subprocess shut down")
|
| 199 |
-
logger.info("=== SHUTDOWN COMPLETE ===")
|
|
|
|
| 1 |
import asyncio
|
| 2 |
import os
|
|
|
|
|
|
|
|
|
|
| 3 |
from fastapi import FastAPI, Request, Response
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
app = FastAPI()
|
| 6 |
proc = None
|
| 7 |
|
| 8 |
@app.on_event("startup")
|
| 9 |
async def startup_event():
|
| 10 |
global proc
|
|
|
|
| 11 |
# Get the token from an environment variable on the Hugging Face Space
|
| 12 |
+
# This is a more secure way to handle the token
|
| 13 |
token = os.environ.get("GITHUB_PERSONAL_ACCESS_TOKEN")
|
|
|
|
|
|
|
|
|
|
| 14 |
if not token:
|
| 15 |
+
print("GITHUB_PERSONAL_ACCESS_TOKEN environment variable not set")
|
| 16 |
return
|
| 17 |
|
| 18 |
+
proc = await asyncio.create_subprocess_exec(
|
| 19 |
+
'/usr/local/bin/github-mcp-server', 'stdio',
|
| 20 |
+
stdin=asyncio.subprocess.PIPE,
|
| 21 |
+
stdout=asyncio.subprocess.PIPE,
|
| 22 |
+
stderr=asyncio.subprocess.PIPE,
|
| 23 |
+
env={"GITHUB_PERSONAL_ACCESS_TOKEN": token}
|
| 24 |
+
)
|
| 25 |
+
asyncio.create_task(log_stderr())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
async def log_stderr():
|
|
|
|
| 28 |
if proc and proc.stderr:
|
|
|
|
| 29 |
while not proc.stderr.at_eof():
|
| 30 |
+
line = await proc.stderr.readline()
|
| 31 |
+
print(f"github-mcp-server stderr: {line.decode().strip()}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
@app.post("/")
|
| 34 |
async def proxy(request: Request):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
if not proc or not proc.stdin or not proc.stdout:
|
|
|
|
| 36 |
return Response(status_code=500, content="Subprocess not running")
|
| 37 |
|
|
|
|
| 38 |
body = await request.body()
|
| 39 |
+
proc.stdin.write(body)
|
| 40 |
+
await proc.stdin.drain()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
|
|
|
|
|
|
| 42 |
response = bytearray()
|
| 43 |
+
while True:
|
| 44 |
+
try:
|
| 45 |
+
chunk = await asyncio.wait_for(proc.stdout.read(1024), timeout=1.0)
|
| 46 |
+
if not chunk:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
break
|
| 48 |
+
response.extend(chunk)
|
| 49 |
+
if chunk.strip().endswith(b'}'):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
break
|
| 51 |
+
except asyncio.TimeoutError:
|
| 52 |
+
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
|
|
|
| 54 |
return Response(content=bytes(response))
|
| 55 |
|
| 56 |
@app.on_event("shutdown")
|
| 57 |
async def shutdown_event():
|
|
|
|
| 58 |
if proc:
|
|
|
|
| 59 |
proc.kill()
|
| 60 |
await proc.wait()
|
|
|
|
|
|
cmd/github-mcp-server/main.go
CHANGED
|
@@ -1,114 +1,116 @@
|
|
| 1 |
package main
|
| 2 |
|
| 3 |
import (
|
| 4 |
-
"
|
| 5 |
-
"
|
| 6 |
-
"
|
| 7 |
-
"
|
| 8 |
-
|
| 9 |
-
"
|
| 10 |
-
"
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
|
| 14 |
-
"github.com/mark3labs/mcp-go/mcp" // Fixed import path
|
| 15 |
-
"github.com/mark3labs/mcp-go/mcp/protocol"
|
| 16 |
-
"github.com/spf13/viper"
|
| 17 |
)
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
)
|
| 23 |
|
| 24 |
-
func
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
//
|
| 51 |
-
|
| 52 |
-
w.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS")
|
| 53 |
-
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
|
| 54 |
-
|
| 55 |
-
// Handle preflight requests
|
| 56 |
-
if r.Method == "OPTIONS" {
|
| 57 |
-
w.WriteHeader(http.StatusOK)
|
| 58 |
-
return
|
| 59 |
}
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
}
|
| 66 |
|
| 67 |
-
// Read the request body
|
| 68 |
-
body, err := io.ReadAll(r.Body)
|
| 69 |
-
if err != nil {
|
| 70 |
-
http.Error(w, "Error reading request body", http.StatusBadRequest)
|
| 71 |
-
return
|
| 72 |
-
}
|
| 73 |
-
defer r.Body.Close()
|
| 74 |
-
|
| 75 |
-
// Log the incoming request
|
| 76 |
-
log.Printf("Received request: %s", string(body))
|
| 77 |
-
|
| 78 |
-
// Create a subprocess to handle the request
|
| 79 |
-
cmd := exec.CommandContext(ctx, "/usr/local/bin/github-mcp-server")
|
| 80 |
-
cmd.Stdin = bytes.NewReader(body)
|
| 81 |
-
cmd.Stdout = w
|
| 82 |
-
cmd.Stderr = os.Stderr
|
| 83 |
-
|
| 84 |
-
// Start the subprocess
|
| 85 |
-
log.Printf("Starting subprocess: /usr/local/bin/github-mcp-server")
|
| 86 |
-
if err := cmd.Start(); err != nil {
|
| 87 |
-
log.Printf("Error starting subprocess: %v", err)
|
| 88 |
-
http.Error(w, "Error starting subprocess", http.StatusInternalServerError)
|
| 89 |
-
return
|
| 90 |
}
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
if ctx.Err() == context.DeadlineExceeded {
|
| 98 |
-
log.Printf("Subprocess timed out after %d seconds", timeoutSeconds)
|
| 99 |
-
http.Error(w, "Subprocess timed out", http.StatusRequestTimeout)
|
| 100 |
-
return
|
| 101 |
-
}
|
| 102 |
-
http.Error(w, "Subprocess error", http.StatusInternalServerError)
|
| 103 |
-
return
|
| 104 |
}
|
| 105 |
|
| 106 |
-
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
}
|
| 114 |
}
|
|
|
|
| 1 |
package main
|
| 2 |
|
| 3 |
import (
|
| 4 |
+
"errors"
|
| 5 |
+
"fmt"
|
| 6 |
+
"os"
|
| 7 |
+
"strings"
|
| 8 |
+
|
| 9 |
+
"github.com/github/github-mcp-server/internal/ghmcp"
|
| 10 |
+
"github.com/github/github-mcp-server/pkg/github"
|
| 11 |
+
"github.com/spf13/cobra"
|
| 12 |
+
"github.com/spf13/pflag"
|
| 13 |
+
"github.com/spf13/viper"
|
|
|
|
|
|
|
|
|
|
| 14 |
)
|
| 15 |
|
| 16 |
+
// These variables are set by the build process using ldflags.
|
| 17 |
+
var version = "version"
|
| 18 |
+
var commit = "commit"
|
| 19 |
+
var date = "date"
|
| 20 |
+
|
| 21 |
+
var (
|
| 22 |
+
rootCmd = &cobra.Command{
|
| 23 |
+
Use: "server",
|
| 24 |
+
Short: "GitHub MCP Server",
|
| 25 |
+
Long: `A GitHub MCP server that handles various tools and resources.`,
|
| 26 |
+
Version: fmt.Sprintf("Version: %s\nCommit: %s\nBuild Date: %s", version, commit, date),
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
stdioCmd = &cobra.Command{
|
| 30 |
+
Use: "stdio",
|
| 31 |
+
Short: "Start stdio server",
|
| 32 |
+
Long: `Start a server that communicates via standard input/output streams using JSON-RPC messages.`,
|
| 33 |
+
RunE: func(_ *cobra.Command, _ []string) error {
|
| 34 |
+
token := viper.GetString("personal_access_token")
|
| 35 |
+
if token == "" {
|
| 36 |
+
return errors.New("GITHUB_PERSONAL_ACCESS_TOKEN not set")
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
// If you're wondering why we're not using viper.GetStringSlice("toolsets"),
|
| 40 |
+
// it's because viper doesn't handle comma-separated values correctly for env
|
| 41 |
+
// vars when using GetStringSlice.
|
| 42 |
+
// https://github.com/spf13/viper/issues/380
|
| 43 |
+
var enabledToolsets []string
|
| 44 |
+
if err := viper.UnmarshalKey("toolsets", &enabledToolsets); err != nil {
|
| 45 |
+
return fmt.Errorf("failed to unmarshal toolsets: %w", err)
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
stdioServerConfig := ghmcp.StdioServerConfig{
|
| 49 |
+
Version: version,
|
| 50 |
+
Host: viper.GetString("host"),
|
| 51 |
+
Token: token,
|
| 52 |
+
EnabledToolsets: enabledToolsets,
|
| 53 |
+
DynamicToolsets: viper.GetBool("dynamic_toolsets"),
|
| 54 |
+
ReadOnly: viper.GetBool("read-only"),
|
| 55 |
+
ExportTranslations: viper.GetBool("export-translations"),
|
| 56 |
+
EnableCommandLogging: viper.GetBool("enable-command-logging"),
|
| 57 |
+
LogFilePath: viper.GetString("log-file"),
|
| 58 |
+
ContentWindowSize: viper.GetInt("content-window-size"),
|
| 59 |
+
}
|
| 60 |
+
return ghmcp.RunStdioServer(stdioServerConfig)
|
| 61 |
+
},
|
| 62 |
+
}
|
| 63 |
)
|
| 64 |
|
| 65 |
+
func init() {
|
| 66 |
+
cobra.OnInitialize(initConfig)
|
| 67 |
+
rootCmd.SetGlobalNormalizationFunc(wordSepNormalizeFunc)
|
| 68 |
+
|
| 69 |
+
rootCmd.SetVersionTemplate("{{.Short}}\n{{.Version}}\n")
|
| 70 |
+
|
| 71 |
+
// Add global flags that will be shared by all commands
|
| 72 |
+
rootCmd.PersistentFlags().StringSlice("toolsets", github.DefaultTools, "An optional comma separated list of groups of tools to allow, defaults to enabling all")
|
| 73 |
+
rootCmd.PersistentFlags().Bool("dynamic-toolsets", false, "Enable dynamic toolsets")
|
| 74 |
+
rootCmd.PersistentFlags().Bool("read-only", false, "Restrict the server to read-only operations")
|
| 75 |
+
rootCmd.PersistentFlags().String("log-file", "", "Path to log file")
|
| 76 |
+
rootCmd.PersistentFlags().Bool("enable-command-logging", false, "When enabled, the server will log all command requests and responses to the log file")
|
| 77 |
+
rootCmd.PersistentFlags().Bool("export-translations", false, "Save translations to a JSON file")
|
| 78 |
+
rootCmd.PersistentFlags().String("gh-host", "", "Specify the GitHub hostname (for GitHub Enterprise etc.)")
|
| 79 |
+
rootCmd.PersistentFlags().Int("content-window-size", 5000, "Specify the content window size")
|
| 80 |
+
|
| 81 |
+
// Bind flag to viper
|
| 82 |
+
_ = viper.BindPFlag("toolsets", rootCmd.PersistentFlags().Lookup("toolsets"))
|
| 83 |
+
_ = viper.BindPFlag("dynamic_toolsets", rootCmd.PersistentFlags().Lookup("dynamic-toolsets"))
|
| 84 |
+
_ = viper.BindPFlag("read-only", rootCmd.PersistentFlags().Lookup("read-only"))
|
| 85 |
+
_ = viper.BindPFlag("log-file", rootCmd.PersistentFlags().Lookup("log-file"))
|
| 86 |
+
_ = viper.BindPFlag("enable-command-logging", rootCmd.PersistentFlags().Lookup("enable-command-logging"))
|
| 87 |
+
_ = viper.BindPFlag("export-translations", rootCmd.PersistentFlags().Lookup("export-translations"))
|
| 88 |
+
_ = viper.BindPFlag("host", rootCmd.PersistentFlags().Lookup("gh-host"))
|
| 89 |
+
_ = viper.BindPFlag("content-window-size", rootCmd.PersistentFlags().Lookup("content-window-size"))
|
| 90 |
+
|
| 91 |
+
// Add subcommands
|
| 92 |
+
rootCmd.AddCommand(stdioCmd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
}
|
| 94 |
|
| 95 |
+
func initConfig() {
|
| 96 |
+
// Initialize Viper configuration
|
| 97 |
+
viper.SetEnvPrefix("github")
|
| 98 |
+
viper.AutomaticEnv()
|
|
|
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
}
|
| 101 |
|
| 102 |
+
func main() {
|
| 103 |
+
if err := rootCmd.Execute(); err != nil {
|
| 104 |
+
fmt.Fprintf(os.Stderr, "%v\n", err)
|
| 105 |
+
os.Exit(1)
|
| 106 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
}
|
| 108 |
|
| 109 |
+
func wordSepNormalizeFunc(_ *pflag.FlagSet, name string) pflag.NormalizedName {
|
| 110 |
+
from := []string{"_"}
|
| 111 |
+
to := "-"
|
| 112 |
+
for _, sep := range from {
|
| 113 |
+
name = strings.ReplaceAll(name, sep, to)
|
| 114 |
+
}
|
| 115 |
+
return pflag.NormalizedName(name)
|
|
|
|
| 116 |
}
|
requirements.txt
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
fastapi
|
| 2 |
uvicorn[standard]
|
| 3 |
python-jsonrpc-server
|
| 4 |
-
requests
|
|
|
|
| 1 |
fastapi
|
| 2 |
uvicorn[standard]
|
| 3 |
python-jsonrpc-server
|
|
|