MCP for Windows systems to execute instructions with administrator privileges.
适用于Windows系统的以管理员权限执行指令的 MCP。
┌─────────────────────────────────────────────────────────┐
│ AI Assistant (Claude / any MCP host) │
│ ↓ MCP stdio │
│ Python MCP Server (client/mcp/main.py) │
│ ↓ TCP JSON (localhost:12380) │
│ C++ Windows Service (service/) │
│ • Runs as LocalSystem (administrator) │
│ • Optional Telegram approval gate │
│ • Executes cmd.exe /c <command> │
│ • Returns stdout / stderr / exit code │
└─────────────────────────────────────────────────────────┘
Optional alternative client:
Python OpenClaw Skill (client/openclaw/skill.py)
↓ same TCP JSON protocol
C++ Windows Service
| Component | Language / Tech | Location |
|---|---|---|
| Windows service | C++20, CMake, vcpkg | service/ |
| MCP server (AI client) | Python 3.12, mcp |
client/mcp/ |
| OpenClaw skill | Python 3.12 | client/openclaw/ |
All messages between the Python clients and the C++ service are framed as:
[4-byte big-endian length][UTF-8 JSON body]
Request (client → service):
{
"id": "uuid4",
"command": "ipconfig /all",
"working_dir": "",
"timeout_seconds": 60
}Response (service → client):
{
"id": "uuid4",
"success": true,
"stdout_output": "...",
"stderr_output": "",
"exit_code": 0,
"error_message": ""
}Requirements: Visual Studio 2022, CMake ≥ 3.25, vcpkg.
cd service
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake
cmake --build build --config Releasecd service
copy build\Release\AdminExecMCP.exe .
copy config.example.json config.json
REM Edit config.json if you want Telegram approval
install.batNote:
install.batmust be run as Administrator.
The service registers itself asAdminExecMCPand starts automatically on boot.
pip install -r client/mcp/requirements.txtAdd to your Claude Desktop / MCP host config (claude_desktop_config.json):
{
"mcpServers": {
"windows-admin-exec": {
"command": "python",
"args": ["C:/path/to/client/mcp/main.py"]
}
}
}Edit config.json next to AdminExecMCP.exe:
{
"approval": {
"enabled": true,
"type": "telegram",
"telegram": {
"bot_token": "123456:ABC-DEF...",
"chat_id": "987654321",
"timeout_seconds": 300
}
}
}Restart the service after editing:
net stop AdminExecMCP && net start AdminExecMCPWhen the AI calls execute_command, the service will send a Telegram message like:
🔐 AdminExecMCP — Approval Required
Command:
ipconfig /all
Reply:
/approve_<uuid> — to approve
/deny_<uuid> — to deny
import importlib.util
spec = importlib.util.spec_from_file_location("skill", r"C:\path\to\client\openclaw\skill.py")
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
for skill in module.SKILLS:
agent.register_skill(skill)| Action | Command (run as Admin) |
|---|---|
| Install & start | AdminExecMCP.exe install |
| Remove | AdminExecMCP.exe uninstall |
| Debug (console) | AdminExecMCP.exe console |
- The service binds only to
127.0.0.1(localhost) by default; it is not accessible from the network. - Enable Telegram approval (
approval.enabled = true) to require explicit human sign-off for every command the AI attempts to run. - The service runs as
LocalSystem. Commands it executes inherit this token and have full administrator access to the local machine. - Restrict who can connect to the MCP server in your AI host configuration.
pip install pytest mcp
pytest tests/| Layer | Technology |
|---|---|
| C++ service | C++20, CMake 3.25+, VS 2022, vcpkg |
| C++ dependencies | nlohmann/json, libcurl |
| Python clients | Python 3.12, mcp |
| Telegram integration | Telegram Bot API via libcurl (C++) |