tunnel-client is the customer-run agent behind Secure MCP Tunnel. It connects
a private or localhost MCP (Model Context Protocol) server to ChatGPT, Codex,
the Responses API, and AgentKit through an OpenAI-hosted MCP tunnel endpoint,
while keeping the MCP server off the public internet.
This CLI and its Go SDK run beside your private MCP server.
Applications call the OpenAI-hosted /v1/mcp/{tunnel_id} endpoint through their
MCP transport; the runtime receives those requests and delivers responses.
The poll/response endpoints are the runtime's queue protocol for client
implementers. See the architecture for the request flow
and the protocol when building a compatible runtime.
Use it when:
/healthz, /readyz, /metrics,
and /ui before a connector or API call depends on it.If you searched for "secure MCP tunnel", "MCP tunnel ChatGPT", "connect local
MCP server to ChatGPT", "connect local MCP server to Codex", "localhost to
ChatGPT", or "Codex local MCP", start with tunnel-client help quickstart,
then read the onboarding guide below.
docs/onboarding.md.docs/architecture.md.docs/permissions.md.docs/deployment/overview.md.docs/troubleshooting.md.docs/protocol.md and use
docs/openapi.json. Optional client features use the
common X-Tunnel-Client-Capabilities header.--mcp.forward-trace-context to carry W3C trace context in MCP params._meta
over stdio and Streamable HTTP.
Opt-in local span export uses
--tracing.enabled --tracing.file=/private/new-trace.jsonl. Complete traces
require compatible service queue handoff and caller parent propagation first.--forward-request-id=mcp,harpoon to include Harpoon REST
requests, --forward-request-id=mcp,oauth to include eligible queued OAuth
discovery requests, or --forward-request-id=none to disable
automatic forwarding.
The same setting is available as FORWARD_REQUEST_ID or top-level YAML
forward_request_id; see request ID forwarding.examples/go-sdk-inmemory.With a runtime API key and tunnel ID, run the built-in server_info, echo,
and uppercase tools without a separate MCP server:
export CONTROL_PLANE_API_KEY="sk-..."
export CONTROL_PLANE_TUNNEL_ID="tunnel_0123456789abcdef0123456789abcdef"
tunnel-client run --embedded-stateless-mcp-stub --health.listen-addr 127.0.0.1:0
--embedded-stateless-mcp-stub uses stateless MCP handling even when a client
sends initialize and notifications/initialized. It issues no MCP session
ID, and these demo tools do not require MCP session affinity between processes.
OAuth and application state have separate requirements.
--embedded-mcp-stub keeps its existing compatibility behavior: legacy
initialization and session requests use stateful handling; self-contained
modern discovery and tool requests use stateless handling. Choose one embedded
mode per run. Both share the embedded listen-address, Unix-socket, server-name, and
server-version options; see embedded demo configuration
for defaults and target conflicts.
The module can run in the same process as a Go MCP server. The MCP server does
not need to bind a port or use stdio: give the server side of an in-memory MCP
transport pair to your server and the client side to tunnelclient.New.
go get github.com/openai/tunnel-client
import (
"context"
"github.com/modelcontextprotocol/go-sdk/mcp"
tunnelclient "github.com/openai/tunnel-client"
)
ctx := context.Background()
server := mcp.NewServer(&mcp.Implementation{Name: "my-server", Version: "1.0.0"}, nil)
serverTransport, tunnelTransport := mcp.NewInMemoryTransports()
go server.Run(ctx, serverTransport)
client, err := tunnelclient.New(tunnelclient.Config{
TunnelID: "tunnel_0123456789abcdef0123456789abcdef",
APIKey: apiKey,
}, tunnelTransport)
if err != nil {
return err
}
return client.Run(ctx)
The runnable Go SDK example registers an echo
tool and connects it to the OpenAI Tunnel control plane.
developers.openai.com/api/docs/guides/secure-mcp-tunnelsdocs/end-user-guide.mddocs/onboarding.mddocs/permissions.mddocs/architecture.mddocs/connectors.mddocs/protocol.mddocs/openapi.jsondocs/enterprise-customer-onboarding.mddocs/configuration.mddocs/deployment/overview.mddocs/deployment/cloudflared.mddocs/troubleshooting.mddocs/development.mdexamples/go-sdk-inmemorydocs/roadmap.mdOn macOS, Homebrew is the supported installation path. Directly downloaded
release ZIPs are not currently notarized and can be blocked by Gatekeeper. If
a manually downloaded archive is blocked, do not use xattr, spctl, or
Open Anyway to bypass the check; install from the official OpenAI tap
instead:
brew install openai/tools/tunnel-client
Verify the installed version, then start with the guided setup:
tunnel-client --version
tunnel-client help quickstart
The Formula installs the matching tunnel-client, bundled cloudflared,
and companion manifest together, while exposing only the tunnel-client
command. It also installs Bash, Zsh, and Fish completions for that version.
If your shell does not load them automatically, follow
Homebrew's shell completion setup.
For Docker, Kubernetes, or VM deployments, see
docs/deployment/overview.md.
To generate the shareable guide output locally:
make end-user-guide-screenshots
make end-user-guide-html
make end-user-guide-slides
The Homebrew Formula supports brew services. It supervises
tunnel-client run using the profile at
$(brew --prefix)/etc/tunnel-client.yaml, starts at login, and restarts the
runtime after it exits. Installation and upgrades do not create or replace
that profile.
First, select the profile you already configured. If it belongs to a managed
alias, find its profile_path with tunnel-client runtimes status <alias> --json,
then run `tunnel-client runtimes stop
| 日期 | 榜单 | 排名 | 周期新增 | 总 STAR |
|---|