feat: add clap CLI with serve and version self-updater (FJMCP-3) #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/cli-serve-version-fjmcp-3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Resolves FJMCP-3.
forgejo-mcpgains a real clap CLI:--helpand--versionwork, the MCP stdio server moves behind an explicitservesubcommand, and a newversion show|check|updateself-updater mirrors theyoutrack-clipattern (registry download, SHA-256 sidecar verification,self_replace, post-swap--versionsmoke test).Changes
src/main.rsparses a clapParserand dispatches:serveruns the previous stdio-server body (logs on stderr, JSON-RPC on stdout);version { show | check | update }is the self-updater. A bareforgejo-mcpno longer starts the server (prints usage, exits 2).build.rsbakesFORGEJO_MCP_GIT_HASH,FORGEJO_MCP_BUILD_DATE(RFC 3339 UTC), andFORGEJO_MCP_UPDATE_URL;--versionprintsforgejo-mcp <semver> (<git-hash>, built <build-date>). A tarball build with no.gitfalls back tounknownand the default URL.version checkHEADs the registry/latestartifact and reports newer / up-to-date / indeterminate against the baked date.version updateprobes the target dir for writability first (sudo / Administrator hint on permission denied), downloads the platform artifact, verifies a.sha256sidecar when present (hard-fail on mismatch, skip when absent), self-replaces, and smoke-tests the swap via--version;--dry-run/--force/--urlbehave as inyoutrack-cli. Logic ported toeyre(the crate's existing error type) rather than addinganyhow.serve: the Dockerfile ENTRYPOINT, README usage and theclaude mcp addexample, and thejust runrecipe comment.COPY build.rsand acceptFORGEJO_MCP_GIT_HASH/FORGEJO_MCP_BUILD_DATEbuild-args. The Linux and Windows CI workflows inject the git hash and build date and publish a.sha256sidecar per artifact (get-tags.nualways emits thelatesttag the updater queries).CLAUDE.mddrops the old "no build.rs / no version baking" note and documents the baked vars and theservelaunch.Note on the commit trailer
Per the repo's VCS-integration policy in
CLAUDE.md, the commit carries a bare#FJMCP-3reference (link only), not aState Donetrailer. Forgejo applies commit commands at push time, not on merge, so aState Donetrailer would resolve the issue while this PR is still open. The issue moves to Done after a human merges.Test plan
cargo fmt --checkandcargo clippy --all-targets -- -D warningscleancargo test: 33 tests pass (ported version + wiremock tests)forgejo-mcp --help/--version/version/version showverified; bare invocation prints usage and exits 2forgejo-mcp servelogs startup on stderr, behavior identical to the prior bare invocationforgejo-mcp version checkagainst the live registry reports the indeterminate case gracefullyjust check-docker(builder-stage compile) succeeds withbuild.rspresentmain.rs previously did no argument parsing, so --help and --version were silently ignored and the process blocked on stdin. It now parses a clap CLI and dispatches: serve runs the previous stdio-server body (logs on stderr, JSON-RPC on stdout) and version { show | check | update } is a self-updater mirroring youtrack-cli. A bare forgejo-mcp no longer starts the server (prints usage, exits 2); callers pass serve. A new build.rs bakes FORGEJO_MCP_GIT_HASH, FORGEJO_MCP_BUILD_DATE (RFC 3339 UTC), and FORGEJO_MCP_UPDATE_URL, so --version prints "forgejo-mcp <semver> (<git-hash>, built <build-date>)"; a tarball build with no .git falls back to unknown and the default URL. version check HEADs the registry /latest artifact and reports newer / up-to-date / indeterminate against the baked date; version update probes the target dir for writability (sudo / Administrator hint on permission denied), downloads the platform artifact, verifies a .sha256 sidecar when present (hard-fail on mismatch, skip when absent), self-replaces, and smoke-tests the swap via --version, with --dry-run / --force / --url. The logic is ported to eyre (the crate's existing error type) rather than adding anyhow. Callers and docs pass serve: the Dockerfile ENTRYPOINT, README usage and the claude mcp add example, and the just run recipe. Both Dockerfiles COPY build.rs and accept FORGEJO_MCP_GIT_HASH / FORGEJO_MCP_BUILD_DATE build-args; the Linux and Windows CI workflows inject the git hash and build date and publish a .sha256 sidecar per artifact. CLAUDE.md drops the old "no build.rs / no version baking" note and documents the baked vars and the serve launch. #FJMCP-3 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>