# juniper/junos-mcp-server architecture

> Architecture diagram of the GitHub repository juniper/junos-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/juniper/junos-mcp-server
- Repository: https://github.com/juniper/junos-mcp-server

## Overview

Junos MCP Server exposes network-device operations as MCP tools: a client request is dispatched to a registered handler, which performs the requested operation against configured Junos devices and returns content to the client. The product also supports configuration templating and changes, operational-command guardrails, device facts, and authenticated HTTP access with token management. Core server and tool behavior is concentrated in jmcp.py; the excerpts do not show every handler’s wiring, so uncertain links are omitted.

Main entry points: [`jmcp.py`](https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py) (SSH connection pool), [`devices-template.json`](https://github.com/juniper/junos-mcp-server/blob/main/devices-template.json) (Device mapping), [`utils/config.py`](https://github.com/juniper/junos-mcp-server/blob/main/utils/config.py) (Device config validation), [`jmcp_token_manager.py`](https://github.com/juniper/junos-mcp-server/blob/main/jmcp_token_manager.py) (Token manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mcp["MCP access"]
  node_server["MCP server<br/>[jmcp.py]"]
  node_tool_registry["Tool registry<br/>[jmcp.py]"]
end

subgraph group_tools["Device tools"]
  node_cli_tools["CLI and config reads<br/>[jmcp.py]"]
  node_config_changes["Config changes<br/>[jmcp.py]"]
  node_template_tools["Template operations<br/>[jmcp.py]"]
  node_facts_tools["Device facts<br/>[jmcp.py]"]
  node_guardrails["Command guardrails<br/>[jmcp.py]"]
  node_other_tools["Other Junos tools<br/>[jmcp.py]"]
end

subgraph group_device["Device access"]
  node_device_config["Device mapping"]
  node_config_validation["Device config validation<br/>[config.py]"]
  node_connection_pool["SSH connection pool<br/>[jmcp.py]"]
end

subgraph group_security["Authentication"]
  node_http_auth["HTTP auth middleware<br/>[jmcp.py]"]
  node_token_manager["Token manager"]
  node_token_store[("Token store")]
end

node_client(("MCP client"))
node_junos{{"Junos devices"}}

node_client -->|"sends MCP requests"| node_server
node_server -.->|"checks HTTP requests"| node_http_auth
node_http_auth -.->|"validates tokens"| node_token_store
node_token_manager -->|"manages tokens"| node_token_store
node_server -->|"dispatches tools"| node_tool_registry
node_server -->|"loads mapping"| node_device_config
node_device_config -->|"provides device settings"| node_config_validation
node_cli_tools -->|"runs device commands"| node_connection_pool
node_config_changes -->|"applies configuration"| node_connection_pool
node_template_tools -->|"uses device connections"| node_connection_pool
node_facts_tools -->|"gathers device facts"| node_connection_pool
node_guardrails -->|"checks commands"| node_cli_tools
node_connection_pool -->|"prepares connection parameters"| node_config_validation
node_connection_pool -->|"opens device sessions"| node_junos
node_other_tools -.->|"uses device sessions"| node_connection_pool

click node_server "https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py"
click node_tool_registry "https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py"
click node_http_auth "https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py"
click node_token_manager "https://github.com/juniper/junos-mcp-server/blob/main/jmcp_token_manager.py"
click node_device_config "https://github.com/juniper/junos-mcp-server/blob/main/devices-template.json"
click node_config_validation "https://github.com/juniper/junos-mcp-server/blob/main/utils/config.py"
click node_connection_pool "https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py"
click node_cli_tools "https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py"
click node_config_changes "https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py"
click node_template_tools "https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py"
click node_facts_tools "https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py"
click node_guardrails "https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py"
click node_other_tools "https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_tool_registry,node_client toneBlue
class node_cli_tools,node_config_changes,node_template_tools,node_facts_tools,node_guardrails,node_other_tools toneAmber
class node_device_config,node_config_validation,node_connection_pool toneMint
class node_http_auth,node_token_manager,node_token_store toneRose
class node_junos toneIndigo
```

## Components

### MCP access

- [MCP server](https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py): `jmcp.py`
- [Tool registry](https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py): `jmcp.py`

### Device tools

- [CLI and config reads](https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py): `jmcp.py`
- [Config changes](https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py): `jmcp.py`
- [Template operations](https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py): `jmcp.py`
- [Device facts](https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py): `jmcp.py`
- [Command guardrails](https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py): `jmcp.py`
- [Other Junos tools](https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py): `jmcp.py`

### Device access

- [Device mapping](https://github.com/juniper/junos-mcp-server/blob/main/devices-template.json): `devices-template.json`
- [Device config validation](https://github.com/juniper/junos-mcp-server/blob/main/utils/config.py): `utils/config.py`
- [SSH connection pool](https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py): `jmcp.py`

### Authentication

- [HTTP auth middleware](https://github.com/juniper/junos-mcp-server/blob/main/jmcp.py): `jmcp.py`
- [Token manager](https://github.com/juniper/junos-mcp-server/blob/main/jmcp_token_manager.py): `jmcp_token_manager.py`
- **Token store**

### Other components

- **MCP client**
- **Junos devices**

## Connections

- MCP client → MCP server: sends MCP requests
- MCP server → HTTP auth middleware: checks HTTP requests
- HTTP auth middleware → Token store: validates tokens
- Token manager → Token store: manages tokens
- MCP server → Tool registry: dispatches tools
- MCP server → Device mapping: loads mapping
- Device mapping → Device config validation: provides device settings
- CLI and config reads → SSH connection pool: runs device commands
- Config changes → SSH connection pool: applies configuration
- Template operations → SSH connection pool: uses device connections
- Device facts → SSH connection pool: gathers device facts
- Command guardrails → CLI and config reads: checks commands
- SSH connection pool → Device config validation: prepares connection parameters
- SSH connection pool → Junos devices: opens device sessions
- Other Junos tools → SSH connection pool: uses device sessions
