A C++20 Linux mission-control protocol server exposing a small command/control protocol over TCP, with multi-client handling, token authentication, structured logs, parser tests, a CLI client and a lightweight HTTP monitoring endpoint.
This project is a compact systems/software-engineering exercise inspired by industrial mission-control and command/monitoring software. It combines Linux networking, modern C++ resource management, concurrency, protocol parsing, observability and automated tests while keeping the codebase small enough to study end to end.
- TCP server accepting multiple clients concurrently.
- Line-oriented Mission Control Protocol (
MCPS/1.0). - Commands:
CONNECT,AUTH <token>,GET_STATUS,START_STREAM,STOP_STREAM,SET_MODE SAFE|ACTIVE|MAINTENANCE,PING,HELP,QUIT. - Token authentication before privileged commands.
- Authentication tokens redacted from server logs.
- Per-client telemetry stream mode.
- Thread-safe server state using
std::atomic,std::mutexand RAII wrappers. std::jthreadbased accept, client and monitoring loops with cooperative shutdown.- Bounded command-line input and socket send timeouts to avoid unbounded buffering/blocking.
- Command parser and processor separated from networking for deterministic unit tests.
- CLI client for scripted or interactive sessions.
- HTTP monitor exposing
/statusas JSON and/as a minimal HTML dashboard. - CMake + CTest based tests with no third-party C++ dependency.
The project targets Linux/POSIX networking and requires:
- a C++20 compiler (GCC or Clang);
- CMake 3.16 or newer;
- POSIX threads;
- Bash for
scripts/demo.sh; curlonly for the optional HTTP check in the demo.
On Debian/Ubuntu, a typical development environment is:
sudo apt update
sudo apt install build-essential cmake curlRun these commands from the repository root:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DMCPS_BUILD_TESTS=ON
cmake --build build --parallel
ctest --test-dir build --output-on-failureFor strict compilation with warnings treated as errors:
cmake -S . -B build-werror -DCMAKE_BUILD_TYPE=Release -DMCPS_BUILD_TESTS=ON -DMCPS_WARNINGS_AS_ERRORS=ON
cmake --build build-werror --parallel
ctest --test-dir build-werror --output-on-failure./build/mcps_server \
--host 0.0.0.0 \
--port 5555 \
--token mission-secret \
--monitor-port 8080 \
--log-file mcps.logThe server stops on SIGINT (Ctrl+C) or SIGTERM. Use --no-monitor if the HTTP endpoint is not required.
The client sends CONNECT and AUTH automatically unless --no-auto-auth is supplied.
Send one command:
./build/mcps_client --host 127.0.0.1 --port 5555 --token mission-secret --command GET_STATUSSet the mission mode:
./build/mcps_client --host 127.0.0.1 --port 5555 --token mission-secret --command "SET_MODE ACTIVE"Receive telemetry events for three seconds:
./build/mcps_client --host 127.0.0.1 --port 5555 --token mission-secret --stream-seconds 3Start an interactive session:
./build/mcps_client --host 127.0.0.1 --port 5555 --token mission-secretThe demo configures and builds the project, starts a local server, exercises status/mode/stream commands and queries the HTTP monitor when curl is available:
bash scripts/demo.shBy default the script starts searching from ports 5555 and 8080 and automatically chooses the next free local ports if either one is already occupied. Ports and token can also be forced explicitly:
MCPS_PORT=15555 MCPS_MONITOR_PORT=18080 MCPS_TOKEN=demo-secret bash scripts/demo.shWith the server running on monitor port 8080:
curl --fail --silent --show-error http://127.0.0.1:8080/
curl --fail --silent --show-error http://127.0.0.1:8080/statusExample /status response:
{
"mode": "SAFE",
"any_stream_active": false,
"connected_clients": 1,
"authenticated_clients": 1,
"active_streams": 0,
"commands": 3,
"protocol_errors": 0,
"auth_failures": 0,
"telemetry_events": 0,
"uptime_ms": 1024
}The actual counters naturally depend on the clients connected when the request is made.
The executables expose their complete supported options:
./build/mcps_server --help
./build/mcps_client --helpImportant server options include --no-monitor, --stream-period-ms <positive-ms> and --debug.
include/mcps/ Public C++ headers
src/ Core implementation and server implementation
apps/ mcps_server and mcps_client executables
tests/ Unit tests driven by CTest
docs/ Protocol, security, architecture and test documentation
scripts/demo.sh End-to-end build/run smoke test
examples/ Example MCPS command session
This is a simulator/portfolio project, not a production command-and-control service. It deliberately uses a static bearer token and an unauthenticated HTTP monitoring endpoint. The token is redacted from logs and protocol input is bounded, but the project does not provide TLS, user identities, role-based authorization, token rotation or rate limiting.
Do not expose it directly to an untrusted network. See docs/SECURITY.md for the exact security assumptions and limitations.
