AI Agents DIY Project: A Custom Connector for ChatGPT to Control Claude-Code Sessions

How I built a DIY MCP server to let ChatGPT remotely orchestrate Claude-Code sessions — enabling real coding work while away from my desk.

Technical diagram showing ChatGPT mobile app connecting through an MCP tunnel to a local Mac supervisor that manages multiple Claude-Code sessions via tmux, illustrating remote AI orchestration architecture

Since the Model Context Protocol (MCP) was introduced, I've been fascinated by its potential. It's clear MCP is going to be everywhere — letting AI agents like ChatGPT plug into tools, APIs, and systems for all kinds of workflows.

But my interest wasn't just theoretical. I had a very practical itch to scratch.

Sometimes I'm at the gym, walking, or away from my desk — and I remember a bug I want to test, or a task I want to run in a project. I use Claude-Code a lot for implementation, but the friction was obvious:

  • ChatGPT is where I brainstorm ideas, search online, and review docs or architectures.
  • Claude-Code is where the real coding happens.

And I was stuck as the human glue between them — copy-pasting, switching tools, waiting until I was back at my Mac.

So I asked myself: What if ChatGPT could directly manage my Claude sessions while I'm away?

That question turned into this DIY project: a Claude-Code MCP Controller. It's not production-ready. It's not fully secure. But it works — and it showed me a glimpse of what AI orchestration between tools really looks like.

👉 Repo: mostafa-drz/claude-code-mcp-controller


The Problem: AI in Silos

Even though I use both ChatGPT and Claude every day, they've always lived in separate worlds:

  • ChatGPT → brainstorming, research, reviewing architecture decisions
  • Claude-Code → running commands, editing files, shipping changes

The result? Context switching. Manual copy-paste. Lots of wasted time.

And the worst part: when I'm away from my desk, I can still brainstorm with ChatGPT on my phone, but I can't act on those ideas. I can't start a Claude session, run a build, or check logs until I'm back at my Mac.

That's the friction this project set out to solve:

👉 Let ChatGPT become a remote controller for Claude-Code sessions, so I can both think and act inside the same conversation — no matter where I am.


The Vision: ChatGPT as Remote Orchestrator

I didn't want to replace Claude or ChatGPT — they each shine in their own lane. What I wanted was orchestration: ChatGPT handling the high-level planning and directly controlling Claude sessions to execute those plans.

And more importantly: I wanted this to work even when I wasn't at my desk.

Imagine this:

  • I'm at the gym or walking outside when an idea hits.
  • I open ChatGPT on my phone, start brainstorming the solution.
  • ChatGPT says: "Want me to spin up a Claude session and run this?"
  • It connects back to my Mac, runs the commands in Claude-Code, and sends me the results — all inside the same chat.

Now, instead of waiting until I'm home, I can keep momentum wherever I am. ChatGPT becomes the remote brain, Claude the hands-on terminal, and MCP the bridge making it all work.


The Architecture

The system bridges ChatGPT and Claude-Code using MCP (Model Context Protocol) as the communication layer:

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   ChatGPT       │◄──►│   Local MCP      │◄──►│  Mac Supervisor │
│   Mobile App    │    │   + ngrok tunnel │    │  (Local Agent)  │
└─────────────────┘    └──────────────────┘    └─────────────────┘
                                │                        │
                       HTTPS via ngrok                   │
                       JSON-RPC 2.0 over SSE             ▼
                                                   ┌─────────────────┐
                                                   │ Claude Sessions │
                                                   │ (via tmux)      │
                                                   │ • session_1     │
                                                   │ • session_2     │
                                                   │ • session_N     │
                                                   └─────────────────┘

Core Components:

  1. ChatGPT Custom Connector: Acts as the orchestration layer, translating natural language into MCP tool calls
  2. MCP Server (FastMCP 2.12.4): Exposes 8 tools as MCP endpoints - list/create/message/logs/status/terminate/check_prompts/respond_to_prompt
  3. Supervisor: Local agent managing Claude session lifecycle with secure UUID-based session tracking
  4. tmux Sessions: Provides reliable process control (send-keys, capture-pane, list-sessions) for each Claude instance
  5. ngrok Tunnel: Ephemeral HTTPS tunnel enabling mobile access without exposing permanent endpoints

Communication Flow: ChatGPT → ngrok HTTPS → MCP Server (JSON-RPC 2.0) → Supervisor HTTP API → tmux commands → Claude-Code sessions

Security Model:

  • Supervisor only manages sessions it creates (process ownership isolation)
  • Cryptographically secure UUIDs for all session identifiers
  • Ephemeral ngrok URLs that expire when tunnel closes
  • Complete audit trail of session creation → management → termination

Design Principles:

  • Simplicity: ~500 lines of Python using FastMCP framework
  • Debuggability: All supervisor operations exposed as HTTP APIs
  • Fail Gracefully: Clear error messages propagated back to ChatGPT
  • Session Isolation: Each Claude instance sandboxed in separate tmux session

Why Local Deployment: The supervisor must run locally because it needs direct access to Mac processes. Cloud deployment cannot control local Claude sessions - they exist as local processes that only a local supervisor can manage.


The Challenges

This wasn't smooth sailing. A few key blockers:

  1. OAuth didn't work — ChatGPT connectors have quirks, and I couldn't get OAuth 2.1 + PKCE working. Using ephemeral ngrok URLs became the pragmatic (though insecure) workaround.
  2. Unstable connections — sometimes the connector just dropped without explanation. Likely early-stage ecosystem issues.
  3. Initial over-engineering — I started with PTY/pexpect madness. Eventually switched to tmux, which solved almost everything elegantly.

First Real Test: Remote Code Navigation

The first time I got it working, I tried adding navigation to my /notes pages. After wrestling with connector setup and OAuth dead ends, the flow finally clicked.

I asked ChatGPT (on mobile) to spin up a Claude session, implement the feature, and run checks. When I got back home, the changes were already in place.

That moment was surreal — real code changes, shipped while I was away. It felt like a glimpse into the future of remote AI-assisted development.

Next steps? Adding more visibility — maybe screen recording or screenshot support — so I can "see" results without waiting until I'm back at my desk.


Remaining Gaps

This project worked, but a few things need solving longer-term:

  • Conversation channels → Ideally, Claude, ChatGPT, and I should all share one continuous log. Right now, I still need to poll logs to see if Claude finished.
  • Stable auth → OAuth and proper access control need to mature.
  • Better notifications → Push alerts when sessions complete would make it truly seamless.

Closing Thoughts

Custom connectors are powerful. This experiment showed me how they can turn ChatGPT into an AI orchestrator — not just a chat partner.

It's early days, but the possibilities are exciting: orchestrating multiple agents, bridging tools, and keeping workflows moving even when we're away from the desk.

This is just a DIY hack, but it points toward a future where:

  • ChatGPT and Claude collaborate directly.
  • AI agents manage context across tools.
  • Humans drop into the loop only when it matters.

👉 Repo here if you want to try it yourself: Claude-Code MCP Controller