# How to Build the GitHub MCP Server Binary from Source: Complete Guide

> Learn how to build the GitHub MCP Server binary from source. This guide details the Go build process, ldflags for versioning, and Docker packaging for effortless deployment.

- Repository: [GitHub/github-mcp-server](https://github.com/github/github-mcp-server)
- Tags: how-to-guide
- Published: 2026-02-16

---

**The GitHub MCP Server is a pure Go application that bundles a Vite-built static UI, compiled using `go build` with ldflags for version injection, and optionally packaged via a multi-stage Dockerfile.**

Building the MCP server binary from source requires combining Node.js and Go toolchains to compile both the web interface and the server executable. The `github/github-mcp-server` repository provides automated scripts and a Dockerfile to streamline this process, whether you are developing locally or creating a container image.

## Prerequisites for Building from Source

Before compiling the binary, ensure your environment meets the following requirements:

- **Go 1.24 or later** – The server is written in Go and requires a recent toolchain version.
- **Node.js 20+ and npm** – Required only if building the UI assets (the `ui/` directory contains a Vite-based React application).
- **Git** – Used to inject commit hashes and build dates into the binary via ldflags.
- **Make (optional)** – Some helper scripts assume a Unix-like environment.

## Step-by-Step Build Process

The build process for the MCP server binary from source consists of three logical phases: compiling the UI assets (optional), building the Go binary, and verifying the output.

### Building the UI Assets (Optional)

The server embeds a static UI located in the `ui/` directory. If you want the web interface bundled into the binary, you must build these assets first:

```bash

# From the repository root

./script/build-ui

```

This script executes `npm ci && npm run build` inside the `ui/` directory, generating static files that the Go build process embeds into the binary. If you skip this step, the server will still compile, but the UI features will be unavailable.

### Compiling the Go Binary

With the UI assets prepared (or skipped), compile the server using the standard Go toolchain. The entry point is located at [`cmd/github-mcp-server/main.go`](https://github.com/github/github-mcp-server/blob/main/cmd/github-mcp-server/main.go):

```bash

# Basic build

go build -o github-mcp-server ./cmd/github-mcp-server

```

For production builds, inject version metadata using ldflags to match the official release process:

```bash

# Production build with version injection

VERSION=$(git describe --tags --always)
COMMIT=$(git rev-parse HEAD)
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)

go build -ldflags="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o github-mcp-server ./cmd/github-mcp-server

```

The `script/list-scopes` file in the repository demonstrates this exact pattern, ensuring builds are reproducible and versioned correctly.

### Verifying the Build

Test the compiled binary by running it in `stdio` mode (requires a GitHub Personal Access Token):

```bash
export GITHUB_PERSONAL_ACCESS_TOKEN=ghp_XXXXXXXXXXXXXXXXXXXX
./github-mcp-server stdio

```

If the binary executes without errors and responds to MCP protocol requests, your build process for the MCP server binary from source was successful.

## Docker Multi-Stage Build (Alternative)

For containerized deployments, the repository provides a Dockerfile that automates the entire build process. This approach uses multi-stage builds to keep the final image minimal:

```dockerfile

# Stage 1: Build UI

FROM node:20-alpine AS ui-build
WORKDIR /app
COPY ui/package*.json ./
RUN npm ci
COPY ui/ .
RUN npm run build

# Stage 2: Build Go binary

FROM golang:1.25.7-alpine AS build
ARG VERSION="dev"
WORKDIR /build
RUN apk add --no-cache git
COPY . .
COPY --from=ui-build /app/pkg/github/ui_dist/ ./pkg/github/ui_dist/
RUN 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)" -o /bin/github-mcp-server ./cmd/github-mcp-server

# Stage 3: Final minimal image

FROM gcr.io/distroless/base-debian12
WORKDIR /server
COPY --from=build /bin/github-mcp-server .
EXPOSE 8082
ENTRYPOINT ["/server/github-mcp-server"]
CMD ["stdio"]

```

Build the image with:

```bash
docker build -t ghcr.io/github/github-mcp-server .

```

The resulting image contains only the compiled binary and embedded UI assets, with no build tools or source code included.

## Summary

- The **build process for the MCP server binary from source** combines a Node.js/Vite UI build with standard Go compilation.
- **UI assets** in the `ui/` directory are optional but required for full functionality; build them using `./script/build-ui` before compiling Go.
- **Go compilation** uses `go build -o github-mcp-server ./cmd/github-mcp-server`, with production builds requiring ldflags to inject version metadata via `main.version`, `main.commit`, and `main.date`.
- **Docker** provides a reproducible multi-stage build that handles both UI and Go compilation, outputting a minimal distroless image.
- Key source files include [`cmd/github-mcp-server/main.go`](https://github.com/github/github-mcp-server/blob/main/cmd/github-mcp-server/main.go) (entry point), `Dockerfile` (container build), and helper scripts in `script/build-ui` and `script/list-scopes`.

## Frequently Asked Questions

### What Go version is required to build the GitHub MCP Server?

The GitHub MCP Server requires **Go 1.24 or later** to compile successfully. The Dockerfile uses Go 1.25.7-alpine for builds, but any recent stable Go version meeting the minimum requirement will work for local compilation.

### Do I need to build the UI assets separately before compiling the Go binary?

**Yes, if you want the web interface included.** The UI assets must be built first using `./script/build-ui`, which runs `npm ci && npm run build` in the `ui/` directory. If you skip this step, the Go binary will compile but will not serve the web UI.

### How does the Dockerfile handle the build process differently than manual compilation?

The Dockerfile uses a **multi-stage build** that automates both the UI and Go compilation in isolated stages. It first builds the UI using Node.js, copies the resulting assets into the Go build stage, compiles the binary with ldflags for version injection, and finally copies only the binary into a minimal distroless image—eliminating build tools from the final container.