<?xml version="1.0" encoding="UTF-8"?>
<!-- <?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?> -->
<rfc category="info" docName="draft-zeng-mcp-troubleshooting-00" ipr="trust200902" submissionType="IETF" xml:lang="en" version="3" xmlns:xi="http://www.w3.org/2001/XInclude">
  <front>
    <title abbrev="MCP for Networks">
      Using the Model Context Protocol (MCP) for Intent-Based Network Troubleshooting Automation
    </title>
    <seriesInfo name="Internet-Draft" value="draft-zeng-mcp-troubleshooting-00"/>
    <author fullname="Guanming Zeng" initials="G." surname="Zeng">
      <organization>Huawei</organization>
      <address>
        <email>zengguanming@huawei.com</email>
      </address>
    </author>
    <author fullname="Jianwei Mao" initials="J." surname="Mao">
      <organization>Huawei</organization>
      <address><email>maojianwei@huawei.com</email></address>
    </author>
    <date year="2025"/>
    <abstract>
      <t>The Model Context Protocol (MCP) is an open standard that enables Large Language Model (LLM) applications to seamlessly integrate with external data sources and tools by exposing Resources, Prompts and Tools in a JSON-RPC 2.0 transport. This document describes a mapping of MCP roles, primitives and security model to the network management domain so that network devices act as MCP servers and network controllers act as MCP clients. The goal is to provide an intent-based, conversational and secure approach for automated network troubleshooting, configuration validation, and closed-loop remediation without inventing new protocols or device agents.</t>
    </abstract>
  </front>
  <middle>
    <section anchor="intro" numbered="true" toc="default">
      <name>Introduction</name>
      <t>Network operators today face two converging demands: (1) reduce Mean Time to Repair (MTTR) while managing ever larger infrastructures, and (2) adopt intent-based interfaces that allow engineers to express high-level goals such as "verify reachability between Site-A and Site-B" instead of typing low-level CLI commands.</t>
      <t>Simultaneously, Large Language Models (LLMs) have demonstrated utility in reasoning about semi-structured data such as device logs, configurations, and command outputs. However, safely exposing device-level actions and data to an LLM in real time remains an open problem. The Model Context Protocol (MCP), developed by Anthropic and published at <eref target="https://modelcontextprotocol.io"/>, provides a lightweight, capability-oriented RPC layer that already addresses this problem for general LLM applications.</t>
      <t>This document specifies a deterministic mapping of MCP roles, primitives, and security workflows onto the network management plane so that:</t>
        <ul spacing="normal">
          <li>A network element (router, switch, firewall, etc.) becomes an "MCP server" that exposes management data and actions as MCP Resources, Prompts and Tools.</li>
          <li>A controller, orchestrator or chat-based assistant becomes an "MCP client" that consumes these primitives.</li>
          <li>Human operators interact with the controller using natural language; the controller translates the intent into a sequence of MCP calls, optionally consulting an LLM for reasoning.</li>
          <li>All interactions are subject to explicit user consent, audit, and capability-based access control, as mandated by MCP.</li>
        </ul>
      
      <t>The result is an intent-based, conversational and secure automation framework that re-uses existing agents (NETCONF/RESTCONF/YANG, SNMP, CLI, gNMI, etc.) already present on devices instead of requiring new firmware.</t>
    </section>

