Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Query Routing Director Using MCP

This topic describes how to use Model Context Protocol (MCP) to query Routing Director.

MCP Server Overview and Implementation

Juniper Routing Director leverages the Model Context Protocol (MCP) to establish a secure connection with AI agents such as Microsoft Copilot, ChatGPT, and Claude. By using an MCP server:

  • Network operators can use AI agents to query Routing Director.

  • AI agents can access Routing Director as a data source and provide network operators with accurate, context‑aware responses to queries.

Figure shows an overview of the interaction of a user with Routing Director through the MCP server.

Figure 1: MCP Server Overview MCP Server Overview

You interact with an MCP host application, which could be an AI-powered interface (for example, Claude, or ChatGPT), where you enter your natural language queries. The MCP host application includes an MCP client that communicates with one or more MCP servers. The MCP servers run independently and provide access to tools, data, or services.

The MCP host application also connects to an LLM which may run either on-premise or in the cloud. The LLM interprets user requests and, through the MCP client present within the host application, communicates with the MCP server. The MCP server acts as a bridge between the MCP host application and Routing Director, exposing various tools and APIs to retrieve device information, alerts, and performance data. The MCP server also executes configuration commands and operational tasks by interfacing with Routing Director through APIs.

The MCP package is stored in the GitHub repository as an open source code under https://github.com/Juniper/routing-director-mcp-server and distributed through the MCP registry.

Benefits

  • The MCP server helps network operators to query network data, create dashboards, and access KPIs conversationally instead of writing code or learning complex API syntax.
  • The MCP Server enhances the troubleshooting experience by enabling network administrators to access Troubleshooting guides and execute commands on devices to remediate issues without switching tools.

Deploy an MCP Server

The following are the pre-requisites to deploy an MCP server on a host (for example, your laptop):

  • Python versions 3.10 or 3.11.

  • Access to Routing Director with valid UI authentication credentials (username and password or API token)

  • Reachability to Routing Director API

  • Create a Python virtual environment to install packages required for running the MCP server.

The following are the steps to deploy an MCP Server:

  1. Download the MCP package from the GitHub MCP repository and the official MCP registry.

    The source code is maintained in GitHub repository under https://github.com/Juniper/routing-director-mcp-server.

  2. In a Python virtual environment, install all requirements defined in the requirement.txt file from the MCP package by using pip3 install -r requirements.txt.

  3. Create the MCP server configuration file (config.json).

    The configuration file specifies how to reach Routing Director, how to authenticate, and which component APIs to expose as tools for querying Routing Director. The following is a sample of the configuration file:

    The following is a sample MCP server configuration file:

    Where,

    • http_url is the base URL of Routing Director.

    • org_id is the unique Identifier of the organization in Routing Director that you want to query.

    • auth defines the authentication. Define the following under auth:

      • type—authentication method to connect to Routing Director. It can take the values—basic or token

        If you enter basic, enter values for:

        • username—Username to access Routing Director.

        • password—Password for the username.

        If you enter token, enter an API token generated by Routing Director. For example:

        For generating API tokens in Routing Director, see Manage API Tokens.

    • components is the list of Routing Director components that can be queried. Components can take one of the following values:

      • ems—Use the ems component to search, acknowledge or unacknowledge alarms reported on Routing Director.

      • juniper-resiliency-interface—Use the juniper-resiliency-interface component to fetch forwarding, routing, and OS exception events generated by Juniper Resiliency Interface (JRI) and collected by Routing Director.

      • device-kpi—Use the device-kpi component to retrieve device system log messages that are collected by Routing Director.

      components is an optional parameter. If components is not defined, all the components are considered.

  4. (Optional) Enable authentication between MCP server and MCP client.

    You can use file-based token authentication for communication between an MCP client and MCP server. To generate a token, execute the following command in the virtual environment where the MCP server is deployed:

    Where, client-id is an ID that you use for generating the authentication token.

    The following is a sample of the generated output:Save the generated token in a .tokens file. By default, the token is saved in the root directory of the GitHub MCP repository.
  5. Start the MCP server.

  6. Configure an AI agent within the MCP host application to communicate with the MCP Server through the MCP client. See Configure an AI Agent to Communicate with the MCP Server.

    The MCP client can use either stdio or streamable-http as a transport mechanism to communicate with the MCP server.

You can now query data from Routing Director by using an MCP host application such as Microsoft Copilot or ChatGPT.

Configure an AI Agent to Communicate with the MCP Server

After the MCP server is configured, you must configure an AI agent present in the MCP host application to communicate with the MCP server. You can configure the MCP server connection in the MCP host application'ss settings. This section provides the steps to configure connection to the MCP server through Claude and Copilot.

Configure Claude

To configure Claude:

  1. Open the Claude configuration file in a text editor.

    • On a macOS machine, run the following command in the Terminal:

    • On a Windows machine, open command prompt and enter:

  2. Add your MCP server configuration as shown below:

  3. Save the file.

  4. Restart Claude.

  5. Verify the connection of Claude with MCP server.

    Claude is connected to the MCP server if the MCP server tools (API Calls) are listed under + > Connectors.

    Alternatively, you can view MCP server tools (API calls) listed in VS code Extensions.

    To ensure that the MCP server has started correctly, view the MCP server logs. The logs are generated based on the type of communication with the AI agent:

    • Starting MCP server 'Juniper Routing Directory' with transport 'stdio' if stdio is used.

    • INFO Starting MCP server 'Juniper Routing Directory' with transport 'http' on http://127.0.0.1:30030/mcp if streamable-http is used.

Configure Copilot

To configure Copilot:

  1. Open Virtual Studio (VS) code.

    Alternatively, you can use any other Integrated Development Environment (IDE) that supports Copilot and MCP server,

  2. Open the MCP settings file using one of the following methods:

    • On a macOS, run the following command in the Terminal:

      Where, user is your username on the macOS machine.

    • On a Windows machine, open command prompt and enter:

      Where, user is your username on the Windows machine.

  3. Add the MCP server configuration to the settings file as shown below:

    Where,

  4. Save the file.

  5. Close and reopen VS code for the MCP configuration changes to take effect.

  6. Verify that Copilot is connected with the MCP server.

    Copilot is connected to the MCP server if you find messages indicating successful connection to the MCP server in the Output panel of VS code.

    Alternatively, you can view MCP server tools (API calls) listed in VS code Extensions.

    To ensure that the MCP server has started correctly, view the MCP server logs. The logs are generated based on the type of communication with the AI agent:

    • Starting MCP server 'Juniper Routing Directory' with transport 'stdio' if stdio is used.

    • INFO Starting MCP server 'Juniper Routing Directory' with transport 'http' on http://127.0.0.1:30030/mcp if streamable-http is used.