Cover image
Try Now
2025-04-10

Un servidor MCP para Pyats (experimental)

3 years

Works with Finder

3

Github Watches

4

Github Forks

10

Github Stars

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

export PYATS_TESTBED_PATH=/absolute/path/to/testbed.yaml

  1. Run the server

Continuous STDIO Mode (default)


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


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


docker build -t pyats-mcp-server .

Run the container (STDIO Mode)

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:


("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


{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/discover"
}

Run Show Command


{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "run_show_command",
    "arguments": {
      "device_name": "router1",
      "command": "show ip interface brief"
    }
  }
}

🔒 Security Features

Input 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


.
├── 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:

{
  "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 server

args:

-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!

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • tomoyoshi hirata
  • Sony α7IIIマニュアルアシスタント

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • jae-jae
  • Servidor MCP para obtener contenido de la página web con el navegador sin cabeza de dramaturgo.

  • ravitemer
  • Un poderoso complemento Neovim para administrar servidores MCP (protocolo de contexto del modelo)

  • patruff
  • Puente entre los servidores Ollama y MCP, lo que permite a LLM locales utilizar herramientas de protocolo de contexto del modelo

  • pontusab
  • La comunidad de cursor y windsurf, encontrar reglas y MCP

  • av
  • Ejecute sin esfuerzo LLM Backends, API, frontends y servicios con un solo comando.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llM 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Resumen de los mejores recursos del mundo.

  • Mintplex-Labs
  • La aplicación AI de escritorio todo en uno y Docker con trapo incorporado, agentes de IA, creador de agentes sin código, compatibilidad de MCP y más.

  • modelcontextprotocol
  • Servidores de protocolo de contexto modelo

    Reviews

    2 (1)
    Avatar
    user_akL1oLXn
    2025-04-17

    As a dedicated user of pyATS_MCP, I can confidently say that this tool is a game-changer for network automation. Created by automateyournetwork, it integrates seamlessly with pyATS to provide robust, reliable network testing and automation capabilities. The user-friendly interface and comprehensive documentation available on the GitHub page make it easy to get started and leverage its full potential. Highly recommended for anyone looking to streamline their network operations!