From 5bbf8e0afb08328b1c8b9a22742b9c6e40a7d918 Mon Sep 17 00:00:00 2001 From: hiifong Date: Sun, 6 Apr 2025 04:06:34 +0000 Subject: [PATCH] Add Dockerfile (#13) Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/13 Co-authored-by: hiifong Co-committed-by: hiifong --- .gitea/workflows/release-nightly.yml | 52 ++++++++++++++++++++++++++++ Dockerfile | 18 ++++++++++ README.md | 43 +++++++++++++++++++++++ pkg/log/log.go | 2 +- 4 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/release-nightly.yml create mode 100644 Dockerfile diff --git a/.gitea/workflows/release-nightly.yml b/.gitea/workflows/release-nightly.yml new file mode 100644 index 0000000..8b74a0a --- /dev/null +++ b/.gitea/workflows/release-nightly.yml @@ -0,0 +1,52 @@ +name: release-nightly + +on: + push: + branches: [main] + tags: + - "*" + +jobs: + release-image: + runs-on: ubuntu-latest + env: + DOCKER_ORG: gitea + DOCKER_LATEST: nightly + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # all history for all branches and tags + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker BuildX + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Get Meta + id: meta + run: | + echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT + echo REPO_VERSION=${GITHUB_REF_NAME#v} >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + target: basic + platforms: | + linux/amd64 + linux/arm64 + push: true + tags: | + ${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ env.DOCKER_LATEST }} + build-args: | + VERSION=${{ steps.meta.outputs.DOCKER_LATEST }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f0e57b8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM golang:1.24-alpine AS builder + +ARG VERSION + +WORKDIR /build + +COPY . . +RUN go mod download + +RUN CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION}" -o gitea-mcp + +FROM scratch + +WORKDIR /app + +COPY --from=builder /build/gitea-mcp . + +CMD ["./gitea-mcp", "-t", "stdio"] \ No newline at end of file diff --git a/README.md b/README.md index 9a1c149..e18fd60 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ **Gitea MCP Server** is an integration plugin designed to connect Gitea with Model Context Protocol (MCP) systems. This allows for seamless command execution and repository management through an MCP-compatible chat interface. +[![Install with Docker in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=gitea&inputs=[{%22id%22:%22gitea_token%22,%22type%22:%22promptString%22,%22description%22:%22Gitea%20Personal%20Access%20Token%22,%22password%22:true}]&config={%22command%22:%22docker%22,%22args%22:[%22run%22,%22-i%22,%22--rm%22,%22-e%22,%22GITEA_ACCESS_TOKEN%22,%22gitea/githea-mcp-server%22],%22env%22:{%22GITEA_ACCESS_TOKEN%22:%22${input:gitea_token}%22}}) [![Install with Docker in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=gitea&inputs=[{%22id%22:%22gitea_token%22,%22type%22:%22promptString%22,%22description%22:%22Gitea%20Personal%20Access%20Token%22,%22password%22:true}]&config={%22command%22:%22docker%22,%22args%22:[%22run%22,%22-i%22,%22--rm%22,%22-e%22,%22GITEA_ACCESS_TOKEN%22,%22gitea/githea-mcp-server%22],%22env%22:{%22GITEA_ACCESS_TOKEN%22:%22${input:gitea_token}%22}}&quality=insiders) + ## What is Gitea? Gitea is a community-managed lightweight code hosting solution written in Go. It is published under the MIT license. Gitea provides Git hosting including a repository viewer, issue tracking, pull requests, and more. @@ -12,6 +14,47 @@ Model Context Protocol (MCP) is a protocol that allows for the integration of va ## 🚧 Installation +### Usage with VS Code + +For quick installation, use one of the one-click install buttons at the top of this README. + +For manual installation, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing `Ctrl + Shift + P` and typing `Preferences: Open User Settings (JSON)`. + +Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace. This will allow you to share the configuration with others. + +> Note that the `mcp` key is not needed in the `.vscode/mcp.json` file. + +```json +{ + "mcp": { + "inputs": [ + { + "type": "promptString", + "id": "gitea_token", + "description": "Gitea Personal Access Token", + "password": true + } + ], + "servers": { + "github": { + "command": "docker", + "args": [ + "run", + "-i", + "--rm", + "-e", + "GITEA_ACCESS_TOKEN", + "gitea/gitea-mcp-server" + ], + "env": { + "GITEA_ACCESS_TOKEN": "${input:gitea_token}" + } + } + } + } +} +``` + ### 📥 Download the official binary release You can download the official release from [here](https://gitea.com/gitea/gitea-mcp/releases). diff --git a/pkg/log/log.go b/pkg/log/log.go index 91402c6..ba27592 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -37,7 +37,7 @@ func Default() *zap.Logger { } core := zapcore.NewCore(enc, ws, level) options := []zap.Option{ - zap.AddStacktrace(zapcore.ErrorLevel), + zap.AddStacktrace(zapcore.DPanicLevel), zap.AddCaller(), zap.AddCallerSkip(1), }