Skip to content

🚀 MCP Server for SEED Internet Emulator#449

Closed
zzw4257 wants to merge 161 commits intoseed-labs:masterfrom
zzw4257:feat/mcp-server
Closed

🚀 MCP Server for SEED Internet Emulator#449
zzw4257 wants to merge 161 commits intoseed-labs:masterfrom
zzw4257:feat/mcp-server

Conversation

@zzw4257
Copy link
Collaborator

@zzw4257 zzw4257 commented Feb 1, 2026

🚀 MCP Server for SEED Internet Emulator

Summary: This PR introduces a complete Model Context Protocol (MCP) Server, turning the SEED Internet Emulator into an interactive environment for LLM agents.

Status Tools Count Primary Runtime Category
🟢 Ready for Review 53 Tools Python 3.10+ Infrastructure / Security

📋 Overview

The MCP Server acts as a bridge between LLM-based agents (like seed-agent) and the SEED Emulator. It enables agents to:

  • Build: Define AS, Routers, and Networks via natural language.
  • Operate: Configure OSPF/BGP and manage container lifecycles.
  • Simulate: Inject faults and execute complex BGP hijack or DoS attack scenarios.

🏗️ Architecture

I use a Layered Hybrid Architecture to ensure both high-performance static tool access and flexible dynamic operation discovery.

graph TD A[LLM Agent / Client] -- "MCP Protocol (stdio)" --> B[MCP Server] subgraph "MCP Server Layer" B --> B1[Infrastructure Tools] B --> B2[Routing & Peering] B --> B3[Dynamic Ops Tools] B --> R[EmulatorRuntime Singleton] end R -- "Python API" --> C[SEED Emulator Core] C -- "Docker API" --> D[Network Nodes / Services] 
Loading

🛠️ Tool Inventory (Highlight)

I've implemented 53 tools categorized by their lifecycle stage.

🔹 1. Infrastructure (Static & High-Frequency)

Tool Description Key Arguments
create_as Create Autonomous System asn: int
create_router Create BGP/OSPF router asn, name
create_network Create internal network asn, name, prefix
connect_to_ix Connect router to IX asn, router_name, ix_id

🔹 2. Routing & Compilation

Tool Description Key Arguments
configure_ospf Configure OSPF on AS asn
set_as_relationship Define Provider/Peer/Customer asn1, asn2, rel
render_simulation Render topology to internal state -
start_simulation Start Docker containers -

🔹 3. Dynamic Operations (Runtime Discovery)

Tool Description Key Arguments
exec_command Execute shell in container container, command
inject_fault Inject network faults (delay/loss) container, fault_type
start_attack Launch BGP Hijack / DoS scenario, target
capture_traffic Tcpdump on specific interface container, interface

📐 Key Design Decisions

Important

Stateful Singleton Runtime: The EmulatorRuntime (in runtime.py) manages the emulator state (designing → rendered → running). This ensures that an LLM can perform multi-turn operations (e.g., "Add a router" then "Start it") without losing context.

  • Idempotency: All tools are safe to retry. Calling create_as(100) twice returns the existing object instead of an error.
  • Error Tolerance: Tools catch internal exceptions and return "Agent-friendly" error messages, preventing the entire LLM chain from crashing.
  • Discovery: Ops tools are registered dynamically, allowing the server to expose new security tools without updating the core client logic.

📂 Reviewer's Guide

Importance File Purpose
⭐⭐⭐ mcp-server/server.py Entry Point: All tool definitions and MCP registration.
⭐⭐⭐ mcp-server/runtime.py Core State: Singleton logic for emulator lifecycle.
⭐⭐ mcp-server/verify_operations.py Integration test showing an agent performing an attack.
mcp-server/tests/ Unit tests for tool logic.

🧪 Verification Plan

1. Automated Tests

cd mcp-server && pytest tests/

2. Manual Integration Demo

Verify tool discovery and execution:

# Verify dynamic tool discovery and basic topology build python3 mcp-server/verify_operations.py

🔮 Future Roadmap

  • RPKI Support: Tools for prefix origin validation.
  • Traffic Gen: Integration with iperf3 and hping3 tools.
  • Visualizer: Real-time web-based topology viewer.

Reviewers: | Labels: feature, mcp, emulator
Ready for Review. 🚀


…to : BruceJqs ) I rebased so I had to do this commit again by myself
update: add new features of Y03-Mirai example
…m2025_2 updated example to add any number of eth nodes
PR for rearranging files in BGP_Hijacking_Attack
update: add VM support to Y03_mirai and modify the file structure
kevin-w-du and others added 29 commits January 19, 2026 08:21
fix: Demosystem 02_morris_worm conf
fix: home bashboard && docker compose
Sprint 1 (Email Service): - Add install_email_service tool for deploying mail servers - Add list_email_providers tool - Integrate EmailService with compile_simulation - Add LLM integration test (verify_email_service.py) Docker/Dynamic Tools (Phase 1 completion): - Add docker-compose v1/v2 compatibility - Add unit tests for Docker and Dynamic tools - Add E2E Docker workflow verification Tests: 28 unit tests passing
Sprint 2: - Add configure_link_properties for latency/bandwidth/packet loss - Add add_static_route for static routing configuration - Add get_node_interfaces for interface inspection - Add 6 unit tests for network config tools Note: Interface configuration works after render() due to SEED's lazy interface creation model. Tests: 34 unit tests passing
Sprint 3: - Add export_topology for JSON, Mermaid, Graphviz formats - Add export_python_script for reproducing topology - Add get_topology_summary for human-readable summary - Add get_code_log to runtime - Add 7 unit tests and LLM integration test
Sprint 4: - Add traceroute tool - Add capture_traffic tool (tcpdump wrapper with timeout) - Add get_interface_stats tool - Update test_dynamic_tools.py with new tests Phase 2 Complete!
Phase 3: - Add bgp_announce_prefix tool for injecting routes - Add get_looking_glass tool for route inspection - Add unit tests (3 new tests) - Add verify_bgp_hijack.py demo script
- Add 20+ dynamic tools for Ops phase (attack, forensics, diagnostics) - Network: capture_traffic, inject_fault (packet_loss, latency) - Security: bgp_announce_prefix, start_attack_scenario - System: exec_command, capture_evidence - Enhance runtime to support dynamic container discovery - Implement hybrid tool loading architecture
- Add verify_operations.py for dynamic tool testing - Add verify_agent_robustness.py for self-correction testing - Add demo_bgp_hijack_lab.py for reference topology - Add unit tests for dynamic operations
@zzw4257 zzw4257 closed this Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

8 participants