Compare commits

..

1 Commits

Author SHA1 Message Date
Lunny Xiao 4e62d158cb docs(image): document Docker image naming mismatch
Add OCI title/description labels to the Dockerfile, note the
docker.gitea.com/gitea-mcp-server vs gitea-mcp naming mismatch in each
README with a link to a new docs/adr note recording the maintainers'
preferred gitea/mcp-server direction from issue #181, and add a test
that keeps the README image references consistent.

Co-Authored-By: Codet <codet@commitgo.dev> (GPT-5-Codex)
2026-08-23 23:28:23 -07:00
13 changed files with 72 additions and 197 deletions
+2
View File
@@ -31,5 +31,7 @@ USER nonroot:nonroot
LABEL org.opencontainers.image.version="${VERSION}" LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.source="https://gitea.com/gitea/gitea-mcp" LABEL org.opencontainers.image.source="https://gitea.com/gitea/gitea-mcp"
LABEL org.opencontainers.image.title="Gitea MCP Server"
LABEL org.opencontainers.image.description="Model Context Protocol server connecting Gitea instances to MCP clients, published as docker.gitea.com/gitea-mcp-server."
CMD ["/app/gitea-mcp"] CMD ["/app/gitea-mcp"]
+2 -8
View File
@@ -10,6 +10,8 @@
Download a binary from the [releases page](https://gitea.com/gitea/gitea-mcp/releases) and put it in your `PATH`, use the `docker.gitea.com/gitea-mcp-server` image, or build from source into `$GOPATH/bin` with `make` and Go 1.26 or later: Download a binary from the [releases page](https://gitea.com/gitea/gitea-mcp/releases) and put it in your `PATH`, use the `docker.gitea.com/gitea-mcp-server` image, or build from source into `$GOPATH/bin` with `make` and Go 1.26 or later:
> The published Docker image is `docker.gitea.com/gitea-mcp-server`, which does not match the `gitea-mcp` repository name. This is a known mismatch, tracked in [issue #181](https://gitea.com/gitea/gitea-mcp/issues/181); the image name stays as-is for now to avoid breaking existing installs. See [docs/adr/docker-image-naming.md](docs/adr/docker-image-naming.md) for details.
```bash ```bash
git clone https://gitea.com/gitea/gitea-mcp.git git clone https://gitea.com/gitea/gitea-mcp.git
cd gitea-mcp cd gitea-mcp
@@ -20,14 +22,6 @@ make install
Pass the Gitea host and access token as command-line flags or environment variables, flags take precedence. Run `gitea-mcp --help` for the full list of flags and environment variables. Logs are written to `$HOME/.gitea-mcp/gitea-mcp.log`, add `-d` for debug logging. Pass the Gitea host and access token as command-line flags or environment variables, flags take precedence. Run `gitea-mcp --help` for the full list of flags and environment variables. Logs are written to `$HOME/.gitea-mcp/gitea-mcp.log`, add `-d` for debug logging.
Set `GITEA_EXTRA_HEADERS` to a JSON object of header name/value pairs to send with every outbound request to Gitea, for example when Gitea sits behind Cloudflare Access:
```bash
export GITEA_EXTRA_HEADERS='{"CF-Access-Client-Id":"id","CF-Access-Client-Secret":"secret"}'
```
These headers never override `Authorization`, `Content-Type`, or `Accept` set by `gitea-mcp` itself.
### MCP protocol and HTTP transport ### MCP protocol and HTTP transport
The server supports MCP up to `2026-07-28` and negotiates down to the client's version, advertising only the `tools` capability. Tool and Gitea failures return a `tools/call` result with `result.isError: true`, while malformed requests and server faults stay JSON-RPC errors. The server supports MCP up to `2026-07-28` and negotiates down to the client's version, advertising only the `tools` capability. Tool and Gitea failures return a `tools/call` result with `result.isError: true`, while malformed requests and server faults stay JSON-RPC errors.
+2
View File
@@ -10,6 +10,8 @@
可从 [发布页面](https://gitea.com/gitea/gitea-mcp/releases) 下载二进制文件并放入 `PATH`,或使用 `docker.gitea.com/gitea-mcp-server` 镜像,也可用 `make` 和 Go 1.26 及以上从源码构建到 `$GOPATH/bin` 可从 [发布页面](https://gitea.com/gitea/gitea-mcp/releases) 下载二进制文件并放入 `PATH`,或使用 `docker.gitea.com/gitea-mcp-server` 镜像,也可用 `make` 和 Go 1.26 及以上从源码构建到 `$GOPATH/bin`
> 已发布的 Docker 镜像名为 `docker.gitea.com/gitea-mcp-server`,与 `gitea-mcp` 仓库名不一致。这是 [issue #181](https://gitea.com/gitea/gitea-mcp/issues/181) 中记录的已知不一致,为避免破坏现有安装,镜像名暂不改动。详见 [docs/adr/docker-image-naming.md](docs/adr/docker-image-naming.md)。
```bash ```bash
git clone https://gitea.com/gitea/gitea-mcp.git git clone https://gitea.com/gitea/gitea-mcp.git
cd gitea-mcp cd gitea-mcp
+2
View File
@@ -10,6 +10,8 @@
可從 [發布頁面](https://gitea.com/gitea/gitea-mcp/releases) 下載二進位檔並放入 `PATH`,或使用 `docker.gitea.com/gitea-mcp-server` 映像檔,也可用 `make` 與 Go 1.26 以上從原始碼建置到 `$GOPATH/bin` 可從 [發布頁面](https://gitea.com/gitea/gitea-mcp/releases) 下載二進位檔並放入 `PATH`,或使用 `docker.gitea.com/gitea-mcp-server` 映像檔,也可用 `make` 與 Go 1.26 以上從原始碼建置到 `$GOPATH/bin`
> 已發布的 Docker 映像檔名稱為 `docker.gitea.com/gitea-mcp-server`,與 `gitea-mcp` 倉庫名稱不一致。這是 [issue #181](https://gitea.com/gitea/gitea-mcp/issues/181) 中記錄的已知不一致,為避免破壞現有安裝,映像檔名稱暫不變更。詳見 [docs/adr/docker-image-naming.md](docs/adr/docker-image-naming.md)。
```bash ```bash
git clone https://gitea.com/gitea/gitea-mcp.git git clone https://gitea.com/gitea/gitea-mcp.git
cd gitea-mcp cd gitea-mcp
-15
View File
@@ -2,11 +2,9 @@ package cmd
import ( import (
"context" "context"
"encoding/json"
"flag" "flag"
"fmt" "fmt"
"io" "io"
"net/http"
"os" "os"
"strconv" "strconv"
"strings" "strings"
@@ -88,7 +86,6 @@ func initFlagSet(fs *flag.FlagSet, args []string, getenv func(string) string, re
fmt.Fprintf(w, " GITEA_ACCESS_TOKEN\tProvide access token\n") fmt.Fprintf(w, " GITEA_ACCESS_TOKEN\tProvide access token\n")
fmt.Fprintf(w, " GITEA_ACCESS_TOKEN_FILE\tPath to a file containing the access token (e.g. a Docker secret)\n") fmt.Fprintf(w, " GITEA_ACCESS_TOKEN_FILE\tPath to a file containing the access token (e.g. a Docker secret)\n")
fmt.Fprintf(w, " GITEA_DEBUG\tSet to 'true' for debug mode\n") fmt.Fprintf(w, " GITEA_DEBUG\tSet to 'true' for debug mode\n")
fmt.Fprintf(w, " GITEA_EXTRA_HEADERS\tJSON object of extra HTTP headers to send with Gitea API requests\n")
fmt.Fprintf(w, " GITEA_HOST\tOverride Gitea host URL\n") fmt.Fprintf(w, " GITEA_HOST\tOverride Gitea host URL\n")
fmt.Fprintf(w, " GITEA_INSECURE\tSet to 'true' to ignore TLS errors\n") fmt.Fprintf(w, " GITEA_INSECURE\tSet to 'true' to ignore TLS errors\n")
fmt.Fprintf(w, " GITEA_MAX_INLINE_ATTACHMENT_BYTES\tOverride inline image attachment size limit in bytes\n") fmt.Fprintf(w, " GITEA_MAX_INLINE_ATTACHMENT_BYTES\tOverride inline image attachment size limit in bytes\n")
@@ -167,18 +164,6 @@ func initFlagSet(fs *flag.FlagSet, args []string, getenv func(string) string, re
flagPkg.MaxInlineAttachmentBytes = parsed flagPkg.MaxInlineAttachmentBytes = parsed
} }
} }
if val := getenv("GITEA_EXTRA_HEADERS"); val != "" {
var headers map[string]string
if err := json.Unmarshal([]byte(val), &headers); err != nil {
fmt.Fprintf(stderr, "invalid GITEA_EXTRA_HEADERS: %v\n", err)
osExit(1)
}
extraHeaders := make(http.Header, len(headers))
for name, value := range headers {
extraHeaders.Set(name, value)
}
flagPkg.ExtraHeaders = extraHeaders
}
} }
// normalizeScope trims whitespace, lowercases, and converts internal spaces // normalizeScope trims whitespace, lowercases, and converts internal spaces
-52
View File
@@ -5,7 +5,6 @@ import (
"flag" "flag"
"maps" "maps"
"slices" "slices"
"strings"
"testing" "testing"
flagPkg "gitea.com/gitea/gitea-mcp/pkg/flag" flagPkg "gitea.com/gitea/gitea-mcp/pkg/flag"
@@ -96,54 +95,3 @@ func TestInitFlagSetScopes(t *testing.T) {
}) })
} }
} }
func TestInitFlagSetExtraHeaders(t *testing.T) {
t.Cleanup(func() { flagPkg.ExtraHeaders = nil })
getenv := func(key string) string {
if key == "GITEA_EXTRA_HEADERS" {
return `{"CF-Access-Client-Id":"id","CF-Access-Client-Secret":"secret"}`
}
return ""
}
readFile := func(string) ([]byte, error) { return nil, nil }
fs := flag.NewFlagSet("test", flag.ContinueOnError)
var stderr bytes.Buffer
initFlagSet(fs, []string{}, getenv, readFile, &stderr)
if got := flagPkg.ExtraHeaders.Get("CF-Access-Client-Id"); got != "id" {
t.Errorf("ExtraHeaders[CF-Access-Client-Id] = %q, want %q", got, "id")
}
if got := flagPkg.ExtraHeaders.Get("CF-Access-Client-Secret"); got != "secret" {
t.Errorf("ExtraHeaders[CF-Access-Client-Secret] = %q, want %q", got, "secret")
}
}
func TestInitFlagSetExtraHeadersInvalidJSON(t *testing.T) {
t.Cleanup(func() { flagPkg.ExtraHeaders = nil })
origOsExit := osExit
var exitCode int
osExit = func(code int) { exitCode = code }
t.Cleanup(func() { osExit = origOsExit })
getenv := func(key string) string {
if key == "GITEA_EXTRA_HEADERS" {
return `not-json`
}
return ""
}
readFile := func(string) ([]byte, error) { return nil, nil }
fs := flag.NewFlagSet("test", flag.ContinueOnError)
var stderr bytes.Buffer
initFlagSet(fs, []string{}, getenv, readFile, &stderr)
if exitCode != 1 {
t.Errorf("exitCode = %d, want 1", exitCode)
}
if !strings.Contains(stderr.String(), "GITEA_EXTRA_HEADERS") {
t.Errorf("stderr = %q, want mention of GITEA_EXTRA_HEADERS", stderr.String())
}
}
+29
View File
@@ -0,0 +1,29 @@
# Docker image naming mismatch (issue #181)
## Current state
The project repository is `gitea.com/gitea/gitea-mcp`, but the Docker image is
published as `docker.gitea.com/gitea-mcp-server`. This mismatch was raised in
[issue #181](https://gitea.com/gitea/gitea-mcp/issues/181).
## Maintainers' direction
Per the issue discussion, the maintainers' preferred long-term name is
`gitea/mcp-server`, matching the naming scheme used by `gitea/act_runner`
(published as a `runner`-style short name) and by comparable projects such as
`github/github-mcp-server`. The name `mcp-server` was preferred over
`gitea-mcp-server` because the repository is primarily run as a local client
process, not a traditional long-running server.
## Decision
No rename has happened yet; the discussion was explicitly left open in the
issue. The current image name, `docker.gitea.com/gitea-mcp-server`, remains in
use so that existing user configurations and documentation keep working.
`org.opencontainers.image.title` and `org.opencontainers.image.description`
labels were added to the `Dockerfile` to make the image self-describing
regardless of the tag it is published under.
If the image is renamed in the future, update the `docker.gitea.com/gitea-mcp-server`
references across `README.md`, `README.zh-cn.md` and `README.zh-tw.md` together
with this document.
+32
View File
@@ -22,6 +22,38 @@ var readmeAccessLabels = map[string]map[string]string{
"../README.zh-tw.md": {"讀取": "read", "寫入": "write"}, "../README.zh-tw.md": {"讀取": "read", "寫入": "write"},
} }
// publishedDockerImage is the image name published for this project. See
// docs/adr/docker-image-naming.md for why it differs from the repository name.
const publishedDockerImage = "docker.gitea.com/gitea-mcp-server"
// dockerImageReference matches any docker.gitea.com/<name> image reference so
// stray typos or partial renames in the README files can be caught.
var dockerImageReference = regexp.MustCompile(`docker\.gitea\.com/[a-zA-Z0-9._-]+`)
// TestReadmeDockerImageReferencesAreConsistent ensures every README mentions
// the same, currently published Docker image name. A partial rename, where
// one example is updated but another is missed, would otherwise leave users
// copying a command that pulls a nonexistent image.
func TestReadmeDockerImageReferencesAreConsistent(t *testing.T) {
for _, path := range []string{"../README.md", "../README.zh-cn.md", "../README.zh-tw.md"} {
t.Run(filepath.Base(path), func(t *testing.T) {
content, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
references := dockerImageReference.FindAllString(string(content), -1)
if len(references) == 0 {
t.Fatalf("no docker.gitea.com image reference found in %s", path)
}
for _, ref := range references {
if ref != publishedDockerImage {
t.Errorf("found image reference %q in %s, want %q", ref, path, publishedDockerImage)
}
}
})
}
}
// toolInfo is what TestReadmeToolTables tracks per tool, both as registered // toolInfo is what TestReadmeToolTables tracks per tool, both as registered
// in code and as documented in a README, so the two can be compared. // in code and as documented in a README, so the two can be compared.
type toolInfo struct { type toolInfo struct {
-3
View File
@@ -1,7 +1,5 @@
package flag package flag
import "net/http"
var ( var (
Host string Host string
Bind string Bind string
@@ -17,5 +15,4 @@ var (
Debug bool Debug bool
AllowedTools map[string]struct{} AllowedTools map[string]struct{}
AllowedScopes map[string]struct{} AllowedScopes map[string]struct{}
ExtraHeaders http.Header
) )
+1 -27
View File
@@ -30,32 +30,6 @@ func sharedTransport() *http.Transport {
return sharedTrans return sharedTrans
} }
// extraHeaderTransport injects flag.ExtraHeaders into every request, without
// overriding headers the caller already set (e.g. Authorization, Content-Type,
// Accept). It reads flag.ExtraHeaders on each round trip rather than caching
// it, so tests can change it between requests.
type extraHeaderTransport struct {
base http.RoundTripper
}
func (t *extraHeaderTransport) RoundTrip(req *http.Request) (*http.Response, error) {
headers := flag.ExtraHeaders
if len(headers) == 0 {
return t.base.RoundTrip(req)
}
cloned := req.Clone(req.Context())
for name, values := range headers {
if cloned.Header.Get(name) == "" {
cloned.Header[name] = values
}
}
return t.base.RoundTrip(cloned)
}
func giteaTransport() http.RoundTripper {
return &extraHeaderTransport{base: sharedTransport()}
}
// NewClient returns a cached *gitea.Client keyed by host+token. The SDK's per-client // NewClient returns a cached *gitea.Client keyed by host+token. The SDK's per-client
// version cache and the shared transport let us reuse keep-alive connections // version cache and the shared transport let us reuse keep-alive connections
// and avoid the SDK's /api/v1/version preflight on every tool call. // and avoid the SDK's /api/v1/version preflight on every tool call.
@@ -66,7 +40,7 @@ func NewClient(token string) (*gitea.Client, error) {
} }
httpClient := &http.Client{ httpClient := &http.Client{
Transport: giteaTransport(), Transport: sharedTransport(),
CheckRedirect: checkRedirect, CheckRedirect: checkRedirect,
} }
opts := []gitea.ClientOption{ opts := []gitea.ClientOption{
-49
View File
@@ -1,49 +0,0 @@
package gitea
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"gitea.com/gitea/gitea-mcp/pkg/flag"
)
func TestNewClient_SendsExtraHeaders(t *testing.T) {
var gotClientID, gotAuthorization string
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
gotClientID = r.Header.Get("CF-Access-Client-Id")
gotAuthorization = r.Header.Get("Authorization")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte(`{"login":"octocat"}`))
}))
defer srv.Close()
origHost := flag.Host
origExtraHeaders := flag.ExtraHeaders
defer func() {
flag.Host = origHost
flag.ExtraHeaders = origExtraHeaders
}()
flag.Host = srv.URL
flag.ExtraHeaders = http.Header{
"Cf-Access-Client-Id": []string{"client-id"},
"Authorization": []string{"should-not-override"},
}
client, err := NewClient("the-token")
if err != nil {
t.Fatalf("NewClient returned error: %v", err)
}
if _, _, err := client.Users.GetMyUserInfo(context.Background()); err != nil {
t.Fatalf("GetMyUserInfo returned error: %v", err)
}
if gotClientID != "client-id" {
t.Fatalf("CF-Access-Client-Id header = %q, want %q", gotClientID, "client-id")
}
if gotAuthorization != "token the-token" {
t.Fatalf("Authorization header = %q, want %q", gotAuthorization, "token the-token")
}
}
+2 -2
View File
@@ -59,7 +59,7 @@ var (
func restHTTPClient() *http.Client { func restHTTPClient() *http.Client {
restClientOnce.Do(func() { restClientOnce.Do(func() {
restClient = &http.Client{ restClient = &http.Client{
Transport: giteaTransport(), Transport: sharedTransport(),
Timeout: httpClientTimeout, Timeout: httpClientTimeout,
CheckRedirect: checkRedirect, CheckRedirect: checkRedirect,
} }
@@ -180,7 +180,7 @@ func DoJSON(ctx context.Context, method, path string, query url.Values, body, re
func attachmentHTTPClient(origin *url.URL) *http.Client { func attachmentHTTPClient(origin *url.URL) *http.Client {
return &http.Client{ return &http.Client{
Transport: giteaTransport(), Transport: sharedTransport(),
CheckRedirect: func(req *http.Request, via []*http.Request) error { CheckRedirect: func(req *http.Request, via []*http.Request) error {
if err := checkRedirect(req, via); err != nil { if err := checkRedirect(req, via); err != nil {
return err return err
-41
View File
@@ -62,44 +62,3 @@ func TestDoJSON_LimitsErrorResponseBody(t *testing.T) {
t.Fatalf("expected body length %d, got %d", errBodySnippetSize, len(httpErr.Body)) t.Fatalf("expected body length %d, got %d", errBodySnippetSize, len(httpErr.Body))
} }
} }
func TestDoJSON_SendsExtraHeaders(t *testing.T) {
var gotClientID, gotAuthorization string
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
gotClientID = r.Header.Get("CF-Access-Client-Id")
gotAuthorization = r.Header.Get("Authorization")
w.WriteHeader(http.StatusOK)
_, _ = io.WriteString(w, "{}")
}))
defer srv.Close()
origHost := flag.Host
origToken := flag.Token
origExtraHeaders := flag.ExtraHeaders
defer func() {
flag.Host = origHost
flag.Token = origToken
flag.ExtraHeaders = origExtraHeaders
}()
flag.Host = srv.URL
flag.Token = "the-token"
flag.ExtraHeaders = http.Header{
"Cf-Access-Client-Id": []string{"client-id"},
"Authorization": []string{"should-not-override"},
}
var out map[string]any
status, err := DoJSON(context.Background(), http.MethodGet, "repos/owner/repo", nil, nil, &out)
if err != nil {
t.Fatalf("DoJSON returned error: %v", err)
}
if status != http.StatusOK {
t.Fatalf("expected status %d, got %d", http.StatusOK, status)
}
if gotClientID != "client-id" {
t.Fatalf("CF-Access-Client-Id header = %q, want %q", gotClientID, "client-id")
}
if gotAuthorization != "token the-token" {
t.Fatalf("Authorization header = %q, want %q", gotAuthorization, "token the-token")
}
}