<section numbered="true" toc="default">
      <name>Terminology</name>
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.</t>
      <t>MCP terms such as "Tool", "Resource", "Prompt", "Client", "Server", "Host", and "Capability" are used as defined in the MCP specification dated 2025-06-18.</t>
      <t>Intent: A high-level, declarative statement of desired network behaviour, expressed in natural language or structured YAML/JSON, that the controller must translate into concrete device actions.</t>
    </section>

    <section anchor="arch" numbered="true" toc="default">
      <name>Architecture</name>
        <figure>
          <name>Reference Topology</name>
          <artwork><![CDATA[
   +----------------------------------+
   |  Human Operator (Chat UI, Web)   |
   +-----------------+----------------+
                     | Intent (natural lang.)
                     v
   +----------------------------------+
   |  Controller / Orchestrator       |
   |  (MCP Client + LLM Host)         |
   +-----------------+----------------+
                     | JSON-RPC 2.0 over TLS
                     v
   +----------------------------------+
   |  Network Device                  |
   |  (MCP Server)                    |
   +----------------------------------+
          ]]></artwork>
        </figure>

      <section anchor="roles" numbered="true" toc="default">
        <name>Role Allocation</name>
        <t>MCP Server: Runs on or proxied in front of the network element. Exposes: </t>
          <ul spacing="normal">
            <li>Resources: Read-only YANG datastores, syslog, tech-support</li>
            <li>Tools: Idempotent actions, e.g., "ping", "traceroute", "clear counters", "rollback config"</li>
            <li>Prompts: Re-usable prompt templates, e.g., "Diagnose BGP session down"</li>
          </ul>
        
        <t>MCP Client: Runs inside the controller. Maintains a persistent JSON-RPC 2.0 connection to each server. Optionally hosts an LLM that reasons about the data returned by servers.</t>
      </section>

      <section anchor="cap" numbered="true" toc="default">
        <name>Capability Negotiation</name>
        <t>On connection establishment, the client and server exchange capability objects as defined in MCP. Servers list their supported YANG modules <xref target="RFC8525"/>, CLI command sets, and Tool schemas encoded in OpenAPI 3.0. Clients list optional features such as "sampling" (LLM recursion) or "roots" (URI scoping).</t>
      </section>
    </section>

    <section anchor="mapping" numbered="true" toc="default">
      <name>Mapping of MCP Primitives to Network Management</name>

      <section anchor="res" numbered="true" toc="default">
        <name>Resources</name>
        <t>Resources are exposed under the URI scheme <tt>mcp://&lt;device&gt;/&lt;yang-module&gt;:&lt;path&gt;</tt>. Reading a resource returns YANG JSON-encoded data per <xref target="RFC7951"/>. Examples: </t>
          <ul spacing="normal">
            <li><tt>mcp://router1/ietf-interfaces:interfaces/interface=eth0</tt></li>
            <li><tt>mcp://router1/openconfig-bgp:bgp/neighbors/neighbor=1.1.1.1</tt></li>
          </ul>
        
        <t>Servers SHOULD support the "content-id" header to enable E-tags for caching.</t>
      </section>

      <section anchor="tools" numbered="true" toc="default">
        <name>Tools</name>
        <t>Tools are mapped to well-known RPC operations already exposed by devices via NETCONF/RESTCONF/YANG, gNMI, or CLI. A Tool is described by an OpenAPI 3.0 Operation Object and MUST be idempotent when possible.</t>
        <t>Example Tool schema (ping):</t>
          <figure>
            <name>Tool Schema Example</name>
            <artwork><![CDATA[
{
  "name": "ping",
  "description": "Execute ICMP echo probe",
  "inputSchema": {
    "type": "object",
    "properties": {
      "destination": { "type": "string" },
      "count":       { "type": "integer", "default": 5 },
      "source":      { "type": "string" }
    },
    "required": ["destination"]
  }
}
            ]]></artwork>
          </figure>
        
      </section>

      <section anchor="prompts" numbered="true" toc="default">
        <name>Prompts</name>
        <t>Prompts are reusable prompt templates stored on the device. They allow vendors or operators to encode golden troubleshooting workflows in natural language. A prompt MAY contain variable placeholders such as "{{interface}}" that the client fills in before sending to an LLM.</t>
      </section>

      <section anchor="sampling" numbered="true" toc="default">
        <name>Sampling (Optional)</name>
        <t>If the client advertises the "sampling" capability, the server MAY request LLM inference on behalf of the device. This is useful for recursive troubleshooting where the device needs to ask clarifying questions. All sampling requests MUST be approved by the human operator via explicit consent UI.</t>
      </section>
    </section>

    <section anchor="usecases" numbered="true" toc="default">
      <name>Example Use Cases</name>

<section anchor="uc1" numbered="true" toc="default">
  <name>Intent: "Verify reachability between Site-A and Site-B"</name>
  <t>The following steps illustrate the flow:</t>
  <ol spacing="normal">
    <li>Operator enters intent in chat UI.</li>
    <li>Controller's LLM deduces required Tools:
      − <tt>ping</tt> (Tool) from router1 to 10.2.2.2<br/>
      − <tt>show interfaces</tt> (Resource) on router2
    </li>
    <li>Controller issues MCP calls.</li>
    <li>Devices return results.</li>
    <li>LLM summarizes: "Packet loss 0%; MTU mismatch detected on router2 ge-0/0/0. Recommend 'set interfaces ge-0/0/0 mtu 1500'."</li>
  </ol>
