A standalone AI Network Assistant that leverages Google Gemini 2.0 and the Model Context Protocol (MCP) to interact with network infrastructure using Cisco pyATS.
This agent allows you to use natural language to inspect, troubleshoot, and manage network devices via a specialized pyATS MCP server. It transforms complex network data into actionable insights through a conversational interface.
- Python 3.10+
- A Google AI Studio API Key (Get it here)
- A pyATS Testbed file (e.g.,
testbed.yaml) containing your device credentials and IP addresses.
Clone the repository and set up a virtual environment to manage dependencies:
# Clone the repo
git clone [https://github.com/your-username/your-repo-name.git](https://github.com/your-username/your-repo-name.git)
cd your-repo-name
# Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install all dependencies
pip install -r requirements.txtThe agent requires two main configuration points to function:
-
API Key: Create a
.envfile in the root directory and add your Google API key:GOOGLE_API_KEY=your_gemini_api_key_here
-
Testbed Path: Export the path to your pyATS testbed file in your current terminal session:
# Linux / macOS export TESTBED_PATH="/absolute/path/to/your/testbed.yaml" # Windows (PowerShell) $env:TESTBED_PATH="C:\path\to\testbed.yaml"
Start the interactive session:
python agent.pyThe agent acts as an intelligent bridge between the LLM (Gemini) and your physical or virtual network infrastructure.
- User Query: You ask, "Is OSPF running on the core-router?"
- Gemini 2.0: Processes the intent and identifies the correct pyATS tool to use.
- MCP Client: Sends the execution request to the local pyATS MCP Server via STDIO.
- pyATS/Genie: Connects to the device, runs the
show ip ospfcommand, parses the raw text into a structured JSON object, and returns it. - Gemini 2.0: Analyzes the structured data and provides a concise, human-friendly answer.
You can interact with your network using natural language:
- Health Checks: "Perform a health check on all devices and tell me if any interfaces are down."
- Routing: "Show me the routing table for leaf-01 and highlight any BGP routes."
- Connectivity: "Ping 8.8.8.8 from the border-gateway and verify internet reachability."
- Details: "What version of software is running on the distribution switches?"
- Environment Variables: Never commit your
.envfile or yourtestbed.yamlto GitHub. They contain sensitive API keys and network credentials. - Access Control: It is recommended to use a pyATS user with read-only privileges for general troubleshooting to ensure the agent cannot accidentally modify configurations.
- Logs: Monitor the terminal output to see exactly which commands the agent is choosing to run on your equipment.
To ensure the agent runs correctly, the following packages are required in your requirements.txt file:
google-genai
mcp
pydantic
python-dotenv
pyats[full]
asyncio