Metadata-Version: 2.4
Name: hier-config-mcp
Version: 0.1.1a0
Summary: MCP server for hier_config network configuration management
License: MIT
License-File: LICENSE
Author: James Williams
Author-email: james.williams@jtdub.com
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: hier-config (>=4.0.0b1,<5.0)
Requires-Dist: mcp[cli] (>=1.2.0,<2.0.0)
Description-Content-Type: text/markdown

# hier-config-mcp

An MCP (Model Context Protocol) server that exposes [hier_config](https://github.com/netdevops/hier_config)'s network configuration comparison and remediation capabilities to AI assistants like Claude.

## Features

- **Configuration Parsing**: Parse network device configurations into hierarchical structures
- **Configuration Comparison**: Compare running vs intended configurations
- **Remediation Generation**: Generate commands to bring devices into compliance
- **Rollback Generation**: Generate commands to revert changes
- **Future State Prediction**: Predict configuration state after applying changes
- **Unified Diff**: Generate diffs between configurations

## Supported Platforms

- **CISCO_IOS** - Cisco IOS (classic IOS for routers and switches)
- **CISCO_NXOS** - Cisco NX-OS (Nexus switches)
- **CISCO_XR** - Cisco IOS-XR (carrier-grade routers)
- **ARISTA_EOS** - Arista EOS (data center switches)
- **ARUBA_AOSCX** - Aruba AOS-CX
- **HP_COMWARE5** - HP Comware 5
- **HP_PROCURVE** - HP ProCurve
- **HUAWEI_VRP** - Huawei VRP
- **JUNIPER_JUNOS** - Juniper Junos
- **NOKIA_SRL** - Nokia SR Linux
- **VYOS** - VyOS
- **FORTINET_FORTIOS** - Fortinet FortiOS
- **GENERIC** - Platform-agnostic parsing

## Installation

```bash
# Clone the repository
git clone https://github.com/jtdub/hier-config-mcp.git
cd hier-config-mcp

# Install dependencies with Poetry
poetry install
```

## Usage

### Running the Server

```bash
# Run the MCP server
poetry run hier-config-mcp

# Or use the MCP development server with inspector
poetry run mcp dev hier_config_mcp/server.py
```

### Claude Desktop Configuration

Add to your Claude Desktop configuration file (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):

```json
{
  "mcpServers": {
    "hier-config": {
      "command": "poetry",
      "args": [
        "-C",
        "/path/to/hier-config-mcp",
        "run",
        "hier-config-mcp"
      ]
    }
  }
}
```

## Available Tools

### `list_platforms`

List all supported network platforms.

### `parse_config`

Parse network device configuration text into a hierarchical format.

**Parameters:**
- `platform`: Network platform name (e.g., "CISCO_IOS")
- `config`: Configuration text to parse

### `compare_configs`

Compare running configuration against intended configuration and generate both remediation and rollback commands.

**Parameters:**
- `platform`: Network platform name
- `running_config`: Current device configuration
- `intended_config`: Desired configuration

**Returns:** Object with `remediation` and `rollback` commands

### `generate_remediation`

Generate commands to transform running config to intended config.

**Parameters:**
- `platform`: Network platform name
- `running_config`: Current configuration
- `intended_config`: Target configuration

### `generate_rollback`

Generate commands to revert from intended config back to running config.

**Parameters:**
- `platform`: Network platform name
- `running_config`: Original configuration
- `intended_config`: Configuration to rollback from

### `predict_config`

Predict the configuration state after applying changes.

**Parameters:**
- `platform`: Network platform name
- `current_config`: Current configuration
- `change_config`: Changes to apply

### `unified_diff_configs`

Generate a unified diff between two configurations.

**Parameters:**
- `platform`: Network platform name
- `config_a`: First configuration
- `config_b`: Second configuration
- `label_a`: Label for first config (optional)
- `label_b`: Label for second config (optional)

## Documentation

Full documentation — user, administrator, developer, and maintainer guides — lives in [`docs/`](docs/index.md) and is built with mkdocs:

```bash
poetry run mkdocs serve
```

## Development

This repo follows the same development standards as [hier_config](https://github.com/netdevops/hier_config): ruff (`select = ["ALL"]`, preview, line length 88), mypy strict, pyright strict, pylint, yamllint, and flynt, with a 95% test coverage floor. All checks run in parallel via `scripts/build.py`.

### Docker Development Environment

A Docker-based workflow modeled on Nautobot app development is available via [invoke](https://www.pyinvoke.org/) — see [docs/dev/docker-development.md](docs/dev/docker-development.md):

```bash
invoke build     # build the dev image
invoke start     # start the dev container
invoke tests     # run everything CI runs, inside the container
invoke destroy   # tear down
```

### Lint and Test

```bash
# Full lint + test suite (what CI runs)
poetry run python scripts/build.py lint-and-test

# Lint only
poetry run python scripts/build.py lint

# Auto-fix formatting and fixable lint findings
poetry run python scripts/build.py lint --fix

# Tests with coverage (95% required)
poetry run python scripts/build.py pytest --coverage

# Tests directly
poetry run pytest
```

### Pre-commit Hook

```bash
# One-time setup; the hook runs the full lint suite before each commit
poetry run pre-commit install
```

### Releasing

Releases are driven by two GitHub Actions workflows (admin permission required):

1. Run the **prepare release** workflow (`Actions` → `prepare release` → `Run workflow`), picking the branch to release from in the branch dropdown and the version bump type (`major`, `minor`, `patch`, or `prerelease`). It bumps the version with `poetry version`, opens a `chore(release): prepare X.Y.Z` PR against the chosen branch, and creates a draft GitHub release tagged `vX.Y.Z`.
2. Merge the release PR.
3. Publish the draft release. Publishing triggers the **release** workflow, which builds and publishes the package to PyPI automatically (`poetry publish --build`).

### Project Structure

```
hier-config-mcp/
├── pyproject.toml
├── README.md
├── mkdocs.yml
├── docs/
│   ├── index.md
│   ├── user/
│   ├── admin/
│   └── dev/
├── hier_config_mcp/
│   ├── __init__.py
│   ├── py.typed
│   └── server.py
└── tests/
    ├── __init__.py
    └── test_server.py
```

## License

MIT