</section>

      <section anchor="uc2" numbered="true" toc="default">
        <name>Intent: "Diagnose why BGP neighbor 1.1.1.1 is down"</name>
        <ol spacing="normal">
          <li>Controller retrieves:
              -<tt>/openconfig-bgp:bgp/neighbors/neighbor=1.1.1.1/state</tt>
              -<tt>/ietf-interfaces:interfaces/interface=loopback0</tt>
          </li>
          <li>Controller calls Tool "tcpdump" filtered on port 179.</li>
          <li>LLM correlates: "No TCP SYN received; ACL foo on interface loopback0 denies port 179."</li>
          <li>Controller offers one-click remediation: remove ACL entry.</li>
        </ol>
      </section>
    </section>

    <section anchor="transport" numbered="true" toc="default">
      <name>Transport &amp; Encoding Considerations</name>
      <t>JSON-RPC 2.0 is carried over TLS 1.3 <xref target="RFC8446"/> with TCP/443 or QUIC <xref target="RFC9000"/> as the underlying transport. Servers present X.509 device certificates; clients use mutual TLS with short-lived SPAKE2 <xref target="RFC9383"/> tokens to achieve zero-touch onboarding.</t>
      <t>YANG data is encoded in JSON <xref target="RFC7951"/> unless the client explicitly requests XML.</t>
      <t>Large tech-support files MAY be streamed via HTTP/2 chunked transfer and are integrity-protected by SHA-256 hashes delivered in the JSON-RPC result.</t>
      <t>Servers MAY support the MCP "progress" notification to report percentage completion for long-running Tools such as "tracepath".</t>
    </section>

    <section anchor="security" numbered="true" toc="default">
      <name>Security Considerations</name>
      <t>This section extends the security model defined in MCP with network-specific requirements.</t>

      <section anchor="consent" numbered="true" toc="default">
        <name>User Consent and Authorization</name>
        <t>All Tool invocations that change device state MUST be confirmed by an authenticated user via an out-of-band consent channel (e.g., click-through UI or signed JWT). The consent object includes:</t>
          <ul spacing="normal">
            <li>Tool name and parameter values</li>
            <li>Estimated impact window (rollback timer)</li>
            <li>User identity and role</li>
            <li>Signed timestamp</li>
          </ul>
        
      </section>

      <section anchor="tokens" numbered="true" toc="default">
        <name>Least-Privilege Capability Tokens</name>
        <t>Servers issue short-lived OAuth 2.0 <xref target="RFC6749"/> access tokens scoped to individual YANG subtrees or Tools. Tokens are bound to the mutual TLS channel to prevent replay.</t>
      </section>

      <section anchor="llmiso" numbered="true" toc="default">
        <name>LLM Isolation</name>
        <t>When the controller hosts an LLM, the LLM is placed in a sandbox with no direct layer-3 reachability to devices. All interactions MUST traverse the MCP client to mitigate prompt-injection attacks.</t>
      </section>

      <section anchor="audit" numbered="true" toc="default">
        <name>Audit and Post-Mortem</name>
        <t>Every JSON-RPC request and response is appended to an immutable audit trail (e.g., syslog <xref target="RFC5424"/> or IETF syslog over TLS). Servers include a "session-id" field to allow cross-device correlation.</t>
      </section>

      <section anchor="privacy" numbered="true" toc="default">
        <name>Privacy</name>
        <t>Resources containing customer data (e.g., DPI logs) are redacted by default. Servers expose a "privacy-level" capability; clients request explicit user consent before retrieving level-3 data.</t>
      </section>
    </section>

    <section anchor="iana" numbered="true" toc="default">
      <name>IANA Considerations</name>
      <t>This document requests IANA to register the following well-known URI:</t>
      <ul spacing="normal">
        <li>URI suffix: mcp</li>
        <li>Description: Model Context Protocol over TLS</li>
        <li>Reference: This document</li>
      </ul>
      <t>Additionally, the YANG module "ietf-mcp" is requested to be added to the IETF YANG module registry with namespace "urn:ietf:params:xml:ns:yang:ietf-mcp".</t>
    </section>
      </middle>

    <back>
    <references title="Normative References">
      <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
        <front>
          <title>Key words for use in RFCs to Indicate Requirement Levels</title>
          <author initials="S." surname="Bradner"/>
          <date year="1997"/>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="2119"/>
      </reference>

      <reference anchor="RFC7951" target="https://www.rfc-editor.org/info/rfc7951">
        <front>
          <title>JSON Encoding of Data Modeled with YANG</title>
          <author initials="L." surname="Lhotka"/>
          <date year="2016"/>
        </front>
        <seriesInfo name="RFC" value="7951"/>
      </reference>

      <reference anchor="RFC8446" target="https://www.rfc-editor.org/info/rfc8446">
        <front>
          <title>The Transport Layer Security (TLS) Protocol Version 1.3</title>
          <author initials="E." surname="Rescorla"/>
          <date year="2018"/>
        </front>
        <seriesInfo name="RFC" value="8446"/>
      </reference>

      <reference anchor="RFC9000" target="https://www.rfc-editor.org/info/rfc9000">
        <front>
          <title>QUIC: A UDP-Based Multiplexed and Secure Transport</title>
          <author initials="J." surname="Iyengar"/>
          <author initials="M." surname="Thomson"/>
          <date year="2021"/>
        </front>
        <seriesInfo name="RFC" value="9000"/>
      </reference>
    

    <!-- 加到 <back> 内的 <references> 区域，放在已有引用之后即可 -->
