ARD92/s2-simulator-mcp-server
If you are the rightful owner of s2-simulator-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The S2 Simulator MCP Server is designed to manage and control network observability simulations, providing both steady-state and anomaly-injection modes.
S2 Simulator MCP Server
Overview
This project implements an MCP (Multi-Cloud Platform) server designed to interact with and control the S2 Observability Simulator. It allows users to generate network observability metrics in either a steady-state (baseline) mode or an anomaly-injection mode, simulating various network issues. Ensure you have all necessary files before you run this.
This was an experiment to learn about MCP and hence its not clean enough to call the APIs directly and instead relies on invoking another tool on the background. But it does its job :) as a result one neeeds to have the files prepared before hand
Features
- Steady-State Simulation: Generate baseline network observability metrics.
- Anomaly Injection: Simulate various network issues like CPU spikes, memory spikes, link downs, BGP flaps, and more.
- Flexible Input: Accept intent through structured JSON payloads or free-form command strings.
- Background Processing: Run simulations as background processes, allowing for non-blocking operations.
- Session Management: Stop and monitor running simulation sessions.
Installation
-
Clone the repository (if you haven't already). and https://github.com/ARD92/s2-observability-simulator.git which is the simulator tool.
-
Install dependencies: The server relies on
mcpandpython-dotenv.pip install -r requirements.txt -
Ensure
generate_all_stats.pyis available: This server expects thegenerate_all_stats.pyscript to be located in the directory specified bySCRIPT_DIR(default:/root/s2-observability-simulator/). You may need to adjust theSCRIPT_DIRandPYTHON_BINenvironment variables if your setup differs. Clone https://github.com/ARD92/s2-observability-simulator.git to obtain the tool
Usage
MCP server config
{
"mcpServers": {
"simulator": {
"command": "npx",
"args": [
"mcp-remote",
"http://192.168.1.10:8050/mcp/",
"--allow-http"
]
}
}
}
The MCP server exposes the following tools:
simulator_intent: To start a new simulation.simulator_stop_run: To stop a running background simulation.simulator_status: To list all tracked simulation processes and their statuses.
Starting the MCP Server
To start the MCP server, run main.py:
python main.py
Running Simulations
Simulations can be initiated using the simulator_intent tool. You can provide a structured JSON payload or freeform text and allow the llm to interpret.
Steady-State Mode
To generate steady-state metrics with a topology file and optional assurance/BGP files:
{
"mode": "steady",
"topology": "topology.csv",
"assurance": "assurance.csv",
"bgp": "bgp.csv",
"tunnel": "tunnel.csv"
}
Anomaly Mode
To inject anomalies, set the mode to "anomaly" and provide the anomaly payload:
{
"mode": "anomaly",
"topology": "topology.csv",
"assurance": "assurance.csv",
"bgp": "bgp.csv",
"anomaly": {"cpuspike": ["nylf01"], "memspike": ["nyag01"], "linkdown": ["nylf01_et-0/0/0"]}
}
use simulator tool with topology=mcp-topology.csv, bgp = mcp-bgp_config.csv, mode=anomaly, anamoly cpuspike for CASPJNP01, memspike for device CASPJNP02, linkdown on CALFJNP02 interface et-0/0/0
If you want to modify existing , use the following prompt
> kill the above session and reinitiate the same with interface et-0/0/4 instead of et-0/0/0
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ simulator_stop_run (simulator MCP Server) {"payload":{"proc_id":"5db1c996-3d88-48b8-a047-85b2e01c39cb"},"ctx":""} │
│ │
│ { │
│ "status": "stopped", │
│ "proc_id": "5db1c996-3d88-48b8-a047-85b2e01c39cb", │
│ "stopped": true, │
│ "signal": "SIGTERM" │
│ } │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ simulator_intent (simulator MCP Server) {"ctx":"","payload":{"topology":"mcp-topology.csv","mode":"anomaly","bgp":"mcp-bgp_config.csv","anoma… │
│ │
│ { │
│ "status": "spawned", │
│ "proc_id": "df5ee7b1-cf7a-4e2b-929d-09a3e66b84ed", │
│ "pid": 1389897 │
│ } │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The previous simulator session has been stopped. I have re-initiated the simulator with the same anomalies, but with the linkdown on CALFJNP02
interface et-0/0/4.
Anomaly Types
The following anomaly types are supported in the anomaly payload:
| Key | Description / Example Usage |
|---|---|
trafficprofile | Modify traffic on a given interface. Example: \'trafficprofile\': [\'nylf01_et-0/0/0_50-2-2\'] |
linkdown | Mark one or more links down. Example: \'linkdown\': [\'nylf01_et-0/0/0\'] |
nodedown | Mark one or more nodes down. Example: \'nodedown\': [\'nylf01\', \'nyag01\'] |
intflap | Enable interface flapping. Example: \'intflap\': [\'nylf01_et-0/0/0\'] |
intindisc | Introduce interface input discards or errors. Example: \'intindisc\': [\'nylf01_et-0/0/0\'] |
cpuspike | Simulate CPU utilization spike on given nodes. Example: \'cpuspike\': [\'nylf01\'] |
memspike | Simulate memory spike on given nodes. Example: \'memspike\': [\'nylf01\'] |
assurance | Inject anomalies into assurance metrics. Example: \'assurance\': [\'nylf01\'] |
bgpflap | Simulate BGP session flap events. Example: \'bgpflap\': [\'nylf01\'] |
tundown | Mark a tunnel as down. Example: \'tundown\': [\'tun01\'] |
tunflap | Simulate tunnel flapping. Example: \'tunflap\': [\'tun01\'] |
intoutdisc | Introduce interface output discards. Example: \'intoutdisc\': [\'nylf01_et-0/0/0\'] |
intinerr | Introduce interface input errors. Example: \'intinerr\': [\'nylf01_et-0/0/0\'] |
intouterr | Introduce interface output errors. Example: \'intouterr\': [\'nylf01_et-0/0/0\'] |
ospfflap | Introduce interface output errors. Example: \'intouterr\': [\'nylf01_et-0/0/0\'] |
ospfdown | Introduce interface output errors. Example: \'intouterr\': [\'nylf01_et-0/0/0\'] |
Managing Sessions
Stopping a Session
To stop a running session, use simulator_stop_run with the proc_id obtained when spawning the command:
{
"proc_id": "YOUR_PROCESS_ID"
}
or
>> > kill all sessions
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ simulator_stop_run (simulator MCP Server) {"payload":{"proc_id":"38018225-c96b-495a-8f90-cc1bc524c5b6"},"ctx":""} │
│ │
│ { │
│ "status": "stopped", │
│ "proc_id": "38018225-c96b-495a-8f90-cc1bc524c5b6", │
│ "stopped": true, │
│ "signal": "SIGTERM" │
│ } │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ All active simulator sessions have been stopped.
Viewing Session Status
To see all active and finished simulator sessions:
{}
(empty payload for simulator_status) or use
>> show all sessions
Here are all the simulator sessions:
* Session ID: 5db1c996-3d88-48b8-a047-85b2e01c39cb (Finished)
* Command: generate_all_stats.py -t mcp-topology.csv -a anomaly -b mcp-bgp_config.csv -av {"memspike": ["CASPJNP02"], "cpuspike": ["CASPJNP01"],
"linkdown": ["CALFJNP02_et-0/0/0"]}
* Session ID: df5ee7b1-cf7a-4e2b-929d-09a3e66b84ed (Finished)
* Command: generate_all_stats.py -t mcp-topology.csv -a anomaly -b mcp-bgp_config.csv -av {"cpuspike": ["CASPJNP01"], "linkdown":
["CALFJNP02_et-0/0/4"], "memspike": ["CASPJNP02"]}
* Session ID: 38018225-c96b-495a-8f90-cc1bc524c5b6 (Running)
* Command: generate_all_stats.py -t mcp-topology.csv -a anomaly -b mcp-bgp_config.csv -av {"cpuspike": ["CASPJNP01"], "linkdown":
["CALFJNP02_et-0/0/1"], "memspike": ["CASPJNP02"]}
Replay logs
> use simulator with mode replay , file logs.csv and topology backbone_topology.csv
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ x simulator_intent (simulator MCP Server) {"ctx":"simulator","payload":{"logfile":"logs.csv","topology":"backbone_topology.csv","mode":"replay"}} │
│ │
│ MCP tool 'simulator_intent' reported tool error for function call: │
│ {"name":"simulator_intent","args":{"ctx":"simulator","payload":{"logfile":"logs.csv","topology":"backbone_topology.csv","mode":"replay"}}} with response: │
│ [{"functionResponse":{"name":"simulator_intent","response":{"error":{"content":[{"type":"text","text":"Error executing tool simulator_intent: replay_file is required for replay │
│ mode"}],"isError":true}}}}] │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ I apologize for the error. It seems the correct parameter for the log file in replay mode is replay_file. I will restart the simulator with the correct parameter.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ simulator_intent (simulator MCP Server) {"ctx":"simulator","payload":{"topology":"backbone_topology.csv","replay_file":"logs.csv","mode":"replay"}} │
│ │
│ { │
│ "status": "done", │
│ "cmd": [ │
│ "/root/mcp-sim/.venv/bin/python3", │
│ "generate_all_stats.py", │
│ "-t", │
│ "backbone_topology.csv", │
│ "-a", │
│ "replay", │
│ "-f", │
│ "logs.csv" │
│ ], │
│ "returncode": 0, │
│ "stdout": "file is logs. sending to logminer\n", │
│ "stderr": "" │
│ } │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The simulator has successfully completed the replay mode operation using logs.csv and backbone_topology.csv.