Repository navigation
feat(publisher): read the login private key from a file or MCP_PRIVATE_KEY - #1734
Conversation
…E_KEY mcp-publisher login dns and login http only took the signing key as --private-key <hex>, which lands in the process list, shell history and CI logs. Add --private-key-file <path> and the MCP_PRIVATE_KEY environment variable, resolved the same way --token falls back to MCP_GITHUB_TOKEN: the two flags are mutually exclusive, either one overrides the env var, and with nothing set the existing "private key (hex) is required" error is unchanged. A PEM file gets a clear error, an empty file is an error rather than a silent fall-through. Docs move the key off the command line in the dns/http examples and under env: in the GitHub Actions workflow. Closes modelcontextprotocol#1704
4ffa256 to
f4d3495
Compare
rdimitrov
left a comment
There was a problem hiding this comment.
Validated a87c597 locally and confirmed CI is green. The full Go suite passed with race detection, lint/schema validation and both builds passed, and all 17 publishing integration examples passed.
Also exercised the built CLI against a running local registry and PostgreSQL with mocked DNS/HTTP public-proof lookup and the production authentication handlers: Ed25519 and P-384 login from files and environment variables, token persistence, publishing and retrieval all passed. Wrong keys, tampered JWTs, unauthorized namespaces, and empty/conflicting flags were rejected. Regression coverage verifies fresh 0600 key files without overwriting existing files. All 76 local scenario checks passed. External proof transport and package validation were not exercised by that mocked setup.
DNS and HTTP login currently require an in-process signing key in
--private-key <hex>, exposing it in process arguments. This adds--private-key-file PATHandMCP_PRIVATE_KEYso publishers can supply the same hex key without putting its value in argv.The two flags are mutually exclusive by presence, including when either is empty. Explicitly empty or whitespace-only flags fail before signing or making any network request; the environment is used only when neither flag was provided. File and environment whitespace is trimmed, and an unreadable, empty, or PEM file fails explicitly without falling back to the environment. Existing signing, server verification, token storage, and cloud signing providers are unchanged. Environment variables and key files still require appropriate protection.
The documentation uses environment secrets in GitHub Actions and shows protected hex-key files for ECDSA login. The hex-key extraction examples use
mktempto create a fresh mode-0600 file and pass that path to the CLI, leaving existing hex-key files untouched. Private-key extraction uses thepriv:/pub:markers rather than a fixed line count, accommodating OpenSSL 4's changed wrapping for Ed25519 and P-384.Closes #1704.
Rebased onto main at
87054b5.Validation:
go test -race ./cmd/publisher/...passed.make lint validate publisherpassed with golangci-lint v2.14.0.a87c5975af96174a25e84541581263904132c722: build/lint/validation/vulnerability checks, full tests, and deployment configuration tests.AI assistance was used during development and the follow-up review, tests, and documentation corrections.