<reference anchor="RFC8174" target="https://www.rfc-editor.org/info/rfc8174">
  <front>
    <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
    <author initials="B." surname="Leiba"/>
    <date year="2017"/>
  </front>
  <seriesInfo name="BCP" value="14"/>
  <seriesInfo name="RFC" value="8174"/>
</reference>

<reference anchor="RFC8525" target="https://www.rfc-editor.org/info/rfc8525">
  <front>
    <title>YANG Library</title>
    <author initials="A." surname="Bierman"/>
    <author initials="M." surname="Bjorklund"/>
    <author initials="K." surname="Watsen"/>
    <date year="2019"/>
  </front>
  <seriesInfo name="RFC" value="8525"/>
</reference>

<reference anchor="RFC5424" target="https://www.rfc-editor.org/info/rfc5424">
  <front>
    <title>The Syslog Protocol</title>
    <author initials="R." surname="Gerhards"/>
    <date year="2009"/>
  </front>
  <seriesInfo name="RFC" value="5424"/>
</reference>

<reference anchor="RFC6749" target="https://www.rfc-editor.org/info/rfc6749">
  <front>
    <title>The OAuth 2.0 Authorization Framework</title>
    <author initials="D." surname="Hardt"/>
    <date year="2012"/>
  </front>
  <seriesInfo name="RFC" value="6749"/>
</reference>

<reference anchor="RFC9383" target="https://www.rfc-editor.org/info/rfc9383">
  <front>
    <title>SPAKE2+, an Augmented Password-Authenticated Key Exchange (PAKE) Protocol</title>
    <author initials="M." surname="Sethi"/>
    <author initials="R." surname="Struik"/>
    <date year="2023"/>
  </front>
  <seriesInfo name="RFC" value="9383"/>
</reference>

</references>

    <references title="Informative References">
        <name>Informative References</name>
        <reference anchor="MCP-SPEC">
        <front>
          <title>Model Context Protocol Specification 2025-06-18</title>
          <author><organization>Anthropic</organization></author>
          <date year="2025"/>
        </front>
        <seriesInfo name="URL" value="https://modelcontextprotocol.io/specification/2025-06-18/basic"/>
      </reference>
    </references>


    <section anchor="app-examples" numbered="true" toc="default">
      <name>JSON-RPC Examples</name>

      <section anchor="ex-ping" numbered="true" toc="default">
        <name>Client Call: ping</name>
        <figure>
          <name>ping Request and Response</name>
          <artwork><![CDATA[
--> {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "tools/call",
      "params": {
        "name": "ping",
        "arguments": {
          "destination": "10.2.2.2",
          "count": 5,
          "source": "192.0.2.1"
        }
      }
    }

<-- {
      "jsonrpc": "2.0",
      "id": 1,
      "result": {
        "loss": 0,
        "rtt": { "min": 2.1, "max": 2.3, "avg": 2.2 }
      }
    }
          ]]></artwork>
        </figure>
      </section>

      <section anchor="ex-sub" numbered="true" toc="default">
        <name>Server Resource Subscription</name>
        <figure>
          <name>Resource Subscribe Example</name>
          <artwork><![CDATA[
--> {
      "jsonrpc": "2.0",
      "id": 2,
      "method": "resources/subscribe",
      "params": {
        "uri": "mcp://router1/ietf-interfaces:interfaces/interface=eth0",
        "content-id": "etag-1234"
      }
    }

<-- {
      "jsonrpc": "2.0",
      "id": 2,
      "result": {
        "subscription-id": "sub-42",
        "initial": { "admin-status": "up", "oper-status": "up" }
      }
    }
          ]]></artwork>
        </figure>
      </section>
    </section>

  </back>
</rfc>