Writing ·
How to securely expose a private MCP server in 2026
Keep a private MCP server non-public while giving an agent a controlled connection path—then retain authorization, tool policy, auditability, and recovery at the server boundary.
By Youssef Hemimy · MCP · security · agent reliability
You do not need to make a private MCP server public to let an agent use it. Keep the server inside its existing network boundary, provide a controlled connection path, and keep authorization, tool policy, and auditability at the server. The connection solves reachability; the server still decides what work is allowed.
- 0
- inbound public listeners required by the documented tunnel pattern
- 1
- controlled outbound path from the private network
- 2
- standard MCP bindings: stdio and Streamable HTTP
- 4
- controls to keep separate: path, access, policy, recovery
Agent surface
A product needs a normal MCP request path.
Outbound client
Runs where it can reach the private server.
Private MCP server
The server stays behind its existing network boundary.
Reachability is one control. It does not replace the controls that decide which calls are allowed, recorded, or safely retried.
Start with the boundary, not the endpoint
The question is not simply whether an MCP server is local or remote. It is where the network connection begins, where it terminates, and which layer can reject a request before a tool runs. For example, OpenAI's Secure MCP Tunnel places tunnel-client inside the network that can already reach the private MCP server. The client opens an outbound HTTPS path, receives queued MCP work, forwards the JSON-RPC request locally, and returns the response through that same path.
That is a useful pattern when a product surface needs to call a server that should remain behind a firewall. It is not an MCP requirement: MCP keeps its protocol semantics separate from the transport binding, with standard bindings for stdio and Streamable HTTP.
Choose the connection pattern by the boundary you need
| Situation | Connection shape | Control that must remain explicit |
|---|---|---|
| The server is intended to be publicly reachable | A normal remote MCP endpoint can fit the boundary. | Transport authorization, tool policy, and call records. |
| The server stays on a private network but an agent surface needs it | Use a controlled path initiated from inside that network, such as an outbound tunnel pattern. | Which identity may traverse the path and which server tools that identity can use. |
| The runtime and server share a tightly controlled host boundary | A local process connection, including stdio where appropriate, can keep the path local. | Process credentials, tool inventory, and recovery when the process restarts. |
These are boundary choices, not security grades. A private route with broad credentials is still broad. A public route with a careful authorization design may be appropriate for a different workload. The right question is: what must remain unreachable, and who is allowed to cross each line?
Keep reachability separate from authorization
MCP's authorization guidance covers restricted HTTP-based servers at the transport layer, while also making clear that authorization is optional across MCP implementations. When it is supported, the guidance includes scoped access and discovery mechanisms. That gives a deployment a place to express least privilege; it does not remove the need for server-side validation.
- Expose only the tools the connecting identity actually needs.
- Keep read paths and consequential write paths visibly different.
- Validate tool inputs where the side effect occurs, not in prompt text.
- Record enough request identity and outcome to investigate a retry.
- Put a human approval boundary in front of actions that cannot be safely replayed.
The MCP tools specification permits the available tool set to vary by the authorization presented on the request. That makes tool exposure a real policy surface, not just a convenience setting. It is also why a production MCP server needs an explicit contract and why human approval gates belong outside the model prompt.
Make the path operable before you depend on it
The first incident is usually not a glamorous attack; it is a dropped connection, a rotated credential, an unavailable private server, or a tool scope that changed while a workflow was in flight. AgentOps Hardening treats those as separate states to observe and recover, rather than a reason to replay a whole workflow blindly.
- Document the private network boundary and the outbound connection owner.
- Define which identities may use the path and which tools each identity can access.
- Log the request identity, tool, outcome, and retry relationship without retaining secrets.
- Test connection loss and credential rotation before unattended use.
- Link the path to the same observability view as the agent workflow.
Pair this pattern with an agent observability dashboard so connection and tool failures do not vanish into a generic agent error. The harness is the product, not the prompt—and the network boundary is part of that harness.
Sources
FAQ
Do I need to make a private MCP server public?
No. A private-server pattern can keep the server behind its existing network boundary while a controlled connection path reaches it. The important follow-up is to keep authorization and tool policy at the server boundary.
Does an outbound tunnel replace MCP authorization?
No. Network reachability and authorization are different controls. For HTTP-based MCP servers, the MCP specification describes transport-level authorization; a deployment still needs to decide which identities and scopes may use which tools.
What should I check before connecting an agent to a private MCP server?
Verify the connection path, the identity allowed through it, the tool set exposed to that identity, the audit record for each call, and the recovery behavior when the path or server becomes unavailable.
Can a private MCP server use stdio or HTTP?
The MCP specification defines standard stdio and Streamable HTTP bindings. OpenAI's Secure MCP Tunnel guide says its tunnel client can reach a private MCP server over stdio or HTTP; other products may support different combinations.
Building something that has to hold up?
We do this work for teams — agent reliability hardening, custom MCP servers, and full-stack AI systems built to survive production.