Network automation lab 20 of 27
AI in network automation: an MCP tool server and reviewing AI-generated code
Build a read-only MCP server that gives an AI agent live interface, routing and configuration data from two routers, make it safe (allow-listed commands, secret redaction, untrusted device text), then catch the mistakes in an AI assistant's Netmiko script before they reach the network.
Run this lab
It needs Lite: its 3 nodes are set to 3 vCPU and 2,048 MB in total. That fits the free demo too.
In your workspace: Shared, then Network Automation - CCNA and CCNP Automation guided labs, then 20 - AI in network automation - an MCP tool server and reviewing AI-generated code
- Level
- Advanced
- Time
- About 90 minutes
- Nodes need
- 3 vCPU, 2,048 MB
- Smallest plan
- Lite
The scenario
Kestrel Freight's NOC wants to let an AI assistant answer questions such as "is r1's link to r2 up?" or "what does r2's routing table look like?" without giving it the keys to the network. The standard way to plug tools into AI assistants is the Model Context Protocol (MCP). You'll build the team's MCP server, netinfo: read-only tools backed by Netmiko and ntc-templates, with the guard rails a security review will ask for. Then you'll do the other half of the job: review a script an AI coding assistant wrote for r1, find what's wrong with it, and fix it properly.
| Device | Address | State at start |
|---|---|---|
| devbox | 10.10.20.10 | ~/lab: netinfo_mcp.py (server starter), mcp_client.py (test client), inventory.yaml, ai_suggestion.py |
| r1 | 10.10.20.11 | Gi0/1 10.1.12.1/30, Lo0 10.255.0.1; no routing yet |
| r2 | 10.10.20.12 | Gi0/1 10.1.12.2/30, Lo0 10.255.0.2; OSPF area 0 ready; one interface description is hostile |
What you’ll practise
- Explain how an AI host, an MCP client and an MCP server work together, and what tools, resources and prompts are
- Implement the MCP handshake and the tools/list and tools/call methods over JSON-RPC 2.0 on stdio
- Expose network data as tools with JSON schemas and structured results
- Defend an AI-facing tool against excessive agency, data leakage and indirect prompt injection
- Evaluate AI-generated network code, find its errors and fix it with verification
The tasks
- Understand the architecture
- Implement the handshake and the two tool methods
- Call the tools
- Stop excessive agency: allow-list the commands
- Stop data leakage: redact secrets
- Recognise indirect prompt injection
- Review the AI assistant's script before running it
- Compare with FastMCP
The Lab Tasks pane has the scenario, these tasks, the checks to run, hints and the full solution.
Topology and devices
The network as it opens in EVE-NG, drawn from the lab’s own canvas, and the image each node runs.
Every link, as text
- devbox
eth0to Mgmt (network) - r1
Gi0/0to Mgmt (network) - r2
Gi0/0to Mgmt (network) - r1
Gi0/1to r2Gi0/1
| Node | Device | Image in Add Node | Set to |
|---|---|---|---|
| devbox | EVE-NG GUI server (Docker) | eve-gui-server:latest | 1 vCPU, 1,024 MB |
| r1 | Cisco IOSv | vios-adventerprisek9-m.spa.159-3.m9 | 1 vCPU, 512 MB |
| r2 | Cisco IOSv | vios-adventerprisek9-m.spa.159-3.m9 | 1 vCPU, 512 MB |
How to open this lab
Sign in to your workspace at
lab.cloudlabbox.com.In File Manager, open Shared, then the folder
Network Automation - CCNA and CCNP Automation guided labs.Open
20 - AI in network automation - an MCP tool server and reviewing AI-generated codeand start its nodes, then open Lab Tasks for the scenario and the steps.
The lab is read-only. You can start the nodes and configure the devices, but changes to the topology can’t be saved. To change it, rebuild it in your own folder.
More Network automation labs
Related labs in other courses
CloudLabBox is independent of Cisco. The lab follows exam topics and isn’t vendor training material; vendor names identify the exams and the images in the workspace.