October 25, 2026
Designing an MCP-Based Security Lab for Agentic Security Research
Connecting Codex, Kali Linux, and REMnux to orchestrate security researching workflows.

By Mahmoud Matar
7 min read
I. Introduction
Security research often involves moving between tools, interpreting their output, and deciding what to investigate next. While solving CTF challenges, I wanted to explore how an AI agent could participate in that process: selecting tools, executing commands, examining results, and using those findings to guide its next steps.
That curiosity led me to build a home lab connecting Codex to Kali Linux and REMnux through the Model Context Protocol (MCP). Running in separate VirtualBox machines, the two environments provide complementary toolsets for security testing, reverse engineering, malware analysis, and digital forensics. Codex runs inside REMnux and accesses tools across both machines, with an SSH tunnel connecting it to the Kali API through a local MCP bridge.
In this article, I will explain how I built it.
II. REMnux Environment
1. Setting up REMnux & Codex
Install the REMnux OVA from the official website and import it into VirtualBox and start the machine.
Note: execute the
remnux upgradecommand just to make sure your REMnux and it tools are up to date
I will be using ChatGPT/Codex for this (because I have a long subscription already)
Install Codex installer from the official website. For me, I opted to install the GUI app because it makes things easier for me.
After downloading. Now install using apt install. After it finishes, just type chatgptin the terminal to open it
If prompted for a keyring password, create yours here
After you log in, everything should be set to start now.
2. Setting up REMnux MCP
Before downloading the REMnux MCP, we need to create some directories. /home/remnux/files/samples and /home/remnux/files/output are essential for the MCP to work correctly.
Also, I am creating a directory called ai-lab for Codex to use as a project.
In the REMnux MCP GitHub Repo, you will find 3 scenarios for installation depending on how you are architecting the home lab; if you are confused, consult the chart below. Our case is scenario #2
#1
+--------------------------------------------------------------------+
| Analyst's Machine |
| |
| +----------------+ +--------------------------------------+ |
| | AI Assistant |---->| remnux-mcp-server (npm package) | |
| | (Claude Code, | MCP | | |
| | Cursor, etc) | | - Blocked command patterns | |
| +----------------+ | - Catastrophic-cmd guards | |
| | - Path sandboxing (opt-in) | |
| +------|-------------------------------+ |
| | |
| +-----------+----------+ |
| v v |
| +--------------+ +--------------+ |
| | Docker Exec | | SSH | |
| | (container) | | (VM) | |
| +------+-------+ +------+-------+ |
| | | |
+-------------------|---------------------|---------------------------+
v v
+-----------+ +-----------+
| REMnux | | REMnux |
| Container | | VM |
+-----------+ +-----------++--------------------------------------------------------------------+
| Analyst's Machine |
| |
| +----------------+ +--------------------------------------+ |
| | AI Assistant |---->| remnux-mcp-server (npm package) | |
| | (Claude Code, | MCP | | |
| | Cursor, etc) | | - Blocked command patterns | |
| +----------------+ | - Catastrophic-cmd guards | |
| | - Path sandboxing (opt-in) | |
| +------|-------------------------------+ |
| | |
| +-----------+----------+ |
| v v |
| +--------------+ +--------------+ |
| | Docker Exec | | SSH | |
| | (container) | | (VM) | |
| +------+-------+ +------+-------+ |
| | | |
+-------------------|---------------------|---------------------------+
v v
+-----------+ +-----------+
| REMnux | | REMnux |
| Container | | VM |
+-----------+ +-----------+#2
+-------------------------------+
| REMnux (VM or bare metal) |
| |
| +----------------+ |
| | AI Assistant | |
| | (Claude Code, | stdio |
| | OpenCode) +--------+ |
| +----------------+ | |
| v |
| +-------------------------+ |
| | remnux-mcp-server | |
| | --mode=local (default) | |
| | | |
| | - Local connector | |
| | - Security layers | |
| +-------------------------+ |
| |
| REMnux tools (native) |
+-------------------------------++-------------------------------+
| REMnux (VM or bare metal) |
| |
| +----------------+ |
| | AI Assistant | |
| | (Claude Code, | stdio |
| | OpenCode) +--------+ |
| +----------------+ | |
| v |
| +-------------------------+ |
| | remnux-mcp-server | |
| | --mode=local (default) | |
| | | |
| | - Local connector | |
| | - Security layers | |
| +-------------------------+ |
| |
| REMnux tools (native) |
+-------------------------------+#3
+----------------+ Streamable HTTP +------------------------------+
| AI Assistant |----(network)------->| REMnux (VM/Container) |
| (Claude Code, | | |
| Cursor, etc) | | +------------------------+ |
+----------------+ | | remnux-mcp-server | |
| | --mode=local | |
| | --transport=http | |
| | | |
| | - Local connector | |
| | - Security layers | |
| +------------------------+ |
| |
| REMnux tools (native) |
+------------------------------++----------------+ Streamable HTTP +------------------------------+
| AI Assistant |----(network)------->| REMnux (VM/Container) |
| (Claude Code, | | |
| Cursor, etc) | | +------------------------+ |
+----------------+ | | remnux-mcp-server | |
| | --mode=local | |
| | --transport=http | |
| | | |
| | - Local connector | |
| | - Security layers | |
| +------------------------+ |
| |
| REMnux tools (native) |
+------------------------------+Let's start by downloading REMnux MCP from its GitHub Repo. Just ask Codex to download the MCP and let it do its thing.
Another additional MCP we can install is the remnux-docs MCP. It gives additional tooling documentation for your AI, which is always a good thing.
Now that everything is set. let's put it to a test!
3. Verifying the REMnux MCP
I have downloaded the following malware .exe sample and put it under the file/samples/random-malware and will let Codex analyze it
Now that it works. You can ask it to make a lot of cool stuff.
As always, AI is non-deterministic; it just predicts the best next word to put. So always take its findings with a grain(s) of salt. A good practice is to make it write a report about the findings and try to double-check it.
This is it for REMnux; you can stop and call it a day. But….Why stop here? Let's expand the lab environment!
III.Kali Environment
The logic is simple. Run the Kali API on Kali, run its Kali MCP bridge on REMnux, and connect them through an SSH tunnel. Codex can then use both the existing REMnux tools and the Kali tools in the same session.
For that, we need to put both VMs on a shared network by having 2 Network adapters on both machines.
+-----------+---------------------+------------------------+---------------------------+
| Adapter | REMnux | Kali | Purpose |
+-----------+---------------------+------------------------+---------------------------+
| Adapter 1 | NAT | NAT | Internet access |
| Adapter 2 | Host-only Adapter | Same Host-only Adapter | Communication between VMs |
+-----------+---------------------+------------------------+---------------------------++-----------+---------------------+------------------------+---------------------------+
| Adapter | REMnux | Kali | Purpose |
+-----------+---------------------+------------------------+---------------------------+
| Adapter 1 | NAT | NAT | Internet access |
| Adapter 2 | Host-only Adapter | Same Host-only Adapter | Communication between VMs |
+-----------+---------------------+------------------------+---------------------------+1. Setting up Kali MCP
Install SSH & Kali MCP on Kali
sudo apt update
sudo apt install -y git python3-venv openssh-server
git clone https://github.com/Wh0am123/MCP-Kali-Server.git "$HOME/MCP-Kali-Server"
cd "$HOME/MCP-Kali-Server"
python3 -m venv .venv
.venv/bin/pip install -r requirements.txtsudo apt update
sudo apt install -y git python3-venv openssh-server
git clone https://github.com/Wh0am123/MCP-Kali-Server.git "$HOME/MCP-Kali-Server"
cd "$HOME/MCP-Kali-Server"
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
Enable SSH with sudo systemctl enable — now ssh .
Start the MCP API and leave this terminal open:
cd "$HOME/MCP-Kali-Server"
.venv/bin/python server.py --ip 127.0.0.1 --port 5000cd "$HOME/MCP-Kali-Server"
.venv/bin/python server.py --ip 127.0.0.1 --port 5000This keeps the API listening on Kali's loopback interface, with access supplied by the tunnel. These bind and port options are documented by the project.
In another Kali terminal, verify that the MCP is working locally by running curl ``[http://127.0.0.1:5000/health](http://127.0.0.1:5000/health)
2. Open the SSH tunnel from REMnux
Run on REMnux the following, replacing kali and the ip with your Kali username and IP:
ssh -N \
-L 127.0.0.1:5001:127.0.0.1:5000 \
-o ExitOnForwardFailure=yes \
-o ServerAliveInterval=30 \
kali@<ip>ssh -N \
-L 127.0.0.1:5001:127.0.0.1:5000 \
-o ExitOnForwardFailure=yes \
-o ServerAliveInterval=30 \
kali@<ip>The forwarding means:
- REMnux receives connections at
127.0.0.1:5001. - SSH carries them to Kali.
- Kali forwards them to its API at
127.0.0.1:5000.
Enter your Kali password when prompted. Leave this terminal running.
Note: A quiet terminal is normal with
-N.
In a second REMnux terminal, run curl ``[http://127.0.0.1:5001/health](http://127.0.0.1:5001/health)
3. Install the MCP bridge on REMnux
Remember those commands? Yeah, run them again, but this time on the REMnux machine
sudo apt install -y git python3-venv openssh-client
git clone https://github.com/Wh0am123/MCP-Kali-Server.git "$HOME/MCP-Kali-Server"
cd "$HOME/MCP-Kali-Server"
python3 -m venv .venv
.venv/bin/pip install -r requirements.txtsudo apt install -y git python3-venv openssh-client
git clone https://github.com/Wh0am123/MCP-Kali-Server.git "$HOME/MCP-Kali-Server"
cd "$HOME/MCP-Kali-Server"
python3 -m venv .venv
.venv/bin/pip install -r requirements.txtWhat is going on?
Although we cloned the same repository on both machines, their jobs differ. The repo has two scripts
server.pyandclient.py
+-------------+-----------+----------------------------------------------+
| Component | Runs on | Job |
+-------------+-----------+----------------------------------------------+
| server.py | Kali | Executes Kali commands |
| client.py | REMnux | Exposes Kali capabilities to Codex via MCP |
| Codex | REMnux | Chooses and calls tools |
+-------------+-----------+----------------------------------------------++-------------+-----------+----------------------------------------------+
| Component | Runs on | Job |
+-------------+-----------+----------------------------------------------+
| server.py | Kali | Executes Kali commands |
| client.py | REMnux | Exposes Kali capabilities to Codex via MCP |
| Codex | REMnux | Chooses and calls tools |
+-------------+-----------+----------------------------------------------+4. Register the bridge with Codex
Add the following entry to ~/.codex/config.toml. or be lazy like me and ask Codex to do it
[mcp_servers.kali]
command = "/home/remnux/MCP-Kali-Server/.venv/bin/python"
args = [
"/home/remnux/MCP-Kali-Server/client.py",
"--server",
"http://127.0.0.1:5001"
][mcp_servers.kali]
command = "/home/remnux/MCP-Kali-Server/.venv/bin/python"
args = [
"/home/remnux/MCP-Kali-Server/client.py",
"--server",
"http://127.0.0.1:5001"
]
Now everything is ready. Restart Codex and verify execution.
Entering /mcpyou should see the REMnux server and the new kali entry. /mcp shows active servers.
Try this prompt :
Use the Kali MCP tool to run
hostname,whoami, andcat /etc/os-release. Show the results so I can confirm the commands execute on Kali.
Just like we made REMnux analyze some random malware. Let's give Kali a vulnerable site to examine. I told code to scan http://testasp.vulnweb.com/
vulnweb.com a deliberately vulnerable web application built with ASP to test web vulnerability scanners and practice ethical hacking
From here, you can go crazy with your security research workflow! Connect it to a Windows machine for Dynamic analysis, Skills, Tooling & scripts- whatever you want!
III. A Use Case in Action
Let's put it to the test, shall we? I have connected the home lab to Huntress 2026 CTF, which they authroize the use of AI. Do not do that unless you are authorized to; respect CTF participants!
Instead of me talking, I will let Codex tell you his workflow himself.