feat(docker): add /healthz endpoint and -healthcheck flag (#254)

Adds a Docker healthcheck and the small HTTP/CLI plumbing it needs.

- Expose `GET /healthz` on the HTTP-mode server.
- Add `-healthcheck` to dial `http://127.0.0.1:<port>/healthz` and exit with status.
- Add a Dockerfile `HEALTHCHECK` instruction using `-healthcheck`.
- Document HTTP-mode usage and stdio override guidance.

Closes https://gitea.com/gitea/gitea-mcp/issues/146

Assisted by Codet.

Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/254
Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com>
This commit is contained in:
Lunny Xiao
2026-08-26 03:00:05 +00:00
parent 04931d48a3
commit bfe0d4c9b0
10 changed files with 168 additions and 1 deletions
+9
View File
@@ -95,3 +95,12 @@ func TestInitFlagSetScopes(t *testing.T) {
})
}
}
func TestInitFlagSetHealthcheck(t *testing.T) {
t.Cleanup(func() { healthcheck = false })
fs := flag.NewFlagSet("test", flag.ContinueOnError)
initFlagSet(fs, []string{"-healthcheck"}, func(string) string { return "" }, func(string) ([]byte, error) { return nil, nil }, &bytes.Buffer{})
if !healthcheck {
t.Error("healthcheck = false, want true")
}
}