How-to guide · Trust a CA
How to fix MCP server certificate errors behind a corporate proxy
In one sentence
You will have found which process opens the TLS connection to your MCP server and put the proxy root where that process reads it, with verification still on.
- Task
- Trust a CA
- Platforms
- Linux
- macOS
- Windows
- Level
- Practitioner · 5 steps
On this page
Before you start
- The exact string. From a Node-based server or mcp-remote:
SELF_SIGNED_CERT_IN_CHAIN,UNABLE_TO_GET_ISSUER_CERT_LOCALLYorUNABLE_TO_VERIFY_LEAF_SIGNATURE, often wrapped in a barefetch failed. Around OAuth sign-in:OAuth error: fetch failedorSDK auth failed: self signed certificate in certificate chain. Sometimes onlyServer disconnected, or a Cursor server that stays on Loading. - The proxy’s root certificate as a PEM file, obtained through a trusted channel as How to work behind a TLS-inspecting corporate proxy describes; on Linux the system bundle
/etc/ssl/certs/ca-certificates.crtserves once IT’s root is in it. - Write access to the client’s configuration file, and a terminal.
A TLS-inspecting proxy re-signs every HTTPS connection with its own certificate authority. Your browser accepts that because IT put the proxy’s root certificate in the operating system’s trust store; the process that connects to your MCP server usually never looks there. Find that process and give it the root, with verification left on.
Steps
1. Confirm the proxy is in the path
Ask the MCP host who signed its certificate:
openssl s_client -showcerts -connect mcp.example.com:443 -servername mcp.example.com </dev/null 2>/dev/null \
| openssl x509 -noout -subject -issuer
subject=CN = mcp.example.com
issuer=C = BE, O = Example Corp, CN = Example Corp TLS Inspection Root
A public issuer means this host is not inspected (a failure then points at the server’s own chain: check it); your company or proxy vendor as issuer means re-signing. Then ask Node, which most stdio servers and mcp-remote run on:
node -e "fetch('https://mcp.example.com/mcp').then(r => console.log(r.status)).catch(e => console.error(e.cause?.code ?? e))"
Any HTTP status, even 401 or 405, means the TLS handshake succeeded. SELF_SIGNED_CERT_IN_CHAIN means the proxy’s root is in the chain and Node holds no copy of it; UNABLE_TO_GET_ISSUER_CERT_LOCALLY means the chain stops at an intermediate Node cannot link to a root it has. Both take the same fix. Run it again with NODE_EXTRA_CA_CERTS=~/corp-root.pem in front of node: a status code proves your PEM file.
2. Find which process opens the connection
The setting must reach the process that performs the handshake, which depends on the transport. Streamable HTTP replaced the separate SSE transport in protocol revision 2025-03-26, but both are connections the client opens itself.
| Transport | Who opens the TLS connection | Where the setting lives |
|---|---|---|
| stdio, including mcp-remote | the server subprocess the client launches | that server’s env block in the client’s config file |
Streamable HTTP or SSE as a url |
the client itself | the client’s own certificate setting (step 4) |
| OAuth sign-in to a hosted server | the client (discovery and tokens) and your browser (sign-in page) | the client’s setting; the OS store for the browser |
A GUI client never runs your shell profile, and the MCP debugging guide says stdio servers inherit only a limited, platform-dependent subset of environment variables. Claude Code in a terminal does pass its shell environment on unless CLAUDE_CODE_MCP_ALLOWLIST_ENV=1 is set, which is why an export in .zshrc works there and nowhere else. Claude Code itself is a native binary, for npm installs too since v2.1.113, with its own certificate setting rather than Node’s.
3. Put the setting where that process reads it
For a stdio server, the variable goes in the server’s env block. Claude Desktop, claude_desktop_config.json:
{
"mcpServers": {
"remote-tools": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.example.com/mcp"],
"env": { "NODE_EXTRA_CA_CERTS": "/Users/you/corp-root.pem" }
}
}
}
Claude Code, .mcp.json in the project or ~/.claude.json; a url entry needs "type": "http", because an entry with a url and no type is read as stdio:
{
"mcpServers": {
"local-tools": {
"command": "npx",
"args": ["-y", "@example/mcp-server"],
"env": { "NODE_EXTRA_CA_CERTS": "/home/you/corp-root.pem" }
},
"hosted-tools": { "type": "http", "url": "https://mcp.example.com/mcp" }
}
}
Cursor, ~/.cursor/mcp.json or .cursor/mcp.json; an envFile key can hold the same variable. On Windows, double the backslashes:
{
"mcpServers": {
"remote-tools": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.example.com/mcp"],
"env": { "NODE_EXTRA_CA_CERTS": "C:\\certs\\corp-root.pem" }
}
}
}
VS Code, .vscode/mcp.json or the user mcp.json, with a servers object and a type:
{
"servers": {
"remote-tools": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.example.com/mcp"],
"env": { "NODE_EXTRA_CA_CERTS": "/Users/you/corp-root.pem" }
}
}
}
To use the OS store instead, replace the variable with "NODE_USE_SYSTEM_CA": "1" on Node 22.19.0 and 24.6.0 or later, or "NODE_OPTIONS": "--use-system-ca" on Node 22.15.0 or later before that. Under bunx, Bun has honoured NODE_EXTRA_CA_CERTS since bun 1.1.22 and reads NODE_USE_SYSTEM_CA=1 too.
For Claude Code’s own connections (url entries, OAuth sign-in and claude.ai connectors), the native binary reads the OS store as well as its bundled roots, since CLAUDE_CODE_CERT_STORE defaults to bundled,system; a root IT installed there needs nothing more. A root that exists only as a file goes in the env block of ~/.claude/settings.json, which background agents and the Desktop app’s Code tab read too:
{
"env": { "NODE_EXTRA_CA_CERTS": "/Users/you/corp-root.pem" }
}
An older npm install still running on your own Node takes NODE_EXTRA_CA_CERTS the same way, and --use-system-ca only on Node 22.15.0 or later.
4. Match the transport
- stdio, including mcp-remote: the
envblock from step 3 is the whole fix, in every client. - Streamable HTTP or SSE as a
url: the client connects. Claude Code uses the setting above. VS Code loads the OS store whilehttp.systemCertificatesis true, its default, so add the proxy root there: macOS, Windows or Linux. Cursor documents no certificate setting for its own HTTP transport: run the server through mcp-remote as stdio, or exclude the host at the proxy (step 5). - Hosted OAuth: the client’s setting covers discovery and token fetches; the sign-in page opens in your browser, which uses the OS store. Claude Desktop reaches custom connectors from Anthropic’s infrastructure, not from your machine, so only its local stdio servers need anything.
5. Or exclude the MCP hosts from inspection
No client configuration needed. Ask the proxy team to exclude the MCP host, its OAuth authorisation server and, for claude.ai connectors used from Claude Code, mcp-proxy.anthropic.com from TLS inspection. Cursor’s network page notes that some enterprise proxies mishandle HTTP/2 streaming and requires SSE passthrough without buffering from any proxy that inspects. That matters for MCP too: Streamable HTTP carries server messages over SSE, so a buffering proxy leaves a server that connects and never answers a tool call. Exclusion fixes both.
Check it worked
Restart the client fully: Node reads NODE_EXTRA_CA_CERTS once at process start, and for Claude Desktop closing the window is not enough, quit it. Then, in Claude Code:
claude mcp list
remote-tools: npx -y mcp-remote https://mcp.example.com/mcp - ✔ Connected
A failing server shows ✘ Failed to connect with the error appended, and claude mcp get remote-tools repeats it on an Issue: line; ! Needs authentication means TLS worked. Start with claude --debug and look in ~/.claude/debug/<session-id>.txt for CA certs: Appended extra certificates from NODE_EXTRA_CA_CERTS, the proof the file was read. Claude Desktop writes mcp.log and mcp-server-NAME.log (the server’s stderr) under ~/Library/Logs/Claude or %APPDATA%\Claude\logs; Cursor shows MCP Logs in the Output panel (Cmd+Shift+U); VS Code offers Show Output from MCP: List Servers; mcp-remote with "--debug" in args writes ~/.mcp-auth/<server-hash>_debug.log.
The chain checker names inspection products:
If something goes wrong
- Works in the terminal, fails in the app: the shell export is not reaching the subprocess; move it into the server’s
envblock. The code is Node’s: SELF_SIGNED_CERT_IN_CHAIN. - Claude Code OAuth sign-in fails with
SDK auth failed: self signed certificate in certificate chainwhileclaude mcp listconnects: issue #55760 in anthropics/claude-code reports that from v2.1.113 the OAuth initiation path ignoredNODE_EXTRA_CA_CERTS; the project marked it fixed in v2.1.133, so runclaude update. An OAuth failure no CA setting touches may be the discovery regression reported in issue #66456. See the Claude Code error page. UNABLE_TO_VERIFY_LEAF_SIGNATUREpersists: the proxy may be sending only the leaf; UNABLE_TO_VERIFY_LEAF_SIGNATURE shows how to tell.npxcannot fetch the package: that download is npm’s own, before the server starts: UNABLE_TO_GET_ISSUER_CERT_LOCALLY.- A bare
fetch failed, a Cursor server stuck on Loading, or a server listed without tools: the client’s log above, or the Node one-liner from step 1, prints the inner code. The editors’ own stores: VS Code / Cursor: self signed certificate in certificate chain. - mcp-remote keeps failing: clear its cache with
rm -rf ~/.mcp-auth; if the proxy must be addressed explicitly, add"--enable-proxy"toargsandHTTPS_PROXYtoenv.
Why this works
A client accepts a chain only when it can link it to a root already in the trust store it reads, and behind an inspecting proxy every chain ends at the proxy’s root. Each runtime keeps its own store: the browser reads the operating system’s, Node ships its own bundle and ignores the OS store unless told to, and the native Claude Code binary reads both. So the browser working proves nothing about the subprocess your client launched; the fix is the one root in the one store that process reads. Who do we trust? explains trust stores and TLS inspection; Certificate chains explains path validation up to a trust anchor.
Go deeper
- MCP transports and the MCP debugging guide.
- Claude Code network configuration and MCP in Claude Code:
CLAUDE_CODE_CERT_STOREand thetyperule. - Cursor network configuration and Cursor MCP.
- VS Code MCP configuration reference, Manage MCP servers and Network connections.
- Node.js CLI reference:
NODE_EXTRA_CA_CERTS,--use-system-ca,NODE_USE_SYSTEM_CA. - Bun environment variables and the mcp-remote README.
Early edition. Written with AI assistance and checked against primary sources; an independent expert review is planned. Found a mistake? Tell us.