netlab-mcp
Allows generation and validation of network device configurations for Nokia SR Linux platforms using netlab. The server can create topologies, render device configs, and run lab validations on Nokia SR Linux devices.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@netlab-mcp create an eBGP topology with srlinux and frr"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
netlab-mcp
An MCP server that wraps ipspace/netlab as an engine to give LLMs
access to validated, lab-tested network device configurations — instead of hallucinated ones.
Why
Getting working network configs out of a raw LLM is unreliable: vendor-syntax drift, no validation,
invented data-model fields, no interop guarantees. netlab already solves the hard part — it owns the
data-model transform (AS / RD-RT / VNI / neighbor computation), the Jinja2 render, the containerlab
provider, and a netlab validate test system. This server does not re-serve raw .j2 templates or
rebuild that pipeline. It exposes netlab's outputs to an LLM and records what actually passes in a lab.
Related MCP server: pyATS MCP Server
What it does
Offline (fast, no docker): translate intent → netlab topology, render real per-device config, query declared module/platform support.
Lab (needs docker + containerlab): deploy to containerlab, run
netlab validate, record the pass/fail verdict into a version-scoped compatibility matrix.
Lab ≠ production. Every config-bearing tool response embeds the full disclaimer from
netlab_mcp.models.DISCLAIMER. Configs are validated only in an isolated, synthetic netlab +
containerlab lab on free images. "Validated in lab" ≠ "safe in your network" — review IP/AS/naming
and interactions with your existing config before applying to real gear. See SECURITY.md.
Scope (MVP)
Free containerlab images only:
srlinux,frr,cumulus,vyos,linux(ceosbehind an explicit EULA env flag). Licensed NOSes (nxos/iosxr/sros/junos/…) come later behind a self-hosted runner.First proven loop: eBGP across srlinux + frr.
Tools
Tool | Mode | Disclaimer | Purpose |
| offline | — | intent + platforms → netlab topology YAML (validated by parse) |
| offline | ✅ | topology → real per-device config + clab.yml |
| offline | — | netlab declared support, overlaid with observed lab verdicts |
| offline | ✅ | return a previously lab-passed topology + config |
| offline | — | index netlab's integration test topologies |
| offline | — | record a negative result into the matrix |
| offline | — | doctor: lab readiness, versions, loaded images, validation plugins |
| lab | ✅ | deploy + |
Mode: offline needs no docker; lab requires docker + containerlab. Disclaimer: ✅ responses embed
the lab≠production disclaimer.
Install — offline (no docker)
The engine (netlab binary + netsim) installs from PyPI as networklab; you do not need to vendor it.
uv venv --python 3.12 .venv
source .venv/bin/activate
uv pip install -e '.[dev]' # pulls networklab (the `netlab` binary) from PyPI
# Only `list_examples` needs netlab's SOURCE tree (tests/integration); it is gitignored.
git clone --depth 1 https://github.com/ipspace/netlab netlab
pytest -m "not docker" # offline + contract suite, no docker needed
netlab-mcp # run the MCP server over stdioInstall — lab (docker + containerlab)
The lab path (validate_in_lab) has host prerequisites that pip does not install. On a dedicated
Linux lab host:
# | Prerequisite | Why | How |
1 | containerlab ≥ 0.75.0 | netlab 26.06's container provider requires it | |
2 | Ansible in the same venv as netlab | netlab pushes device config via Ansible, calling bare |
|
3 | Per-device Ansible collections | each NOS driver needs its collection | e.g. |
4 | Scoped passwordless sudo for containerlab | netlab runs | see block below |
PATH trap: because netlab invokes bare binary names, the server must run with the venv activated (or
.venv/binonPATH), or netlab won't findansible-playbook/netlab.
Passwordless sudo — create /etc/sudoers.d/netlab-clab (mode 0440, validate with visudo -cf):
<user> ALL=(root) NOPASSWD: SETENV: /usr/bin/containerlabThe
SETENV:tag is mandatory — netlab passes-E; without it you getsorry, you are not allowed to preserve the environment.Do NOT use
NOPASSWD: ALL.Security implication: containerlab can bind-mount host paths and run privileged containers, so this entry is effectively passwordless root for
<user>. Use it only on a dedicated/disposable lab host. See SECURITY.md.
Verify the host is lab-ready: docker info and containerlab version (≥ 0.75.0) succeed. If they don't,
validate_in_lab degrades cleanly to verdict unavailable (it is not an error) and the offline tools
keep working.
Quickstart — the eBGP srlinux + frr loop
Canonical topology: tests/fixtures/mvp_bgp.yml — srlinux DUT (AS 65000) ↔
frr peer (AS 65100), with a validate.session test that checks the BGP neighbor reaches Established.
Driving the tools the way an MCP client would (see scripts/smoke_offline.py):
generate_topology("ebgp peering", ["srlinux", "frr"])→ netlab topology YAML.render_config(topology_yaml)→ real per-node config (srlinux JSON-RPC, frr vtysh) +clab.yml.validate_in_lab(topology_yaml, ["srlinux", "frr"], module="bgp")→ deploy +netlab validate; verdictpassis recorded as known-good (with cached artifacts).get_known_good("bgp", "srlinux")→ the lab-passed topology + config for reuse.
Security model
Free-image allow-list, enforced on netlab's resolved node devices (not the caller's
platformsclaim) and fails closed when a device can't be resolved — licensed NOSes are rejected.ceosis gated behind the explicitNETLAB_MCP_ACCEPT_CEOS_EULAenv flag.External
tools:(edgeshark, nso, …) are rejected, withnetlab up --no-toolsas a backstop.A platforms/topology mismatch is rejected (no spoofing the declared device set).
Every config-bearing response embeds the lab≠production disclaimer.
Full threat model — including what the guardrails explicitly do not protect against — is in SECURITY.md.
Configuration (env vars)
Variable | Effect |
| path to the |
| store dir for the matrix db + artifacts (default: |
| base dir for per-request temp workdirs (default: |
| set truthy to allow the EULA-gated |
| comma-separated extra device names to allow past the free set |
| set truthy to allow any device backed by a locally loaded docker image |
|
|
| HTTP bind address (default |
| enable static bearer auth on the HTTP transport |
HTTP transport
NETLAB_MCP_TRANSPORT=http NETLAB_MCP_TOKEN_FILE=/etc/netlab-mcp/token netlab-mcpserves MCP on http://127.0.0.1:8000/mcp (Authorization: Bearer <token>) plus an
unauthenticated GET /health liveness probe (cheap, non-sensitive — safe to expose to
uptime checks). A non-loopback NETLAB_MCP_HOST is refused unless a token is configured:
validate_in_lab reaches docker/sudo on this machine, so the token is effectively
root-equivalent — treat it accordingly and prefer NETLAB_MCP_TOKEN_FILE (mode 0600) over
the bare env var. Client config:
{
"mcpServers": {
"netlab": {
"type": "http",
"url": "http://127.0.0.1:8000/mcp",
"headers": { "Authorization": "Bearer <token>" }
}
}
}Systemd unit sketch:
[Service]
Environment=NETLAB_MCP_TRANSPORT=http
Environment=NETLAB_MCP_TOKEN_FILE=/etc/netlab-mcp/token
ExecStart=/opt/netlab-mcp/.venv/bin/netlab-mcp
User=netlabArchitecture
LLM / MCP client → FastMCP server (allow-list + disclaimer guardrails) → offline engine (netlab create
/ initial -o / show module-support) or lab engine (netlab up → containerlab → netlab validate) →
sqlite matrix store. See docs/netlab-mcp-architecture.excalidraw
(open at excalidraw.com → File ▸ Open; regenerate with python scripts/gen_diagram.py).
Layout
src/netlab_mcp/
server.py FastMCP app + tool registrations
config.py netlab binary discovery, platform allow-list, paths
models.py disclaimer + shared constants
engine/ runner, transform, render, compat, probes, lab, topo, topogen
store/ sqlite matrix + yaml mirror + results.yaml harvest
store/ runtime state (matrix.db gitignored, matrix.yaml committed)
tests/ offline (CI-safe), contract, lab (docker-gated)Contributing
See CONTRIBUTING.md. The PR gate is pytest -m "not docker"; lab tests are
docker-gated. By participating you agree to the Code of Conduct.
License
Apache-2.0. The wrapped ipspace/netlab engine is separately licensed (MIT) and is not
vendored or redistributed by this project — it is installed as a dependency.
Acknowledgements
Built on ipspace/netlab and
containerlab. Disclaimer: this is an independent project, not affiliated with
or endorsed by either.
Available Tools
8 toolsgenerate_topologyA
Turn an intent + target platforms into a netlab topology YAML (parse-validated).
intent: free text, e.g. "ebgp peering" or "ospf two routers". The module is inferred.
platforms: NOS list, dut first (MVP free set: srlinux, frr, cumulus, vyos, linux).
Feed the returned topology_yaml to render_config or validate_in_lab.
Inputs: intent (required), platforms. Returns: object
get_known_goodB
Return a previously lab-passed topology + rendered config for module+platform, if any.
Inputs: module (required), platform (required), netlab_version. Returns: object
host_checkA
Diagnose this host's lab readiness in one call — run this first when anything fails.
Reports docker/containerlab availability + versions, the netlab version, which platforms are allowed, which devices have locally loaded images (deployable without a pull), and which devices can anchor validate tests per module.
Inputs: no named parameters. Returns: object
list_examplesA
Index netlab's integration test topologies (real, maintained multi-platform scenarios).
With no module: list available modules + counts. With a module: list its scenarios.
Inputs: module. Returns: object
query_compatibilityC
What netlab declares a platform supports, overlaid with what was observed in the lab.
declared comes from netlab; observed comes from prior validate_in_lab/harvest runs.
conflicts flags cells declared-supported but observed-failing for the current version.
Inputs: module, platforms. Returns: object
render_configA
Render real per-device config from a netlab topology — offline, no containers.
Returns {per_node: {node: {module: config_text}}, clab_yaml, disclaimer}. This is the netlab data-model transform + Jinja2 render; the config matches what would deploy.
Inputs: topology_yaml (required), nodes. Returns: object
report_failureC
Record a negative result (a combo that did not work) into the compatibility matrix.
Inputs: module (required), platforms (required), topology_yaml (required), error (required), +1 more. Returns: object
validate_in_labA
Deploy a topology to containerlab, run netlab validate, and record the verdict.
Requires docker + containerlab on a Linux host. Returns the verdict (pass/fail/warning), rendered config, raw validate output, and persists a version-scoped matrix row. The lab is always torn down afterward. On a host without containerlab this returns verdict "unavailable" rather than failing.
Inputs: topology_yaml (required), platforms (required), module, scenario, +2 more. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clearly distinct purpose: topology generation, known-good retrieval, host check, example listing, compatibility query, config rendering, failure reporting, and lab validation. No overlap in functionality.
All tool names follow a consistent verb_noun pattern in snake_case (e.g., generate_topology, validate_in_lab, report_failure). Naming is predictable and readable.
With 8 tools, the set is well-scoped for a netlab MCP server. Each tool is justified and covers a specific step in the workflow without being excessive or insufficient.
The tool surface covers the full lifecycle: topology generation, config rendering, validation, host readiness, compatibility queries, failure reporting, and example browsing. No obvious missing operations for the intended domain.
Maintenance
Related MCP Connectors
AI network lab: build and validate real multi-vendor router and switch labs from a prompt.
AI helper for choosing and speccing network & security products from Cisco, Arista, Juniper and more
Provides capabilities that let LLM agents perform a range of infrastructure management tasks.
AI routing, memory, guardrails, and governance. Routes across Claude, GPT, Gemini.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables programmatic control of a PNETLab network-emulation lab via natural language, allowing users to build topologies, wire links, push device configs, and boot the lab through an LLM agent.316Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to directly inspect, configure, test, and orchestrate network devices through pyATS/Genie, including show command parsing, config rollback, feature state learning/diffing, fleet-wide command fan-out, and declarative test execution.MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to understand lab topologies, follow operational principles, and interact with real network devices through observable terminals while keeping private access information hidden.7Apache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables LLMs to turn natural-language prompts into validated, deployed Cisco network topologies, including routing, switching, DHCP, VLANs, security auditing, and live device inspection.MIT