This directory contains a Model Context Protocol (MCP) server designed to interact with the GitHub API. It is based on the official github/github-mcp-server implementation, adapted for use within the KlavisAI project.
This server allows MCP clients to leverage GitHub's API for tasks like retrieving repository contents, managing issues, searching code, and more, using the standardized MCP interface.
- Docker: (Recommended for running) Download and install Docker Desktop or Docker Engine.
- Go: Version 1.23 or later (Required for local development/running without Docker).
- Git: Required for cloning and version control.
The server requires a GitHub Personal Access Token (PAT) for authenticated API access.
-
Create a
.envfile: In themcp_servers/githubdirectory, create a file named.envby copying the example:cp mcp_servers/github/.env.example mcp_servers/github/.env
-
Add your GitHub Token: Edit the
.envfile and replaceyour_github_personal_access_tokenwith your actual GitHub PAT. Ensure your token has the necessary permissions (e.g.,repo,read:user) for the operations you intend to perform.# mcp_servers/github/.env GITHUB_AUTH_TOKEN=ghp_YourActualGitHubTokenHere
- Important: Keep your
.envfile secure and do not commit it to version control. The.gitignorefile in the project root should already be configured to ignore.envfiles.
- Important: Keep your
-
Optional Variables:
PORT: The port the server listens on. Defaults to5000.BASE_URL: The base URL exposed by the server. Defaults tohttp://localhost:{PORT}. You generally don't need to change these for local Docker usage.
Using Docker provides a containerized and consistent environment.
-
Build the Docker Image: Navigate to the root of the
klavisrepository (the directory containing thismcp_serversfolder) and run the build command:docker build -t klavis-github-mcp -f mcp_servers/github/Dockerfile .-t klavis-github-mcp: Tags the image with the nameklavis-github-mcp.-f mcp_servers/github/Dockerfile: Specifies the path to the Dockerfile..: Sets the build context to the current directory (theklavisroot), allowing the Dockerfile to copy files frommcp_servers/github/.
-
Run the Docker Container:
docker run --rm -p 5000:5000 --env-file mcp_servers/github/.env klavis-github-mcp
--rm: Automatically removes the container when it exits.-p 5000:5000: Maps port 5000 on your host machine to port 5000 inside the container (the default port the server listens on).--env-file mcp_servers/github/.env: Loads environment variables (specificallyGITHUB_AUTH_TOKEN) from your.envfile into the container. Note: The.envfile itself is not copied into the image.klavis-github-mcp: The name of the image to run.
The server should now be running and accessible at
http://localhost:5000.
If you prefer not to use Docker, you can run the server directly using Go.
- Ensure Prerequisites: Make sure you have Go 1.23+ installed.
- Navigate to Directory: Open your terminal in the
mcp_servers/githubdirectory. - Configure: Create and configure the
.envfile as described in the "Configuration" section. - Install Dependencies: Download the necessary Go modules:
go mod download
- Run the Server:
The server will load the
go run sse_server.go
GITHUB_AUTH_TOKENfrom the.envfile in the current directory and start listening on port 5000 (or the port specified in.env).
Once the server is running (either via Docker or locally), you can interact with it using any MCP-compatible client (like mcp-cli). Point your client to the server's address (e.g., http://localhost:5000).
If you configured the server using the GITHUB_AUTH_TOKEN environment variable (e.g., via --env-file in Docker or the .env file locally), the server will use this token for all requests.
Alternatively, if the server was started without the GITHUB_AUTH_TOKEN environment variable set, clients must provide the token via the x-auth-token header with each request.