Skip to content

feat(publisher): read the login private key from a file or MCP_PRIVATE_KEY - #1734

Merged
rdimitrov merged 3 commits into
modelcontextprotocol:mainfrom
JosephDoUrden:feat/private-key-file
Nov 13, 2026
Merged

rdimitrov merged 3 commits into
modelcontextprotocol:mainfrom
JosephDoUrden:feat/private-key-file

Conversation

@JosephDoUrden

@JosephDoUrden JosephDoUrden commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

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 PATH and MCP_PRIVATE_KEY so 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 mktemp to create a fresh mode-0600 file and pass that path to the CLI, leaving existing hex-key files untouched. Private-key extraction uses the priv:/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 publisher passed with golangci-lint v2.14.0.
  • Tests cover input precedence, conflicting flags (including empty values), unreadable/empty/PEM files, whitespace, and token persistence. Subprocess regressions verify that empty, whitespace-only, and repeated flags ending in an empty value fail without falling back to a valid ambient key or sending an authentication request.
  • Documentation regressions execute the actual file-creation/extraction snippets with non-secret fixture input, checking fresh mode-0600 files on repeated runs and preservation of existing mode-0644 files and symlinks.
  • Added subprocess tests exercise both DNS and HTTP, Ed25519 and P-384, file and environment inputs, file precedence over an invalid ambient key, and absence of private keys from CLI output. The fixture verifies signatures and the exact request payload; invalid-key errors are also checked for disclosure. Tests use the test executable, including race instrumentation, without a prebuilt CLI dependency.
  • Executed both corrected ECDSA examples with OpenSSL 4.0.3: generated 48-byte hex keys with mode 0600 and verified that the CLI's public proof matches the generated key. The four environment-based authentication examples and 15-/16-byte wrapping fixtures also passed.
  • CI Pipeline passed on 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.

JosephDoUrden and others added 2 commits November 13, 2026 01:19
…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
@rdimitrov
rdimitrov force-pushed the feat/private-key-file branch from 4ffa256 to f4d3495 Compare November 12, 2026 23:23

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rdimitrov
rdimitrov merged commit 115f852 into modelcontextprotocol:main Nov 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

login dns/http: accept the private key from an environment variable or a file, not only --private-key

2 participants