Skip to content

pratik-mahalle/github-mcp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Server for GitHub Pull Request Automation

MCP (Merge and Create Pull Request) Server is a Go-based application designed to automate GitHub pull requests (PRs). It listens for GitHub webhook events (such as push and PR events) and automatically creates or merges pull requests based on specific conditions.

Features

  • Automate PR creation: Automatically create pull requests for branches that follow a feature/ naming convention.
  • Merge Pull Requests: Merge pull requests with a selected strategy (merge, squash, or rebase).
  • Handle Webhooks: Listens for GitHub webhook events to trigger actions on push or pull request events.

Requirements

  • Go 1.18+ (for building and running the server)
  • GitHub account with access to repositories
  • Ngrok (for tunneling your local server to a public URL, required for GitHub webhook testing)

Setup Instructions

1. Clone the Repository

Clone this repository to your local machine.

git clone https://github.com/your-username/github_mcp.git
cd github_mcp

2. Install Dependencies

Install the required dependencies using go get.

go mod tidy

3. Configure Environment Variables

Create the Env Variables file with your credentials.

GITHUB_TOKEN=your_github_personal_access_token
OWNER=your_github_username
REPO=your_github_repository
BASE_BRANCH=main

4. Install Ngrok

If you are testing GitHub webhooks locally, you can use Ngrok to expose your local server to the internet.

Download and install Ngrok from https://ngrok.com/download.

After installing Ngrok, run it on port 8080:

ngrok http 8080

This will give you a public URL that you can use to set up the webhook in your GitHub repository.(If you have something better to expose your app, go with it.)

5. Run the Server

Run the server using the following command:

go run main.go

This will start the server on http://localhost:8080.

6. Set Up GitHub Webhook

  1. Go to your GitHub repository.
  2. Navigate to Settings > Webhooks > Add webhook.
  3. In the Payload URL field, enter the Ngrok URL or your local server URL: http://<ngrok-url>/webhook (e.g., http://1234.ngrok.io/webhook).
  4. Set the Content type to application/json.
  5. Choose the events that will trigger the webhook, typically Push and Pull request.
  6. Save the webhook.

7. Test

  • Make a push to a branch that starts with feature/ (e.g., feature/new-feature).
  • The server will automatically create a pull request from that branch to the base branch.
  • If a pull request is closed and merged, it will be logged and the status will be updated.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is open-source and available under the MIT License. `

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages