MCP server for junos-ops: expose Juniper device operations to AI assistants
Project description
junos-mcp
English | 日本語
MCP (Model Context Protocol) server for junos-ops.
Exposes Juniper Networks device operations to MCP-compatible AI assistants (Claude Desktop, Claude Code, etc.) via STDIO transport. While junos-ops is the CLI tool for humans, junos-mcp is the AI-facing interface to the same powerful engine.
Features
Device Information
| Tool | Description | Connection |
|---|---|---|
get_device_facts |
Get basic device information (model, hostname, serial, version) | Yes |
get_version |
Get JUNOS version with upgrade status | Yes |
get_router_list |
List all available routers from config.ini | No |
CLI Command Execution
| Tool | Description | Connection |
|---|---|---|
run_show_command |
Run a single CLI show command | Yes |
run_show_commands |
Run multiple CLI commands in a single session | Yes |
run_show_command_batch |
Run a command on multiple devices in parallel | Yes |
Configuration Management
| Tool | Description | Connection |
|---|---|---|
get_config |
Get device configuration (text/set/xml format) | Yes |
get_config_diff |
Show config diff against a rollback version | Yes |
push_config |
Push config with commit confirmed + health check | Yes |
Upgrade Operations
| Tool | Description | Connection |
|---|---|---|
check_upgrade_readiness |
Check if device is ready for upgrade | Yes |
compare_version |
Compare two JUNOS version strings | No |
get_package_info |
Get model-specific package file and hash | No |
list_remote_files |
List files on remote device path | Yes |
copy_package |
Copy firmware package via SCP with checksum | Yes |
install_package |
Install firmware with pre-flight checks | Yes |
rollback_package |
Rollback to previous package version | Yes |
schedule_reboot |
Schedule device reboot at specified time | Yes |
Diagnostics
| Tool | Description | Connection |
|---|---|---|
collect_rsi |
Collect RSI/SCF with model-specific timeouts | Yes |
collect_rsi_batch |
Collect RSI/SCF from multiple devices in parallel | Yes |
Safety by Design
All destructive operations (push_config, copy_package, install_package,
rollback_package, schedule_reboot) default to dry-run mode (dry_run=True).
The AI assistant must explicitly set dry_run=False to make changes.
push_config provides additional safety features not found in other Junos MCP servers:
- commit confirmed with configurable timeout (auto-rollback if not confirmed)
- Fallback health check after commit (ping, NETCONF uptime probe, or any CLI command)
- Automatic rollback if health check fails (commit is not confirmed, timer expires)
Requirements
- Python 3.12+
- junos-ops with a valid
config.ini - MCP Python SDK >= 1.0
Installation
pip install junos-mcp
Or for development:
git clone https://github.com/shigechika/junos-mcp.git
cd junos-mcp
python3 -m venv .venv
. .venv/bin/activate
pip install -e ".[test]"
Configuration
This server uses the same config.ini as junos-ops. See junos-ops README for details.
Each tool accepts an optional config_path parameter. If omitted, the default search order is used:
- Environment variable
JUNOS_OPS_CONFIG ./config.ini~/.config/junos-ops/config.ini
Usage
Claude Code
Register the MCP server with claude mcp add:
claude mcp add junos-mcp \
-e JUNOS_OPS_CONFIG=~/.config/junos-ops/config.ini \
-- python -m junos_mcp
The --scope (-s) option controls where the configuration is stored:
| Scope | Description | Config location |
|---|---|---|
local (default) |
Current project, current user only | ~/.claude.json |
project |
Current project, shared with team | .mcp.json in project root |
user |
All projects, current user only | ~/.claude.json |
Claude Desktop
Add to Claude Desktop config file:
| OS | Config file |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| Linux | ~/.config/Claude/claude_desktop_config.json |
{
"mcpServers": {
"junos-mcp": {
"command": "python",
"args": ["-m", "junos_mcp"],
"env": {
"JUNOS_OPS_CONFIG": "/path/to/config.ini"
}
}
}
}
Restart Claude Desktop after editing.
MCP Inspector (development)
mcp dev junos_mcp/server.py
Testing
pytest tests/ -v
71 tests covering all 19 tools, helper functions, and edge cases.
Architecture
stdout Capture
junos-ops functions use print() for output. Since MCP STDIO transport uses stdout for JSON-RPC communication, all print() output is captured via contextlib.redirect_stdout and returned as tool results.
Global State Initialization
junos-ops uses common.args and common.config as global variables. The MCP server initializes these using the same pattern as the test fixtures in junos-ops (conftest.py).
Parallel Execution
Batch tools (run_show_command_batch, collect_rsi_batch) use ThreadPoolExecutor via junos-ops common.run_parallel() with configurable max_workers.
License
Apache License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file junos_mcp-0.3.0.tar.gz.
File metadata
- Download URL: junos_mcp-0.3.0.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99385477d2a96709fa37f973b0e51325227f558ac99d0f907ba9dea06511f2c9
|
|
| MD5 |
58e1f9fb84df33c89475917343a9de96
|
|
| BLAKE2b-256 |
dce70be17dcd1389bdbf9455fce74d67602775e14cdce350a65fc393c2758d08
|
Provenance
The following attestation bundles were made for junos_mcp-0.3.0.tar.gz:
Publisher:
pypi.yaml on shigechika/junos-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
junos_mcp-0.3.0.tar.gz -
Subject digest:
99385477d2a96709fa37f973b0e51325227f558ac99d0f907ba9dea06511f2c9 - Sigstore transparency entry: 1234081744
- Sigstore integration time:
-
Permalink:
shigechika/junos-mcp@a0faabec458305d34c9c99fda44215d97bd4c3e0 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/shigechika
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@a0faabec458305d34c9c99fda44215d97bd4c3e0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file junos_mcp-0.3.0-py3-none-any.whl.
File metadata
- Download URL: junos_mcp-0.3.0-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55b5025df0dc6bd7e98312ace64d123a690cb9a44b8ab8eb417739e444722bd0
|
|
| MD5 |
740dd7888a0c5af2d382ff416656e8f5
|
|
| BLAKE2b-256 |
92df439fa576ec5245839fd600723f2ab9a913fbf9c1b6397f1fcacbf09b3442
|
Provenance
The following attestation bundles were made for junos_mcp-0.3.0-py3-none-any.whl:
Publisher:
pypi.yaml on shigechika/junos-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
junos_mcp-0.3.0-py3-none-any.whl -
Subject digest:
55b5025df0dc6bd7e98312ace64d123a690cb9a44b8ab8eb417739e444722bd0 - Sigstore transparency entry: 1234081779
- Sigstore integration time:
-
Permalink:
shigechika/junos-mcp@a0faabec458305d34c9c99fda44215d97bd4c3e0 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/shigechika
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@a0faabec458305d34c9c99fda44215d97bd4c3e0 -
Trigger Event:
push
-
Statement type: