netmiko-mcp
claude-project — netmiko MCP サーバー + スキル
コピーしてすぐに使えるプロジェクトです。AI エージェントに SSH 経由でのルーター、スイッチ、ファイアウォールへの読み取り専用アクセス を、Model Context Protocol を通じて提供します。
このプロジェクトには、以下の 2 つのコンポーネントとそれらの間の連携が含まれています。
mcps/mcp_server_netmiko.py— 自己完結型の MCP サーバー。10 個のツールを備え、すべてのコマンドはオペレーター定義の許可/拒否リストに対して検証され、出力はntc-templatesで JSON にパースされ、すべての試行は fail-closed の監査証跡に記録されます。.claude/skills/netmiko/SKILL.md— エージェントに、いつこれらのツールを使うべきか、各プラットフォームの CLI 方言がどのようなものか、そして拒否をどのように読み解くかを教えるスキルです。
ここではデバイスへの書き込みは一切行いません。許可リストはデフォルト拒否(default-deny)です。空のリストは何も許可せず、拒否側が常に許可側よりも優先されます。
発生したすべての動作は監査証跡に記録され、netmiko.query_audit_trail によって会話の中で問い合わせ可能です:"SW-CORE-01 で行われたすべての操作を日付順に"、"最後の 6 つのアクション"、"今週拒否されたコマンド"。このプロジェクトには UI がないため、このツールが監査証跡を読む唯一の方法です。
著者と由来
このプロジェクトは Ed Scrimaglia (edgardo.scrimaglia@gmail.com、Octupus) によって執筆されました。サーバー、スキル、設定モデル、ドキュメントはすべて彼の作品であり、Niko エージェント 向けに書かれ、スタンドアロンプロジェクトとしてパッケージ化されています。
このプロジェクトはフォークから始まりましたが、その起源は隠さずに明示されています。出発点は Kirk Byers の作品であり、そこから大きく発展しました。現在ここにあるもの — ソースオブトゥルース(SoT)に基づくインベントリ、資格情報解決、3 つのデプロイ形態、出力ページング、監査証跡、スキル、そしてこのドキュメント — は上流には存在しません。
Kirk Byers による 2 つの上流プロジェクト:
Netmiko — 実際にデバイスと通信を行うマルチベンダー SSH ライブラリ。
netmiko_mcp — このサーバーがフォークした MCP サーバー。その一部はほぼそのまま残っています。セキュリティの中核部分(コマンド検証、グロブ処理、許可/拒否の非対称性)は、上流のパッチを今後も差分適用できるよう、意図的に忠実に移植されています。これはエンジニアリング上の判断であり、それ以外の作業の制限ではありません。
Related MCP server: MCP-Telecom
Niko について
このサーバーは Niko (Neural Intelligence Knowledge Orchestrator AI エージェント) のために書かれました。Niko は Octupus で Ed Scrimaglia によって構築されました。Niko は複数の MCP サーバー(ソースオブトゥルースサーバー、このサーバー、Jira、メール送信、ファイル作成など)の前面に立ち、オペレーターが平易な言葉で質問し、それを実環境から回答を得られるようにします。つまり、SoT は あるべき状態 を、デバイス自体は 実際の状態 を提供します。
Niko 内部では同じファイルが少し異なる動きをします。これはコード内のいくつかの要素を説明するために知っておく価値があります。
サーバーは ループバック上の HTTP で動作し、各ポートが割り当てられ、
mcps/mcp_config.jsonでurl/transport/local/envとして宣言されます。これは後述の 2 軸設定と同じものを Niko 独自の形式で表現したものです。インストールはファイルのコピーではなく、アプリを通じて行われます。アップロードは検証され、依存関係はコード自体から解決され、インストールに失敗した場合はサーバーが中途半端な状態にならないようロールバックされます。
これらの統合はすべて オプションのインポートとフォールバック であり、niko がインストールされている必要はありません。4 つのインポートがあり、それぞれが失敗した場合の動作は以下の通りです。
インポート | 行 | スタンドアロンでのフォールバック |
| 60 |
|
| 68 |
|
| 436 |
|
| 2709 | ペイロードを変更せずに返す no-op 関数 |
Niko の外部で重要なものが失われることはありません。同時実行ハンドラは複数プロセス・1 ファイルの問題を解決するものですが、ここでは発生しません。リストバジェットは、独自のコンテキスト管理を持つエージェントのために長いペイロードをトリミングします。1 つのファイル、2 つの居場所、フォークはありません。
Fedele は Niko のソースオブトゥルースです。そのため、SoT 変数は NetBox インスタンスを指していても FEDELE_ プレフィックスを持ちます。
ライセンス
このプロジェクト自身のコードは MIT です — LICENSE を参照してください。
派生作品であるため、2 つのライセンスが適用され、両方のファイルが同梱されています。
ライセンス | ファイル | |
このプロジェクトのコード、ドキュメント、スキル | MIT | |
| Apache-2.0 |
NOTICE には、Apache-2.0 §4(b) で要求される帰属表示と変更声明が記載されています。Netmiko は通常の MIT 依存関係です。インポートされ、ベンダリングはされておらず、再配布するものはありません。
レイアウト
claude-project/
├── .mcp.json # declares the server (project scope)
├── .env.example # → copy to .env with the SSH credentials
├── .claude/skills/netmiko/
│ └── SKILL.md # one directory per skill, file named SKILL.md
├── mcps/
│ └── mcp_server_netmiko.py # NOT at the root: the server reads ../.env
├── config/netmiko/
│ ├── commands.yml # allow/deny list — without it, a 16-command fallback applies
│ └── inventory.yml # inventory in netmiko_tools format
├── logs/ # netmiko-mcp.log + netmiko-audit.jsonl
├── mcpr/netmiko/ # created on demand (0700): large outputs
├── LICENSE LICENSE-APACHE-2.0 NOTICE
└── pyproject.toml譲れない 2 つのルール:
スキルは
.claude/skills/<name>/SKILL.mdに配置します。 Claude Code はskills/netmiko.mdを読みません。ディレクトリとその正確なファイル名が必要です。サーバーは
mcps/に配置し、ルートには置きません。PARENT_DIRは.pyファイル (mcp_server_netmiko.py:62) があるディレクトリの親であり、そこから.envが読み込まれます。サーバーがルートにあると、.envはプロジェクトの 1 つ上の階層で検索されます。
実行方法
uv venv --python 3.12
uv pip install -r <(uv pip compile pyproject.toml) # or: uv sync
cp .env.example .env && $EDITOR .env # SSH credentials
# .mcp.json needs no editing: its paths are project-relative
claude # approve the project serverセッション内で:/mcp で 10 個のツールが一覧表示され、/skills でスキルが読み込まれたことを確認できます。まずはネットワークに触れずに確認:
netmiko MCP が強制しているコマンドポリシーはどれですか?
3 つの形態
インベントリ の取得元と 資格情報 の取得元は、独立した 2 つの軸です。これにより、1 つのサーバーから 3 つのデプロイ形態が生まれます。そして、2 つの環境変数を変更するだけで、サーバー自体を修正することなくそれらの間を移行できます。
インベントリ | 資格情報 | 必要なもの | 使用すべき場面 | |
A — SoT で全てを管理 | Fedele | Fedele | API トークン + Fernet キー | SoT が信頼でき、すでにデバイスの資格情報を保持している場合 |
B — SoT でインベントリ、ローカルで資格情報 | Fedele または NetBox |
| API トークン | SoT はあるが、その資格情報プラグインがない場合。通常の出発点 |
C — 自己完結型 | ローカル YAML |
| 外部のものは不要 | ラボ、エアギャップ環境、デモ、または SoT がダウンした際の縮退モード |
netmiko.get_metadata で実際に実行中の形態を確認できます。設定ファイルから推測しないでください。
{
"inventory": {"backend": "fedele", "scope_filter": {"tag": "lab"}, "available": true},
"credential_source": "env",
"device_types_in_inventory": ["cisco_ios", "huawei_vrp", "…"]
}A — ソースオブトゥルースとして Fedele、資格情報も含む
エージェントはデバイスを 名前 で要求します。サーバーは呼び出し時に SoT に対してアドレス、プラットフォーム、資格情報を解決します。このプロジェクトには機器情報は一切保存されません。SoT にデバイスを追加すれば、ファイルを編集したり再起動したりすることなく、次の呼び出しから到達可能になります。
// .mcp.json → env
"NETMIKO_MCP_INVENTORY_TYPE": "fedele",
"NETMIKO_MCP_CREDENTIAL_SOURCE": "fedele",
"NETMIKO_MCP_FEDELE_GROUP_SOURCE": "tags", // tags | device_roles | sites
"NETMIKO_MCP_FEDELE_DEVICE_FILTER": "tag=lab", // the scope filter — read the warning
"NETMIKO_MCP_FEDELE_CACHE_TTL": "60"# .env
FEDELE_URL=https://fedele.example.com
FEDELE_TOKEN=<API token>
FEDELE_CREDENTIALS_KEY=<Fernet key of the fedele_credentials plugin>ファイル:必須のものはありません。commands.yml は 推奨 されますが、これがない場合でも組み込みの フォールバックポリシー が適用されます。ローカルインベントリは関与せず、NETMIKO_USERNAME / NETMIKO_PASSWORD も不要です。credential_source=fedele の場合、NETMIKO_SECRET は 無視 されます。イネーブルパスワードも SoT から取得されます。
資格情報参照の仕組み(3 段階):
GET dcim/devices/?name=<name> → device.id
GET plugins/credentials/devicecredentials/?device=<id> → credential id
GET plugins/credentials/networkcredentials/<id>/ → username + encrypted password
decrypted locally with the Fernet keyこの形態を選ぶ前に知っておくべきこと:
Fernet キーはセキュリティ全体の境界です。 サーバーのメモリ内でデバイスパスワードを復号化します。パスワードそのものと同様に扱ってください。
FEDELE_CREDENTIALS_KEYがない場合でもサーバーは起動しますが、すべての ツールが同じStartup Error(欠落変数名)を返します。静かに失敗するのではなく、明示的に失敗します。スコープフィルターを設定してください。
NETMIKO_MCP_FEDELE_DEVICE_FILTERがない場合、インベントリは SoT が認識している全機器、つまりエージェントが到達可能なすべてのデバイスになります。サーバーはこれがない場合に警告をログ出力します。フィルターはクエリ構文を受け付けます。tag=lab&status=active。primary_ipがないデバイス、platformがないデバイス、またはプラットフォームが Netmiko のdevice_typeでないデバイスは、インベントリから 除外 されます。SoT はカメラ、バッジリーダー、シャーシなども管理します。除外はカウントされ報告されるため、エージェントがサブセットに対して「これがすべてのデバイスです」と主張することはありません。サーキットブレーカーがあります。トランスポートエラーまたは 5xx エラーが発生すると、クライアントは 30 秒間 SoT への呼び出しを停止します。SoT がダウンしている状態で 40 台のデバイスに対してグループコマンドを実行した場合、40 回ではなく 1 回だけ失敗します。
B — インベントリは SoT、資格情報は .env
A と同じですが、1 つの変数が異なります。
"NETMIKO_MCP_CREDENTIAL_SOURCE": "env",# .env
FEDELE_URL=https://sot.example.com
FEDELE_TOKEN=<API token>
NETMIKO_USERNAME=<service account>
NETMIKO_PASSWORD=<password>
NETMIKO_SECRET=<enable password, if any device asks for it>動的なインベントリ(それ自体で価値がある部分)を、資格情報プラグインや Fernet キーなしで利用できます。すべてのデバイスに対して 1 つのサービスアカウントが使用されます。
NetBox、または NetBox 形状の SoT
インベントリバックエンドは NetBox REST の方言を話すため、NetBox 自体もこの形態でそのまま動作します。
バックエンドが呼び出すもの | 読み取る内容 |
| デバイスリスト。スコープフィルターでフィルタリングされ、ページネーションされます |
|
|
| SSH ホスト、マスクは除去 |
| Netmiko の |
FEDELE_URL を NetBox インスタンスに向け(/api を付けなくても自動で追加されます)、FEDELE_TOKEN を NetBox の API トークンに設定します。クライアントは NetBox が期待する Authorization: Token … ヘッダーで認証します。変数名は FEDELE_ プレフィックスを保持しています。これは命名上の遺産であり、製品要件ではありません。
NetBox がデフォルトで満たさない 1 つの要件:platform.name は Netmiko の device_type と完全に一致する必要があります — cisco_ios、arista_eos、huawei_vrp、juniper_junos。"Cisco IOS 15.2" という名前のプラットフォームは device_type ではないため、それを設定されたすべてのデバイスはインベントリから除外されます。NetBox 内のプラットフォーム名を変更するか、除外を受け入れてください。除外は報告されます。
資格情報は NetBox が カバーしない 部分です。plugins/credentials/… エンドポイントは Fedele のプラグインに属します。プレーンな NetBox では形態 A は利用できません。B を利用してください。
C — 自己完結型:SoT なし
すべてがこのプロジェクト内に存在します。外部サービスへの問い合わせは一切行われません。
// .mcp.json → env
"NETMIKO_MCP_INVENTORY_TYPE": "yaml",
"NETMIKO_MCP_CREDENTIAL_SOURCE": "env",
"NETMIKO_MCP_INVENTORY_FILE": "/abs/path/claude-project/config/netmiko/inventory.yml"# .env
NETMIKO_USERNAME=<service account>
NETMIKO_PASSWORD=<password>
NETMIKO_SECRET=<enable password, if any device asks for it>ファイル: inventory.yml はここで必須です — デバイスが存在する唯一の場所です。commands.yml は引き続き推奨ですが、必須ではありません。インベントリは netmiko_tools 形式です — 名前と接続データのフラットなマッピングに、グループキーが加わります:
CORE-RTR-01:
device_type: cisco_xr # must be a Netmiko device_type, verbatim
host: 192.0.2.11
CORE-SW-01:
device_type: arista_eos
host: 192.0.2.21
core: # a group is a list of device names
- CORE-RTR-01
- CORE-SW-01このプロジェクトが同梱するファイルはサンプルデータです: RFC 5737 のドキュメント用レンジ上の12の架空のデバイス、7つのグループ、そして許可リストに記載されているすべてのCLIダイアレクトが網羅されるように選ばれたプラットフォームです。実際の環境に置き換えてください。
これはこのプロジェクトが設定済みで出荷するフレーバーであり、同時に縮退モードでもあります: SoTがダウンした場合、2つの変数と再起動でフレーバーAまたはフレーバーBのデプロイをここに移行できます。これは必要になる前に練習しておく価値があります。
代償として、ファイルは古くなります。親リポジトリの scripts/export_inventory.py がSoTから再生成します; 定期的に実行してください。6ヶ月前のアドレスが入ったバックアップインベントリは、バックアップがないより悪いです。なぜなら、運用中に気づくからです。
3つすべてで変わらないもの
コマンドポリシー、監査証跡、出力ページング、ツールサーフェスはフレーバー間で変わりません。エージェントから見える契約は同一であり、そのためスキルにフレーバーごとのバリエーションは必要ありません。
commands.yml は推奨、必須ではない
サーバーはこれなしでも動作します。ファイルがない場合、すべてを拒否したり、起動を拒否したりはしません: 組み込みのフォールバックとして16の読み取り専用コマンドが代わりに使用されます — show version、show ip interface brief、display version およびそれらのJunos/VRP相当品です。これは意図的です。空のポリシーはサーバーが正常と報告している間にすべてのコマンドを拒否することになり、オペレーターには「デバイスが拒否した」ではなく「誰もポリシーを書かなかった」と読まれます。フォールバックは起動時に通知され、netmiko.get_command_policy は policy_source: "fallback" を報告し、監査対象の試行はすべてそのソースを保持します。
つまり、このファイルはポリシーの決定であり、インストール手順ではありません: フォールバックにより初回起動でサーバーを実行でき、環境独自のポリシーを保守的なデフォルトの代わりに使いたいときに commands.yml を書きます。できないのは、自分で選んでいないポリシーをそれと知らずに持つことです — サーバーは問い合わせがあるたびに、どのポリシーが有効かを伝えます。
.mcp.json ファイル
プロジェクトルートの .mcp.json は、このプロジェクト用の MCPサーバーを宣言します。Claude Codeはファイルを初めて見たときに承認を求め、このファイルはコミットされることを意図しています: チーム全員が同じサーバーを取得する方法です。
同じサーバー定義には他に2つのスコープがあります:
スコープ | 保存場所 | 参照者 |
| プロジェクトルートの | プロジェクトを開くすべての人(承認後) |
|
| そのユーザーのすべてのプロジェクト、そのマシン上 |
|
| そのユーザーのみ、そのプロジェクトのみ |
claude mcp add --scope project netmiko -- /path/to/python /path/to/server.py で project エントリが書き込まれます; JSONを手動で編集しても同じです。
ファイルの構造
{
"mcpServers": { // ← the top-level key. Not "servers", not "mcp".
"netmiko": { // ← the server name; it becomes the tool prefix
... // mcp__netmiko__<tool>
}
}
}サーバー名は見た目だけのものではありません: Claude Codeは各ツールを mcp__<server-name>__<tool-name> として公開します。名前が netmiko で、サーバーが登録するツールが netmiko.get_metadata の場合、Claudeが実際に認識するツールは mcp__netmiko__netmiko.get_metadata です。/mcp を実行して正確な名前を確認してから、allowed-tools リストや権限ルールに記述してください。
フィールドリファレンス
フィールド | トランスポート | 意味 |
| 両方 |
|
| stdio | 起動する実行可能ファイル。絶対パス — cwdを想定しない |
| stdio | 引数リスト、各要素は別々 |
| stdio | 子プロセスの環境。継承された環境にマージされる |
| http / sse | 完全なエンドポイントURL(パスを含む) |
| http / sse | 追加のリクエストヘッダー、通常は |
値は環境変数の展開をサポート: ${VAR} および ${VAR:-default}。トークンをコミットされたファイルから分離しておくのに便利です:
"headers": { "Authorization": "Bearer ${NETMIKO_MCP_TOKEN}" }トランスポート1 — stdio(このプロジェクトが使用するもの)
Claude Codeはサーバーを子プロセスとして起動し、そのstdin/stdoutを介してJSON-RPCで通信します。ポートをリッスンするものはなく、ネットワークから到達可能なものもなく、プロセスのライフタイムはセッションと同じです。これはSSH認証情報を保持するサーバーにとって適切なデフォルトです。
{
"mcpServers": {
"netmiko": {
"type": "stdio",
"command": "${CLAUDE_PROJECT_DIR:-.}/.venv/bin/python",
"args": ["${CLAUDE_PROJECT_DIR:-.}/mcps/mcp_server_netmiko.py"],
"env": {
"NETMIKO_MCP_INVENTORY_TYPE": "yaml",
"NETMIKO_MCP_INVENTORY_FILE": "${CLAUDE_PROJECT_DIR:-.}/config/netmiko/inventory.yml",
"NETMIKO_MCP_COMMAND_FILE": "${CLAUDE_PROJECT_DIR:-.}/config/netmiko/commands.yml",
"NETMIKO_MCP_CREDENTIAL_SOURCE": "env",
"NETMIKO_MCP_SAVE_OUTPUT_DIR": "${CLAUDE_PROJECT_DIR:-.}/mcpr/netmiko",
"NETMIKO_MCP_AUDIT_LOG_FILE": "${CLAUDE_PROJECT_DIR:-.}/logs/netmiko-audit.jsonl",
"LOG_FILE": "${CLAUDE_PROJECT_DIR:-.}/logs/netmiko-mcp.log",
"LOG_LEVEL": "INFO"
}
}
}
}注意すべき2つの点:
ハードコードされたパスは使わない、そしてワーキングディレクトリは信頼できるものではありません。
${CLAUDE_PROJECT_DIR:-.}がファイルをそのままコミット可能に保つものです; 次のセクションが全容です。なぜなら、その明白な読み方は間違っているからです。サーバーはstdoutに書き込んではいけません。 stdout は プロトコルチャネルであり、1行の余計な出力がセッションを壊します。ログはstderrと、
LOG_FILEのローテーションファイル(5 MB × 3、0600で作成 —DEBUGではこのファイルにデバイス出力が含まれます)に出力されます。Niko内部では同じ変数がMCPLoggingによって処理されます。
${CLAUDE_PROJECT_DIR:-.} の由来
1つの文字列に2つの別々のもの: 構文と変数。
構文。 ${VAR} と ${VAR:-default} はPOSIXパラメータ置換です(「VAR を使用; 未設定または空の場合は default を使用」)が、シェルは関与しません — JSONファイルがシェルを通過することはありません。Claude Codeはファイルを読み込む際に、command、args、env、url、headers でこの展開を自身で実装します。これはそのクライアントの慣習であり、MCP仕様の一部ではありません: 他のクライアントは実装していない可能性があり(Claude以外のエージェントを参照、その場合はパスをリテラルにする必要があります)、VS Codeには独自の表記 $ {workspaceFolder} があります。
変数。 CLAUDE_PROJECT_DIR はClaude Codeによってプロジェクトルートに設定され、フックが受け取るのと同じ値です。これは安定しています — セッション中に --add-dir で追加のワーキングディレクトリを許可しても、この値は変わりません。
直感に反する部分、そして :-. が飾りではない理由: Claude Codeはその変数を自身の環境ではなく、起動するサーバーの環境に設定します。しかし展開は起動前に、Claude Codeの環境に対して行われます — そこには変数は存在しません。そのため、裸の ${CLAUDE_PROJECT_DIR} は何も展開されず、/config/netmiko/inventory.yml というファイルシステムのルートへの絶対パスになってしまいます。
したがって、プロジェクトスコープの .mcp.json では、デフォルトはエッジケースのフォールバックではなく、毎回使用される値です。プロセスに渡されるのは ./config/netmiko/inventory.yml です。唯一の例外はプラグインによって提供されるMCP設定です — その場合、Claude Codeは変数を直接置換し、デフォルトは不要です。
これがサーバーの手を縛るものです。相対パスは子プロセスのcwdに対して解決され、cwdはクライアントの選択であり、プロジェクトのものではありません。したがって resolve_project_path(): すべての相対パス設定は、設定が読み込まれるときに PARENT_DIR(mcps/ の親、.env が存在するのと同じルート)に固定されます。どこから起動されたセッションでも config/netmiko/ を見つけ、validate_startup() はファイルがない場合に絶対パスを表示します。~ は依然としてオペレーターのホームを意味し、プロジェクト内のファイルではありません。
この変数は、ドキュメントが意図する方法で、サーバー内部から(os.environ["CLAUDE_PROJECT_DIR"])読み取る場合に依然として有用です。このサーバーはそれを必要としません: PARENT_DIR は __file__ から導出されるため、クライアントにまったく依存しません — 同じ理由で、誰もその変数を設定しないHTTPトランスポートでは特別な処理が不要です。
出典: Claude Code — MCP、セクション Add a local stdio server および Environment variable expansion in .mcp.json。
トランスポート2 — HTTP(ストリーミング可能HTTP)
Claude Codeはこれをサポートしており、他のMCPクライアントも同様です。これはサーバーが別の場所で動作する場合に使用するトランスポートです: 別のホスト、コンテナ、複数のエージェントで共有されるサービス、またはClaude以外のエージェント。
サーバーファイルは常に __main__ ガードの下で mcp.run(transport="stdio") を呼び出すため、HTTPは代わりにFastMCP CLIによって提供されます — コードの変更は不要です:
.venv/bin/fastmcp run mcps/mcp_server_netmiko.py \
--transport http --host 127.0.0.1 --port 8123
# endpoint: http://127.0.0.1:8123/mcp/NETMIKO_MCP_* 変数はクライアント設定の一部ではなくなりました: サーバープロセスはあなたが起動するため、それらはその環境(シェルのexport、systemdユニット、コンテナの environment: ブロック)に属します。
クライアント側:
{
"mcpServers": {
"netmiko": {
"type": "http",
"url": "http://127.0.0.1:8123/mcp/",
"headers": {
"Authorization": "Bearer ${NETMIKO_MCP_TOKEN}"
}
}
}
}または、同等に claude mcp add --transport http netmiko http://127.0.0.1:8123/mcp/。
--transport sse と "type": "sse" も機能します; SSEは古いリモートトランスポートであり、ストリーミング可能HTTPに移行していないクライアントのために維持されています。
セキュリティ。 FastMCP CLIはこれを認証なしで提供します: ポートに到達できる者は誰でも、サーバーの環境にある認証情報を使用して、インベントリ内のすべてのデバイスに対してshowコマンドを実行できます。ローカルテストの場合は
127.0.0.1にバインドし、共有するものについては、TLSを終端しAuthorizationヘッダーをチェックするリバースプロキシの背後に配置してください。上記のheadersブロックはクライアントが送信するものです; プロキシがそれを検証する必要があります。
Claude以外のエージェント
ここに示されている mcpServers オブジェクトは事実上の形状です: Claude Code、Claude Desktop、Cursor、Windsurfはすべて、stdio用に同じ3つのフィールド(command / args / env)を、リモート用に同じ2つのフィールド(url / headers)を読み取ります。エントリをそれらの間でコピーしても、通常はそのまま動作します。
コピーする前に確認すべき既知の違い:
VS Code は
mcp.jsonを使用し、トップレベルのキーが"mcpServers"ではなく"servers"であり、"type"を明示的に指定する必要があります。一部のクライアントは
${VAR}展開を実装していません; その場合、値はリテラルでなければならず、これはコミットされたファイルにトークンを貼り付けるよりも、HTTPトランスポートとプロキシの組み合わせを支持する根拠となります。設定ファイルがまったくないエージェントでも、HTTPエンドポイントに直接通信できます — URLと
Authorizationヘッダーが契約のすべてです。
env ブロック
NETMIKO_MCP_* エントリは、YAML設定ファイルよりも優先されます。これらは明示的に設定されています。なぜなら、Nikoの外部には NikoPaths がないため、デフォルトは ~/commands.yml と ~/.netmiko_mcp_tmp にフォールバックするからです。
ここでのすべてのパスはプロジェクトルートからの相対パスで記述できます: サーバーは設定読み込み時に相対パスを PARENT_DIR に固定するため、起動されたプロセスのcwdがインベントリや監査証跡の場所を決定することはありません。絶対パスまたは ~ はそのまま解釈されます。
変数 | デフォルト | 目的 |
|
|
|
| (netmiko-tools のルックアップ) | タイプが |
|
|
|
|
| グループを定義するもの: |
| (なし) | スコープフィルター、 |
|
| SoT 解決キャッシュの秒数 |
| Niko 外では | 許可/拒否リスト |
|
| コマンド内でのパイプを有効にする |
| (なし) | OpenSSH |
|
| グループコマンドでの同時接続数 |
| Niko 外では | 大規模出力のバッファ |
|
| この行数を超えると出力をインラインで返さずファイルに保存 |
| (親 README を参照) | 監査証跡(JSON、フェイルクローズ)。 |
|
| これらの設定を保持する YAML 設定ファイルへのパス |
|
| 運用ログ:常に stderr に出力、さらにこのローテーションファイル(5 MB × 3、 |
認証情報はここでは設定しません。NETMIKO_USERNAME、NETMIKO_PASSWORD、
NETMIKO_SECRET および FEDELE_* 変数は
<project-root>/.env から読み取られるため、コミットされた JSON ファイルに含まれることはありません。
優先順位:env ブロック内の値が .env の値より優先されます(黙示的に)。各変数は必ず一箇所でのみ定義してください。
その他の変数はすべて親リポジトリの README に記載されています。
動作確認
claude mcp list # netmiko: ✓ connectedセッション内で /mcp によりツール一覧が表示され、/skills によりスキルが読み込まれたことが確認できます。適用中のポリシーを尋ねると、netmiko.get_command_policy が読み取っているファイル名を返します。または "fallback" と報告された場合は、ファイルが見つからず、組み込みの 16 コマンドで動作していることを意味します。
著者: Ed Scrimaglia edgardo.scrimaglia@gmail.com — 最終更新日: 2026-08-18.
Available Tools
10 toolsnetmiko.get_command_policyA
List the commands this server will accept, and where that policy comes from.
CALL THIS AFTER A REFUSAL, BEFORE RETRYING. A Security Error: Command ... is not permitted means the command is outside the operator's policy. Do not guess a
variant and do not abbreviate — read the policy here, pick a command that is
actually allowed, and if nothing fits, tell the user which command was refused
and what the allow list does cover.
Also useful when the user asks what they can run on this deployment.
ANSWERING "which commands are available for Juniper / Huawei / Cisco": the lists
are flat, because the operator writes one policy for the whole estate. Filter it
yourself by dialect — you know the CLIs, and device_types_in_inventory tells
you which platforms are actually present. show route* and show chassis* are
Junos, display * is Huawei VRP and HPE Comware, show ip route is Cisco-style,
and show version happens to work on several. Under the fallback,
allowed_commands_by_platform already carries that split, verbatim and exact —
use it as given instead of re-deriving it. Two rules when you answer:
Never list a command that is not in
allowed_commands. It will be refused.Say when the answer is empty: an allow list written for one vendor covers nothing on another, and that is the operator's doing, not a device fault.
policy_source says who wrote the policy in force:
"file" — the operator's allow/deny list, at
command_file."fallback" — no policy file exists on this deployment, so only a small built-in read-only set runs.
warningexplains it; relay that to the user, because every other refusal follows from it and looks like a device problem otherwise.
How the lists are read (getting this wrong wastes attempts, and every attempt is audited):
Deny wins over allow, always.
The allow list does NOT cover abbreviations:
show versiondoes not permitsh ver. Send full commands.The deny list DOES cover abbreviations of the same word count: a deny on
configurealso blocksconf.*is a glob and only ever appears at the end.cmd*swallows whatever follows;cmd *requires at least one more word and does not matchcmdon its own.Anything the allow list does not name is denied.
Returns:
str: JSON with policy_source, command_file, allowed_commands,
denied_commands, their counts, a rules object,
device_types_in_inventory, and — only under the fallback —
allowed_commands_by_platform and a warning.
Inputs: no named parameters. Returns: result
netmiko.get_metadataA
Return authoritative metadata about the Netmiko MCP server and its inventory.
MANDATORY — call this tool FIRST on EVERY user message that mentions, asks about, or relates to network devices, routers, switches, firewalls, show commands, device inventory or device groups, before any other netmiko tool and before answering from memory, system prompt, or RAG/FAQ.
It reports which inventory backend is active (Fedele or the local YAML file) and, for the local file, how old it is. That matters: operating from a stale local inventory can send a command to the wrong box.
This tool does NOT reach any network device. For "is the MCP alive" call netmiko.health_check. To actually query a device, use netmiko.send_show_command.
Returns:
str: JSON with version, author, description, inventory, capabilities,
command_policy and tool_routing. command_policy is "file" when the
operator's allow/deny list is in force and "fallback" when no policy file
exists — in that case a warning field says so, only a handful of
read-only commands will be accepted, and you must relay that warning to
the user instead of treating the denials as device failures.
Inputs: no named parameters. Returns: result
netmiko.health_checkA
Check whether the Netmiko MCP server itself is responsive and correctly configured.
IMPORTANT: If the user message involves network devices, call netmiko.get_metadata FIRST.
This checks the MCP server, NOT any network device and NOT the inventory backend reachability. "¿Está arriba el router X?" is not this tool — that requires actually running a command against the device with netmiko.send_show_command.
Returns:
str: JSON with available, version, inventory_backend,
credential_source and command_policy ("file" or "fallback").
When command_policy is "fallback" a warning field explains that
no policy file exists and only built-in read-only commands run;
report that warning to the user.
Inputs: no named parameters. Returns: result
netmiko.list_device_outputsA
List the output files already saved on disk for a device, group, or all devices.
IMPORTANT: If the user message involves network devices, call netmiko.get_metadata FIRST.
Outputs land here when save_output=True was used or when a command exceeded save_threshold. Read them with netmiko.read_device_output.
Inputs: device_or_group (required). Returns: result
netmiko.list_devicesA
List devices from the inventory, without credentials.
IMPORTANT: If the user message involves network devices, call netmiko.get_metadata FIRST.
Use this to discover exact device names before running a command. Device names are the only handle the other tools accept — never pass an IP address or a hostname you inferred.
Inputs: device_or_group. Returns: result
netmiko.list_groupsA
List every device group defined in the inventory.
IMPORTANT: If the user message involves network devices, call netmiko.get_metadata FIRST.
Groups are what netmiko.send_show_command_to_group accepts. Call this before assuming a group name exists — never invent one.
Returns:
str: JSON with groups (list of group-name strings) and count.
Inputs: no named parameters. Returns: result
netmiko.query_audit_trailA
Read the audit trail: what this server was asked to do, and what happened.
Answers questions about PAST activity — "everything done on SW-CORE-01", "the last 6 netmiko actions", "which commands were refused this week", "who touched that switch and with which credential". It reads the audit records only; it never opens a connection and never returns device output.
Every argument is a filter, combined with AND. Leave one empty to not filter on it. Translate what the user asked into these arguments — do not ask for everything and sift through it.
The audit trail rotates daily and this reads the rotated files too, but only
what is still on disk. files_scanned and oldest_available in the response
say how far back the answer actually reaches: if the period the user asked
about is older than that, say so instead of reporting "nothing happened".
matched is how many records satisfied the filters; returned is how many
came back in this call. When they differ, the response is one page — never
report returned as a total.
Calling this tool writes a tool_invocation record of its own — reading the
trail is itself auditable — but those records are hidden from the results by
default, so "the last 6 actions" is about the network and not about your own
questions. audit_queries_hidden says how many were left out.
Inputs: tool, event, limit, order, +10 more. Returns: result
netmiko.read_device_outputA
Read a previously saved output file for one device, with pagination.
IMPORTANT: If the user message involves network devices, call netmiko.get_metadata FIRST.
The response header states the line range and the total line count. When lines remain, a continuation hint gives the offset to use next. Do not report a total based on a page you have not finished reading.
Inputs: filename (required), device_name (required), limit, offset. Returns: result
netmiko.send_show_commandA
Connect to one network device over SSH and run a single show command.
IMPORTANT: If the user message involves network devices, call netmiko.get_metadata FIRST.
The command is validated against the operator's allow/deny list before execution. A rejection is NOT a bug and NOT something to work around: report it to the user and say which command was refused. Do not retry with an abbreviation — abbreviations are covered by the deny list, not by the allow list.
SYNTAX IS PER-PLATFORM. Netmiko drives 177 base device_types (416 with variants)
from 102 vendors and their CLIs are NOT interchangeable. Check the device's
device_type with netmiko.list_devices first and use that platform's syntax:
Cisco IOS/Arista/Juniper use show ..., Huawei VRP and HPE Comware use
display ..., MikroTik RouterOS uses /system resource print, F5 tmsh uses
list/show with its own grammar. Never translate a command from one family
to another by analogy, and never probe variants to see which one is accepted —
each attempt is audited and may be denied for a different reason.
Inputs: command (required), device_name (required), save_output, use_textfsm. Returns: result
netmiko.send_show_command_to_groupA
Run the same show command concurrently on every device of a group.
IMPORTANT: If the user message involves network devices, call netmiko.get_metadata FIRST.
The command is validated once before any connection is opened, so a denied command reaches no device at all. Per-device failures are returned per device: a partial result is normal and must be reported as partial, never summarised as if every device answered.
A GROUP MAY MIX PLATFORMS. The same command string is sent to every member, so a
group holding both Cisco IOS and Huawei VRP devices will fail on half of them
whatever you send — show version is invalid on VRP, display version is invalid
on IOS. Check device_type across the group with netmiko.list_devices first; if
the group is heterogeneous, issue one netmiko.send_show_command per platform
instead of forcing a single string onto all of them.
Inputs: command (required), device_or_group (required), save_output, use_textfsm. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool targets a clear resource and action, and the descriptions explicitly define when each should be used. get_metadata and health_check overlap somewhat since both report server configuration details, but their distinct purposes are clearly explained.
Most names follow a consistent verb_noun pattern such as list_devices, send_show_command, and query_audit_trail. health_check is the main deviation, being a noun phrase rather than a verb-led name, but the overall pattern remains predictable.
10 tools is well within the ideal scope for a network automation server. Each tool earns its place by covering a distinct function: metadata, policy, health, inventory, command execution, output retrieval, and auditing.
The tool set covers the full read-only operational workflow: discover devices and groups, check command policy, run show commands individually or to a group, list and read saved outputs, and query the audit trail. There are no obvious dead ends—every inventory and output listing has a corresponding consumption tool.
Maintenance
Related MCP Connectors
Read-only MCP access to a documented IT fleet: state, changes, posture. 15 tools.
Read-only Linux server and Docker monitoring for AI assistants: CPU, memory, disk, network.
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Cisco IOS-XE network devices over SSH using structured tools. Provides read and write capabilities for network management with built-in validation and security.-
- AlicenseAqualityDmaintenanceBridges AI agents with network infrastructure, enabling secure read-only access to multiple vendor routers via SSH for natural language queries and troubleshooting.5811 PyPI1MIT
- FlicenseAqualityDmaintenanceEnables LLMs to run read-only show commands on Cisco IOS/IOS-XE and Nexus switches over SSH, with a two-account model for privilege separation and a fail-closed allowlist for safety.25-
- AlicenseNot gradedqualityBmaintenanceProvides read-only, multi-vendor network device interaction, configuration auditing against vendor-guide rules, and safe diffing of proposed changes for AI agents to inspect and analyze network infrastructure without any commit or write capability.1Apache 2.0