Repository navigation
Conversation
Remote MCP servers at private IP addresses can now be trusted on first use instead of requiring a tls config: the first connect fails with the presented certificate's fingerprint and the command to trust it; opencode mcp trust <url> [--force] pins the certificate for the project; later connects verify the pinned certificate, and rotations fail until re-pinned with --force. Hostnames and public IPs never auto-trust; explicit tls config takes precedence. Adds the mcp_trusted_host table (per project, machine-local), mcp.trust.inspect and mcp.trust.pin endpoints, the CLI command, and docs.
Contributor
|
Thanks for porting this to v2, @karup. Trusting self-signed certificates on private networks is a useful feature (see #40111). This pull request is too large to review as one change (about 1,300 changed lines outside tests, 35 files). It also combines pieces that each work on their own. The description says "explicit tls config takes precedence", but
You're welcome to open those, ideally linking #40111. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This was referenced Oct 28, 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.
Issue for this PR
Closes #40111
Also partially addresses
#23506
Rather than disabling verification globally, fingerprint pinning achieves the same goal — trusting a specific self-signed cert — without insecure: true. caFile handles private CAs cleanly without a blanket bypass.
#14696
#26862
The createTlsFetch() wrapper and per-server TLS config injection proves the transport-layer plumbing needed for mTLS. Adding cert/key fields to the tls config block follows the same pattern — caFile validates PEM; cert+key would too.
#1694
Provides a portable alternative. Instead of relying on OS-specific trust stores, caFile: "~/ca.pem" lets users point to their corporate CA explicitly, working identically across macOS/Linux/Windows without NODE_EXTRA_CA_CERTS.
Type of change
What does this PR do?
Adds per-MCP-server TLS trust configuration for remote MCP servers using self-signed certificates or private CAs. Three options:
caFile(path to CA cert),caPem(inline CA cert), andfingerprint(SHA256 certificate pinning, like SSH host keys).Config schema is added to both V1 and V2 MCP configs. A
buildTlsCa()helper reads files, validates PEM content, and verifies fingerprints, thencreateTlsFetch()injects the trusted CA into a custom fetch wrapper scoped to that transport only — no global TLS changes.Fingerprint verification uses a one-time pre-flight TLS socket to retrieve the server cert, compares it against the user-provided fingerprint, and promotes the verified cert to a trusted CA. Trust applies only to that transport instance and does not leak across MCP servers.
How did you verify your code works?
buildTlsCaintegrationif (mcp.tls)prevents any new allocations or yields when TLS is not configured)Screenshots / recordings
Not a UI change.
Checklist