feat: add expvar debug endpoint and build version injection - #33
Merged
Conversation
Register the expvar debug endpoint on the HTTP mux at /debug/vars (internal-only; not exposed via ingress HTTPRoute). The blank import of expvar registers its handler on http.DefaultServeMux, which is then mounted at that path. Add a Version package-level var as an ldflags injection target, and use it as the MCP server implementation version string instead of a hardcoded literal. The Makefile derives the version from 'git describe --tags --dirty --always', which produces a clean tag on tagged commits, a tag+offset+hash string between tags, and appends -dirty when there are uncommitted changes. 🤖 Generated with [GitHub Copilot](https://github.com/features/copilot) (via Zed) Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
Override the FlagSet Usage func to print the version string before the flag defaults, so 'lfx-mcp-server --help' shows the running version. 🤖 Generated with [GitHub Copilot](https://github.com/features/copilot) (via Zed) Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
Add .ko.yaml declaring the -X main.Version ldflag using the VERSION environment variable, following the same pattern as lfx-v2-member-service. Set VERSION in both ko workflow steps: - Tagged release: VERSION=github.ref_name (e.g. v0.4.1) - Main branch: VERSION=development-<sha> Also name the previously anonymous main-branch build step for clarity. 🤖 Generated with [GitHub Copilot](https://github.com/features/copilot) (via Zed) Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
emsearcy
requested review from
Copilot and
jordane
and removed request for
Copilot
March 20, 2026 19:34
Add a VERSION build arg to the Dockerfile (defaulting to 'dev') and pass it to the -X main.Version ldflag in the go build command. Update the docker-build Makefile target to forward VERSION=$(VERSION) so local Docker builds get the same git-describe version string as make build. Also change the default DOCKER_TAG from 'latest' to 'local' to avoid accidentally tagging local builds as latest. 🤖 Generated with [GitHub Copilot](https://github.com/features/copilot) (via Zed) Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds internal observability and build metadata to the lfx-mcp-server binary by exposing a Go expvar endpoint and injecting a build-time version string used in the MCP implementation metadata and CLI help output.
Changes:
- Registers
/debug/vars(expvar) on the HTTP server mux. - Introduces a build-injected
main.Versionvariable and uses it in MCP implementation metadata and--helpoutput. - Updates local build (Makefile/Dockerfile) and CI/ko configuration to pass version via ldflags.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Makefile | Derives a git-based VERSION, injects it via ldflags, and passes it to Docker builds. |
| Dockerfile | Accepts a VERSION build-arg and injects it via ldflags for local Docker builds. |
| cmd/lfx-mcp-server/main.go | Adds build-time Version, prints it in CLI usage, uses it in MCP implementation metadata, and mounts /debug/vars. |
| .ko.yaml | Configures ko to inject main.Version from VERSION env var at build time. |
| .github/workflows/ko-build-tag.yaml | Sets VERSION from the tag name for tagged ko builds. |
| .github/workflows/ko-build-main.yaml | Sets VERSION to a development SHA-based value for main-branch ko builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- bump github.com/modelcontextprotocol/go-sdk v1.4.0 -> v1.4.1 to resolve GHSA-89xv-2j6f-qhc8 and GHSA-q382-vc8q-7jhj - add missing package comment to internal/tools/member_write.go - replace blank expvar import with named import; register /debug/vars via expvar.Handler() directly on the local mux instead of mounting http.DefaultServeMux - wrap /debug/vars in localhostOnly middleware so it is reachable via kubectl port-forward but blocked from ingress traffic - add ko-build Makefile target that loads a local image as linuxfoundation/lfx-mcp/lfx-mcp-server:local, matching docker-build; VERSION is forwarded so the .ko.yaml template resolves correctly 🤖 Generated with [GitHub Copilot](https://github.com/features/copilot) (via Zed) Signed-off-by: Eric Searcy <eric@linuxfoundation.org>
jordane
approved these changes
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements ARCH-350.
Changes
/debug/varsexpvar endpoint: Registers the Go standard libraryexpvarhandler on the HTTP mux at/debug/vars(internal-only; not exposed via ingress HTTPRoute). The blank import ofexpvarregisters its handler onhttp.DefaultServeMux, which is then mounted at that path.Build version injection: Adds a
Versionpackage-level var as an ldflags injection target. Used as the MCP server implementation version string (visible in MCP Inspector) and in--helpoutput.Makefile: Derives version from
git describe --tags --dirty --always, giving:v0.4.1on a tagged commitv0.4.1-3-gabcdef0between tagsv0.4.1-dirty/v0.4.1-3-gabcdef0-dirtywith uncommitted changes.ko.yaml: Declares the-X main.Versionldflag using{{.Env.VERSION}}templating, following the same pattern aslfx-v2-member-service.CI workflows: Sets
VERSIONenv var in both ko build steps:VERSION=github.ref_name(e.g.v0.4.1)