convez.ai
MCP ServerDevOps & InfraestruturaAvançado
Devika-gopakumar

OVS MCP Server

Devika-gopakumar/ovs-mcp-server

MCP server para Open vSwitch com interface natural para agentes IA

Ver no GitHub
InicialPluginScore · de 0 a 100

Servidor MCP integrado ao Open vSwitch em C que permite a agentes IA consultar e controlar switches virtuais usando linguagem natural. Implementa um HTTP server leve que se conecta aos internals do OVS para fornecer ferramentas de leitura e escrita de portas, fluxos e VLANs.

Instalação

$npx convez-ai Devika-gopakumar/ovs-mcp-server

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
0
Forks
0
Acompanhando
0
Saúde
14%
Último commit
há 5 meses
Versão
—
Issues abertas
0
Contribuidores
1

Casos de uso

  • Controlar switches virtuais via linguagem natural com LLMs
  • Automação de configuração de redes OVS através de agentes IA
  • Consulta de estadísticas e topologia de redes virtuais

Veredito

Projeto técnico sólido que brid geramente o gap entre LLMs e gerência de redes. A implementação em C diretamente no OVS é elegante, mas exige conhecimento profundo de virtualização de rede; recomendado para engenheiros de infraestrutura que precisam expor OVS a agentes IA.

README

A tradução para o português deste README ainda está na fila.

Distributed MCP Fabric for Open vSwitch

A lightweight MCP (Model Context Protocol) server embedded inside Open vSwitch (OVS) in C, enabling AI agents to query and control a virtual network switch using natural language.


Architecture

        LLM / AI Agent (Gemini 2.5 Flash)
                    |
            MCP (multi-endpoint)
                    |
       +------------+------------+
       |            |            |
  MCP Server   MCP Server   MCP Server
  (Node 1)     (Node 2)     (Node 3)
       |            |            |
  Open vSwitch Open vSwitch Open vSwitch

Each node = [ MCP Server ] + [ Open vSwitch ]


Modules

Module 1 — OVS Build and Understanding

  • Built Open vSwitch from source on Kali Linux
  • Build pipeline: ./boot.sh → ./configure → make -j4 → sudo make install
  • Created virtual bridge br0 and test port test-port
  • Learned: bridges, ports, interfaces, flows, VLANs

Module 2 — MCP Server Integration

  • Created mcp_server.c — lightweight HTTP server embedded inside OVS
  • Listens on port 8080, endpoint: POST /mcp
  • Hooked into OVS main loop inside ovs-vswitchd.c:
    • mcp_server_init() — called once at OVS startup
    • mcp_server_run(idl) — called every main loop iteration
    • mcp_server_close() — called at OVS shutdown
  • Used non-blocking socket so OVS main loop never freezes

Module 3 — MCP Dispatcher

  • JSON parsing using OVS built-in openvswitch/json.h
  • dispatch_request() reads the tool field and routes to correct handler
  • Full error handling for invalid JSON, missing fields, unknown tools

Module 4 — Connect MCP to OVS Internals

  • get_ports — reads bridge, port, interface hierarchy from OVSDB IDL
  • get_flows — calls bridge_get_all_flows() using ofproto API
  • get_port_stats — calls bridge_get_port_stats() reading kernel netdev counters

Module 5 — SET Operations

  • set_vlan — writes VLAN tag to OVSDB then applies to datapath via port_configure()
  • set_port_state — enables or disables port using NETDEV_UP flag

Module 6 — LLM Integration

  • Python AI agent ovs_agent.py powered by Gemini 2.5 Flash
  • Plain English → Gemini decides tool → OVS executes → Gemini explains result
  • Three functions: ask_gemini(), call_ovs_tool(), explain_result()

Files

FileDescription
vswitchd/mcp_server.cNEW — HTTP server and all 5 tool handlers
vswitchd/mcp_server.hNEW — function declarations
vswitchd/bridge.cMODIFIED — added get_flows, get_port_stats, set_vlan, set_port_state
vswitchd/bridge.hMODIFIED — declared new bridge functions
vswitchd/ovs-vswitchd.cMODIFIED — added MCP init, run, close calls
vswitchd/automake.mkMODIFIED — added mcp_server.c to build
ovs_agent.pyNEW — Python LLM agent

MCP Tools

ToolDescriptionArguments
get_portsList all ports on the switchNone
get_flowsDump all flow rulesNone
get_port_statsPacket and byte counters per portNone
set_vlanSet VLAN tag on a portport, vlan
set_port_stateEnable or disable a portport, state (up/down)

Build and Run

Build OVS

cd ~/ovs
./boot.sh
./configure
make -j4
sudo make install

Start OVS

sudo ovsdb-server \
  --remote=punix:/usr/local/var/run/openvswitch/db.sock \
  --remote=db:Open_vSwitch,Open_vSwitch,manager_options \
  --pidfile --detach

sudo ovs-vswitchd --pidfile --detach

Create test bridge and port

sudo ovs-vsctl add-br br0
sudo ovs-vsctl add-port br0 test-port -- set interface test-port type=internal

Test with curl

curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -d '{"tool": "get_ports"}'

curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -d '{"tool": "get_flows"}'

curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -d '{"tool": "get_port_stats"}'

curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -d '{"tool": "set_vlan", "arguments": {"port": "test-port", "vlan": 100}}'

curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -d '{"tool": "set_port_state", "arguments": {"port": "test-port", "state": "down"}}'

curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -d '{"tool": "set_port_state", "arguments": {"port": "test-port", "state": "up"}}'

Run AI Agent

pip install google-genai --break-system-packages
python3 ovs_agent.py

Natural language commands

show me all ports
show me all flows
show me port statistics
disable the test-port
enable the test-port
set vlan 200 on test-port

Tech Stack

ComponentTechnology
OSKali Linux
SwitchOpen vSwitch 3.7.90
MCP ServerC (embedded inside OVS)
AI AgentPython
LLMGemini 2.5 Flash (google-genai)
ProtocolHTTP/JSON on port 8080
JSON LibraryOVS built-in openvswitch/json.h
Ver o original no GitHub

Bom para

Relacionados