Skip to main content

Use Binary Ninja with ChatGPT via MCP securely

·5 mins· loading · loading · ·
Jaybird1291
Author
Jaybird1291
Table of Contents

First, I’d like to thank Jerry for his post Use Binary Ninja with ChatGPT Desktop App - the first steps are literally the same. If you already have a domain, it’ll be free for you. If like me, you don’t; it’ll cost you less than $0.85.

Architecture
#

  • ChatGPT (web or desktop app)
  • Binary Ninja with Binary Ninja MCP plugin
  • Cloudflare Tunnel (cloudflared)
  • A domain

Why Cloudflare Tunnel?
#

ChatGPT can only talk to a remote MCP server if that server is publicly reachable over HTTPS. A FastMCP instance running on your machine (for example on localhost:8050) is typically not reachable from the Internet because it sits behind NAT, a consumer router, or a corporate firewall. Cloudflare Tunnel solves this by letting a small agent (cloudflared) on the machine create outbound-only connections to Cloudflare’s edge, so traffic reaches your local service without exposing a publicly routable IP address or opening inbound ports on your router.

Operationally, Cloudflare Tunnel gives you a stable HTTPS endpoint (for example https://mcp.yourdomain.tld) that Cloudflare terminates at the edge and then forwards through the tunnel to your local origin (for example http://127.0.0.1:8050). Because the tunnel is outbound, it usually only requires allowing egress connectivity from your machine to Cloudflare (Cloudflare documents the relevant egress requirements, including port 7844 for QUIC/HTTP2).

In addition to connectivity, using Cloudflare as the front door enables edge security controls that are difficult to do safely on a home network, such as applying WAF rules and enforcing an IP allowlist (e.g., only permitting OpenAI/ChatGPT egress IP ranges) before traffic ever reaches the machine running FastMCP.


Installing Binary Ninja MCP plugin
#

In Binary Ninja:

  1. Open Manage Plugins
  2. Search for Binary Ninja MCP by fosdickio
  3. Install the plugin
  4. Run the plugin (click on “MCP: Stopped”)


Setting up bridge environment
#

  1. Install uv (Python package and project manager) if it’s not already installed
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  1. Install plugin’s requirements
cd "$HOME\AppData\Roaming\Binary Ninja\repositories\community\plugins\fosdickio_binary_ninja_mcp"
uv init
uv add -r .\requirements.txt

Converting the bridge to a FastMCP HTTP server
#

As Jerry said, the original bridge script only supports stdio as an MCP transport, but ChatGPT expects an HTTP-based MCP endpoint. To fix that, we’ll switch it to FastMCP with streamable-http transport.

  1. Install FastMCP package
uv add fastmcp
  1. Update imports in $HOME\AppData\Roaming\Binary Ninja\repositories\community\plugins\fosdickio_binary_ninja_mcp\bridge\binja_mcp_bridge.py
# Change 
from mcp.server.fastmcp import FastMCP  # line 12

# to 
from fastmcp import FastMCP
  1. Make it use HTTP transport instead of stdio
# Change in "if __name__ == "__main__":" block
mcp.run() # line 865

# to
mcp.run(transport="streamable-http", port=8050)  # or any port you prefer

This will expose the MCP server over HTTP on 127.0.0.1:8050.

  1. Start the bridge
cd "$HOME\AppData\Roaming\Binary Ninja\repositories\community\plugins\fosdickio_binary_ninja_mcp\bridge"
.\.venv\Scripts\activate

python .\binja_mcp_bridge.py

Note that you will have to relaunch it every time you want to use the MCP server.


Setting up a domain & Cloudflare Tunnel
#

Domain
#

If you already have a domain you can skip this part.

To pay only $0.85 per year for a domain (with Whois privacy) you can buy the cheap [6to9-digit.xyz] (cf. 1.111B Class .xyz domains) like this one on Namecheap:

  1. Add to cart & pay
  2. Check your spam to verify your account (important or it’ll just stay in “pending” status)
  3. Verify DNSSEC is disabled

Cloudflare Tunnel
#

  1. Create an account here CloudFlare One & verify your email or you’ll get stuck (check spam)
  2. Go to Account home
  3. Select Onboard a domain
  4. Enter your domain apex domain (domain.tld) and select Continue
  5. Select the free plan
  6. On Namecheap update your Nameservers with “Custom DNS” and put Cloudflare’s ones
  7. Wait (and force update) until it’s “active” on Cloudflare

Next step is:

  1. Get back on CloudFlare One
  2. Go to Networks > Connectors > Cloudflare Tunnels
  3. Select Create a tunnel
  4. Choose Cloudflared for the connector type and select Next
  5. Enter a name like “MCP” and save
  6. Install cloudflared on your machine but don’t run it!
  7. Authenticate (if you didn’t verify your email you’ll get stuck here)
cloudflared login
  1. Create a tunnel
cloudflared tunnel create <tunnel-name>
  1. Configure the tunnel to route mcp.yourdomain.tld to http://127.0.0.1:8050
mkdir -p "C:\Windows\System32\config\systemprofile\.cloudflared"

# Copy cert.pem & tunnel-id.json (edit the ID) files in the directoru 
cp "$HOME\.cloudflared\tunnel-ID.json" "C:\Windows\System32\config\systemprofile\.cloudflared"

cp "$HOME\.cloudflared\cert.pem" "C:\Windows\System32\config\systemprofile\.cloudflared"
  1. Create config.yml file here C:\Windows\System32\config\systemprofile\.cloudflared\config.yml (edit tunnel UUID & hostname)
tunnel: <TUNNEL-UUID>
credentials-file: C:\Windows\System32\config\systemprofile\.cloudflared\<TUNNEL-UUID>.json

ingress:
  - hostname: mcp.yourdomain.tld
    service: http://127.0.0.1:8050
  - service: http_status:404

logfile: C:\Cloudflared\cloudflared.log
  1. Create a DNS route to the tunnel
cloudflared tunnel route dns <tunnel-name> mcp.yourdomain.tld
  1. Start the tunnel
cloudflared.exe --config=C:\Windows\System32\config\systemprofile\.cloudflared\config.yml tunnel run

Note that you could either create a service to run this everytime or have to run this command every time you want to use your ChatGPT connector.

Improve security
#

For this we’ll block everything BUT ChatGPT egress IP. In fact, OpenAI write in its documentation that it’s the only method for now:

A frequent question is how your MCP server can confirm that a request actually comes from ChatGPT. Today the only reliable control is network-level filtering, such as allowlisting ChatGPT’s published egress IP ranges.

  1. Get the IP here https://openai.com/chatgpt-connectors.json
  2. Convert to CSV
  3. Create an “IP list” on Cloudflare
    • Go to Settings
    • Go to Lists
    • Select Create a new list
    • For Content type, select IP
    • Paste all IP from the CSV
  4. Create a WAF rule “Block non-allowed list”
(http.host eq "mcp.yourdomain.tld" and not ip.src in $openai_chatgpt_egress)

The list can change! Often check the chatgpt-connectors.json list and review the field “creationTime”

Creating custom ChatGPT connector
#

Now you should have:

  1. .\binja_mcp_bridge.py (FastMCP bridge service) running
cd "$HOME\AppData\Roaming\Binary Ninja\repositories\community\plugins\fosdickio_binary_ninja_mcp\bridge"
.\.venv\Scripts\activate
python .\binja_mcp_bridge.py
  1. Cloudflare tunnel running
cloudflared.exe --config=C:\Windows\System32\config\systemprofile\.cloudflared\config.yml tunnel run

To create your ChatGPT custom connector:

  1. Go to ChatGPT Web or Desktop App
  2. Go to SettingsConnectorsAdvanced settings
  3. Enable Developer Mode
  4. Click Back and then Create
  5. As URL put https://mcp.yourdomain.tld/mcp/
  6. Save the connector and normally everything should work.

As you click save, you’ll see some logs appearing on your FastMCP terminal (ChatGPT accessing it):


Using the connector
#

Basically just type /the-name-of-your-connector and voilà: