https://github.com/automateyournetwork/pyATS_MCP
An MCP Server for pyATS (experimental)
https://github.com/automateyournetwork/pyATS_MCP
Last synced: 3 days ago
JSON representation
An MCP Server for pyATS (experimental)
- Host: GitHub
- URL: https://github.com/automateyournetwork/pyATS_MCP
- Owner: automateyournetwork
- Created: 2025-04-04T16:49:01.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2025-04-05T12:13:33.000Z (about 1 month ago)
- Last Synced: 2025-04-05T13:19:04.064Z (about 1 month ago)
- Language: Python
- Size: 10.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-devops-mcp-servers - automateyournetwork/pyATS_MCP - Cisco pyATS server enabling structured, model-driven interaction with network devices. (Cloud Infrastructure / π₯οΈ Command Line)
- awesome-devops-mcp-servers - automateyournetwork/pyATS_MCP - Cisco pyATS server enabling structured, model-driven interaction with network devices. (Cloud Infrastructure / π₯οΈ Command Line)
README
# pyATS MCP Server
This project implements a Model Context Protocol (MCP) Server that wraps Cisco pyATS and Genie functionality. It enables structured, model-driven interaction with network devices over STDIO using the JSON-RPC 2.0 protocol.
π¨ This server does not use HTTP or SSE. All communication is done via STDIN/STDOUT (standard input/output), making it ideal for secure, embedded, containerized, or LangGraph-based tool integrations.
π§ What It Does
Connects to Cisco IOS/NX-OS devices defined in a pyATS testbed
Supports safe execution of validated CLI commands (show, ping)
Allows controlled configuration changes
Returns structured (parsed) or raw output
Exposes a set of well-defined tools via tools/discover and tools/call
Operates entirely via STDIO for minimal surface area and maximum portability
π Usage
1. Set your testbed path
```bash
export PYATS_TESTBED_PATH=/absolute/path/to/testbed.yaml
```
2. Run the server
Continuous STDIO Mode (default)
```bash
python3 pyats_mcp_server.py
```
Launches a long-running process that reads JSON-RPC requests from stdin and writes responses to stdout.
One-Shot Mode
``` bash
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/discover"}' | python3 pyats_mcp_server.py --oneshot
```
Processes a single JSON-RPC request and exits.π¦ Docker Support
Build the container
```bash
docker build -t pyats-mcp-server .
```
Run the container (STDIO Mode)
```bash
docker run -i --rm \
-e PYATS_TESTBED_PATH=/app/testbed.yaml \
-v /your/testbed/folder:/app \
pyats-mcp-server
```π§ Available MCP Tools
Tool Description
run_show_command Executes show commands safely with optional parsing
run_ping_command Executes ping tests and returns parsed or raw results
apply_configuration Applies safe configuration commands (multi-line supported)
learn_config Fetches running config (show run brief)
learn_logging Fetches system logs (show logging last 250)
All inputs are validated using Pydantic schemas for safety and consistency.
π€ LangGraph Integration
Add the MCP server as a tool node in your LangGraph pipeline like so:
```python
("pyats-mcp", ["python3", "pyats_mcp_server.py", "--oneshot"], "tools/discover", "tools/call")
```
Name: pyats-mcp
Command: python3 pyats_mcp_server.py --oneshot
Discover Method: tools/discover
Call Method: tools/call
STDIO-based communication ensures tight integration with LangGraphβs tool invocation model without opening HTTP ports or exposing REST endpoints.
π Example Requests
Discover Tools
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/discover"
}```
Run Show Command
``` json
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "run_show_command",
"arguments": {
"device_name": "router1",
"command": "show ip interface brief"
}
}
}
```
π Security FeaturesInput validation using Pydantic
Blocks unsafe commands like erase, reload, write
Prevents pipe/redirect abuse (e.g., | include, >, copy, etc.)
Gracefully handles parsing fallbacks and errors
π Project Structure
```graphql
.
βββ pyats_mcp_server.py # MCP server with JSON-RPC and pyATS integration
βββ Dockerfile # Docker container definition
βββ testbed.yaml # pyATS testbed (user-provided)
βββ README.md # This file```
π₯ MCP Server Config Example (pyATS MCP via Docker)
To run the pyATS MCP Server as a container with STDIO integration, configure your mcpServers like this:
``` json
{
"mcpServers": {
"pyats": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"PYATS_TESTBED_PATH",
"-v",
"/absolute/path/to/testbed/folder:/app",
"pyats-mcp-server"
],
"env": {
"PYATS_TESTBED_PATH": "/app/testbed.yaml"
}
}
}
}```
π§Ύ Explanation:
command: Uses Docker to launch the containerized pyATS MCP serverargs:
-i: Keeps STDIN open for communication
--rm: Automatically removes the container after execution
-e: Injects the environment variable PYATS_TESTBED_PATH
-v: Mounts your local testbed directory into the container
pyats-mcp-server: Name of the Docker image
env:
Sets the path to the testbed file inside the container (/app/testbed.yaml)
βοΈ Author
John Capobianco
Product Marketing Evangelist, Selector AI
Author, Automate Your Network
Let me know if youβd like to add:
A sample LangGraph graph config
Companion client script
CI/CD integration (e.g., GitHub Actions)
Happy to help!
# The testbed.yaml file works with the Cisco DevNet Cisco Modeling Labs (CML) Sandbox!