When using conversational AI models as coding assistants, one of the most frustrating bottlenecks is the model's disconnection from your actual execution environment. Copying code back and forth between your browser and editor, applying changes, running tests in a separate terminal, and pasting terminal errors back into prompts slows down your workflow.
The Model Context Protocol (MCP) was introduced to solve this exact problem. However, many existing MCP servers are designed purely as local stdio processes tied to a single desktop application on the same machine. What if you want to work remotely from a laptop, interact via ChatGPT web, or use a high-performance home PC or Linux server as a headless remote development workstation?
The open-source project chatgpt-remote-mcp is a self-hosted development server built specifically to bridge this gap. Running via Docker Compose on Windows or Linux, it combines Cloudflare Tunnel, an OAuth 2.0 authentication framework, 21 comprehensive development tools, and asynchronous process management to let ChatGPT securely interact with your machine from anywhere.
| Approach | Access Location | Router Port Forwarding | Authorization Standard | Background Processes |
|---|---|---|---|---|
| Traditional stdio MCP | Local desktop client only | None required | Local process trust | One-shot commands only |
| Port-Forwarded HTTP MCP | Anywhere on the internet | Required (Exposes Public IP) | Basic Auth / static tokens | Dropped on HTTP timeouts |
| chatgpt-remote-mcp | Web, mobile, from anywhere | None required (Outbound tunnel) | OAuth 2.0 + Approval Key | Streaming Ring Buffer monitoring |
Three Real-World Challenges with Remote MCP
Building a toy HTTP MCP server for localhost is straightforward. But when you try to connect it to ChatGPT for real remote access, you quickly run into three obstacles.
First, exposing open ports to the public internet creates severe security risks. Opening router firewall ports or configuring DDNS on a private development machine invites port scans and malicious bots.
Second, ChatGPT enforces strict integration standards. OpenAI's custom MCP interface requires an OAuth 2.0 flow for secure authorization delegation. Servers lacking standardized authorization and token endpoints fail during client registration.
Third, real coding workflows require background process management. Development isn't just about reading files; you need to install packages, run builds, launch test runners, and inspect streaming stdout/stderr buffers over time. A simple one-shot execution tool cannot handle interactive workflows.
Architecture and Core Features
chatgpt-remote-mcp is structured into a tunneling layer, a reverse proxy layer, and an Express-based MCP application layer.
- subgraph
- CG
- end
- CFT
- CFD
- NG
- APP
- FS
- PM
| Core Component | Technology | Primary Role and Protection Boundary |
|---|---|---|
| Edge Tunnel | Cloudflare Tunnel (cloudflared) | Bidirectional encrypted tunnel without opening inbound ports; edge DDoS mitigation. |
| Edge Proxy | Nginx Reverse Proxy | Client IP normalization (X-Forwarded-For), header sanitization, per-client rate limiting. |
| Auth Engine | Express OAuth 2.0 Server | Standards-compliant OAuth grant flow with master Approval Key protection. |
| Tool Execution | 21 MCP Tool Handlers | Filesystem operations, batch reading, script execution, asynchronous ring buffer logging. |
1. Zero Inbound Port Forwarding via Cloudflare Tunnel
When the server starts, the internal cloudflared container establishes an outbound tunnel to Cloudflare's edge network. No inbound firewall ports need to be opened on your router. You get automated SSL certificates and DDoS protection out of the box simply by specifying your Cloudflare Zero Trust tunnel token in .env.
2. Built-in OAuth 2.0 Server with Approval Keys
chatgpt-remote-mcp includes a complete OAuth 2.0 authorization server implemented in Express. When ChatGPT requests client authorization via /oauth/authorize, an explicit master Approval Key is required to complete the grant.
- Approval Key Validation: Only clients presenting the generated secret key can obtain tokens, preventing unauthorized parties from connecting even if they discover your tunnel domain.
- Client Registration Capacity: Bounded by
MCP_OAUTH_MAX_REGISTERED_CLIENTS(default 256) to protect memory and prune inactive clients safely. - Token Lifecycle: 1-hour access tokens and 30-day refresh tokens provide a practical balance between security and convenience.
3. Nginx Boundary and IP Normalization
A lightweight Nginx container sits in front of the application. It normalizes client IP headers (X-Forwarded-For) at the trust boundary so that Express can enforce accurate per-client rate limits.
4. 21 Rich MCP Development Tools
The server provides 21 granular tools for interacting with files and processes:
| Category | Tool Names | Description |
|---|---|---|
| Filesystem Inspection | list_directory, stat_path, hash_file | Recursive directory traversal, file metadata, and sha256 checksums. |
| Reading & Batching | read_file, read_files | Single file reading and multi-file batch reading in a single turn. |
| Editing & Patching | write_file, replace_in_file, apply_patch | Creating files, exact string replacement, and unified diff patching. |
| Path Management | make_directory, copy_path, move_path, remove_path, chmod_path | Directory creation, file movement, deletion, and permission modes. |
| File Transfer | upload_file, download_file | Base64-encoded file upload and download. |
| Command Execution | exec_command, run_script | Bounded shell commands and script file execution. |
| Process Lifecycle | write_stdin, read_process, terminate_process, list_processes | Spawning background processes, sending stdin, reading buffers, termination. |
In particular, read_files enables ChatGPT to inspect multiple source files in one turn, reducing latency and context token overhead.
5. Long-Running Process Buffer Management
Longer tasks such as running test suites or building bundles cannot be cut short by rigid HTTP timeouts. The process manager decouples processes asynchronously and buffers stdout and stderr in memory. ChatGPT can inspect incremental logs with read_process and send inputs via write_stdin.
list_directory, read_files
write_file, replace_in_file, apply_patch
exec_command, run_script
Quick Start Guide
chatgpt-remote-mcp is optimized for Windows 11 with PowerShell 7 and Docker Desktop, but runs smoothly on any Linux host with Docker Compose v2.
Step 1: Clone and Initialize Keys
Clone the repository:
git clone https://github.com/munlucky/chatgpt-remote-mcp.gitcd chatgpt-remote-mcp
Generate independent secret keys:
.\scripts\setup-keys.ps1
This generates an initial .env file with secure random secrets for the OAuth approval key and internal health probes.
Step 2: Configure Environment Variables
Edit .env to match your domain and workspace path:
# Public domain routed through CloudflarePUBLIC_DOMAIN=mcp.yourdomain.com # Cloudflare Zero Trust Tunnel TokenCLOUDFLARE_TUNNEL_TOKEN=eyJhIjoi... # Host workspace path to exposeHOST_WORKSPACE_PATH=C:\dev\my-project # Container mount pathCONTAINER_WORKSPACE_PATH=/workspace
Step 3: Verify and Start
Validate Docker status, mount paths, and environment settings:
.\scripts\verify-env.ps1
If checks pass, start the server:
.\scripts\start.ps1
Step 4: Copy the Approval Key
Retrieve your OAuth approval key:
.\scripts\get-approval-key.ps1
Step 5: Connect to ChatGPT
- In ChatGPT, open Settings and navigate to Developer or Model Context Protocol settings.
- Click Add MCP Server.
- Enter your tunnel URL:
https://mcp.yourdomain.com/mcp - Choose OAuth 2.0 and provide your Approval Key in the authorization prompt.
- Once connected, all 21 tools will be active in your chat sessions.
Practical Usage Examples
Here are common ways to use the server in conversation:
1. Codebase Exploration and Direct Patching
Prompt:"Read package.json and src/index.ts, design a new /health route,and apply the patch directly to the code."
ChatGPT uses read_files to collect both files in one turn, plans the route, and calls apply_patch or replace_in_file to update the codebase on your machine.
2. Running Test Suites in the Background
Prompt:"Run npm test in the background, monitor the process output,and diagnose any failing test cases."
ChatGPT spawns the test runner, polls the process buffer via read_process, and summarizes the test results.
3. Reviewing Usage Telemetry
Administrators can inspect aggregate tool usage over the past 24 hours:
.\scripts\usage-report.ps1 -Hours 24
This filters out automated health probes and displays tool calls and active sessions.
Summary
chatgpt-remote-mcp turns any Windows or Linux workstation into a secure, private AI development server. With Cloudflare Tunnel protecting your network perimeter and an integrated OAuth 2.0 server enforcing access control, you can give ChatGPT direct access to your codebase without sacrificing security.
Explore the open-source repository at github.com/munlucky/chatgpt-remote-mcp to set up your own remote development bridge.

댓글
GitHub 계정으로 로그인하면 댓글을 남길 수 있습니다. 댓글은 GitHub Discussions를 통해 운영됩니다.