Content
# ENSP-MCP AI
MCP Server-based auxiliary tool for Huawei eNSP, providing device management, CLI execution, configuration issuance, and topology visualization.
## Overview
- **MCP Server**: Offers device management, CLI execution, configuration issuance, configuration saving, running configuration viewing, network diagnosis, and health check tools for MCP-enabled AI clients.
- **Topo Viewer**: Local browser page supporting `.topo`, `.xml`, `.json` topology file uploads and saving device and link information as `topology.json`.
- **Topology Context**: AI prioritizes reading the currently uploaded topology to avoid blindly searching for old topology files in the local file system.
- **Runtime Log**: Web UI displays tool invocation summaries, exceptions, device connections, command sending, and terminal echo.
- **Prompt Layer**: Provides `ensp_ops_playbook` and `ensp_senior_network_engineer` MCP Prompts.
## Operating Environment
- Windows system.
- Huawei eNSP installed and launched.
- Python 3.10 or higher.
- MCP-enabled AI clients, such as Claude Desktop, Codex App, Cursor, Trae, etc.
> eNSP itself relies on the Windows environment, and this project is also designed for Windows local usage scenarios.
## Installation
It is recommended to use uv to create an independent virtual environment to avoid polluting the system Python environment.
### Method 1: Using uv to create a virtual environment
```powershell
cd E:\path\to\ENSP-MCP-ai
uv venv .venv
.\.venv\Scripts\Activate.ps1
uv pip install -r requirements.txt
```
### Method 2: Using pip to create a system environment
```powershell
cd E:\path\to\ENSP-MCP-ai
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
```
## MCP Client Configuration
### Claude Desktop
Edit `%APPDATA%\Claude\claude_desktop_config.json`:
```json
{
"mcpServers": {
"ensp-MCP": {
"command": "E:\\path\\to\\ENSP-MCP-ai\\.venv\\Scripts\\python.exe",
"args": ["-m", "ensp_mcp_server.server"],
"cwd": "E:\\path\\to\\ENSP-MCP-ai"
}
}
}
```
### Codex App
Codex App uses Codex's `config.toml` to configure MCP Server. You can open the configuration file through Settings → Configuration in Codex App or directly edit `~/.codex/config.toml`.
```toml
[mcp_servers.ensp-MCP]
command = "E:\\path\\to\\ENSP-MCP-ai\\.venv\\Scripts\\python.exe"
args = ["-m", "ensp_mcp_server.server"]
cwd = "E:\\path\\to\\ENSP-MCP-ai"
```
### Cursor / Trae
Use the same startup parameters in MCP Server configuration:
```json
{
"command": "E:\\path\\to\\ENSP-MCP-ai\\.venv\\Scripts\\python.exe",
"args": ["-m", "ensp_mcp_server.server"],
"cwd": "E:\\path\\to\\ENSP-MCP-ai"
}
```
## Startup Method
The client will automatically start the MCP Server through the Python module:
```powershell
cd E:\path\to\ENSP-MCP-ai
.\.venv\Scripts\python.exe -m ensp_mcp_server.server
```
After the service is started, the Web UI address is:
```txt
http://127.0.0.1:18080/index.html
```
## Usage Process
1. Open the topology (topo) in eNSP and launch the device.
2. Configure and connect to the MCP Server in the AI client.
3. Open Web UI: `http://127.0.0.1:18080/index.html`.
4. Upload `.topo`, `.xml`, or `.json` topology files.
5. Web UI saves `topology.json` and synchronizes the topology device to the MCP registry.
6. Use natural language to perform viewing, configuration, troubleshooting, and verification tasks in the AI client.
Example:
```text
Help me view R1's routing table
Check if devices can connect based on the current topology
Configure OSPF for R1 and R2, and verify neighbor status after configuration
Check if device configurations match link relationships in the current topology
```
## Prompt and Agent Configuration
The project has built-in MCP Prompts: `ensp_ops_playbook` and `ensp_senior_network_engineer`. If the client supports MCP Prompts, you can directly enable it in the client.
For software like Trae that supports custom Agent/role prompts, you can use the content of [prompts.md](prompts.md) as the built-in Agent prompt to constrain AI to work like a network engineer: confirm topology and goals, configure step-by-step, and verify results.
## Project Structure
```text
eNSP-MCP-ai/
├── README.md
├── requirements.txt
├── index.html
├── topo-viewer.css
├── topo-viewer.js
├── prompts.md
└── ensp_mcp_server/
├── __init__.py
├── server.py
├── web_ui.py
├── runtime.py
├── topology_context.py
├── prompts.py
├── config.py
├── console.py
├── exceptions.py
└── tools/
├── __init__.py
├── cli.py
└── topology.py
```
## License
This project follows the MIT License and is developed based on Redmig110's original open-source project [eNSP-AI](https://github.com/Redmig110/eNSP-AI). The original project provided MCP Server and eNSP device operation basics, and this project expanded on it with built-in Web UI, topology context, runtime log, Prompt layer, and status handling logic.