HG

higress-group/higress-ops-mcp-server

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

23 stars 8 forks 品質 36 トレンド 10

Higressの包括的な構成と管理を可能にするモデルコンテキストプロトコル(MCP)サーバーの実装.

概要

Higressの包括的な構成と管理を可能にするモデルコンテキストプロトコル(MCP)サーバーの実装。 このリポジトリは、LangGraph および LangChain MCP アダプターの上に構築された MCP クライアントも提供し、設計済みのエージェントフローアーキテクチャにより、Higress MCP Server との相互作用を促進します。 [https://github.com/user-attachments/assets/bae66b77-a158-452e-9196-98060bac0df7] .env.example ファイルを .env にコピーし、対応する値を入力します。 stdio モードでは、MCP サーバプロセスが MCP クライアントプログラムによって開始されます。 MCP クライアントと MCP サーバを起動するには、次のコマンドを実行します。 - まったく新しいツールカテゴリを追加すると、ツールディレクトリに新しいファイルを作成する - 既存のカテゴリに収まると、既存のクラスにツールを追加 - API 呼び出しをカプセル化するutils/higress client.py にメソッドを追加 - 既存の HTTP メソッド (get, put, post) を実際の API 通信に使用する - ツールクラスをサーバーのtool classesリストに追加します.

概要(AI 翻訳)

Higressの包括的な構成と管理を可能にするモデルコンテキストプロトコル(MCP)サーバーの実装。 このリポジトリは、LangGraph および LangChain MCP アダプターの上に構築された MCP クライアントも提供し、設計済みのエージェントフローアーキテクチャにより、Higress MCP Server との相互作用を促進します。

デモ

[https://github.com/user-attachments/assets/bae66b77-a158-452e-9196-98060bac0df7]

環境変数の設定

.env.exampleファイルを.envにコピーし、対応する値を入力します。

MCP クライアントと MCP サーバーの開始

stdio モードでは、MCP サーバプロセスが MCP クライアントプログラムによって開始されます。 MCP クライアントと MCP サーバを起動するには、次のコマンドを実行します。

新しいツールを追加

ステップ1:新しいツールクラスを作成するか、既存のツールを拡張する

  • まったく新しいツールカテゴリを追加すると、ツールディレクトリに新しいファイルを作成する
  • 既存のカテゴリに収まると、既存のクラスにツールを追加するか

手順 2: ツールがHigress Console APIとやり取りする必要がある場合、HigressClientに新しいメソッドを追加します

  • API 呼び出しをカプセル化するutils/higress client.py にメソッドを追加する
  • 既存のHTTPメソッド(get, put, post)を実際のAPI通信に使用する

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

Higress OPS MCP Server

A Model Context Protocol (MCP) server implementation that enables comprehensive configuration and management of Higress. This repository also provides an MCP client built on top of LangGraph and LangChain MCP Adapters, facilitating interaction with the Higress MCP Server through a well-designed agent flow architecture.

Demo

https://github.com/user-attachments/assets/bae66b77-a158-452e-9196-98060bac0df7

Config Environment Variables

Copy the .env.example file to .env and fill in the corresponding values.

Start MCP Client and MCP Server

In stdio mode, the MCP server process is started by the MCP client program. Run the following command to start the MCP client and MCP server:

uv run client.py

Add a new tool

Step 1: Create a new tool class or extend an existing one

  • Create a new file in the tools directory if adding a completely new tool category
  • Or add your tool to an existing class if it fits an existing category
from typing import Dict, List, Any
from fastmcp import FastMCP

class YourTools:
    def register_tools(self, mcp: FastMCP):
        @mcp.tool()
        async def your_tool_function(arg1: str, arg2: int) -> List[Dict]:
            """
            Your tool description.
            
            Args:
                arg1: Description of arg1
                arg2: Description of arg2

            Returns:
                Description of the return value
            
            Raises:
                ValueError: If the request fails
            """
            # Implementation using self.higress_client to make API calls
            return self.higress_client.your_api_method(arg1, arg2)

Step 2: Add a new method to HigressClient if your tool needs to interact with the Higress Console API

  • Add methods to utils/higress_client.py that encapsulate API calls
  • Use the existing HTTP methods (get, put, post) for actual API communication
def your_api_method(self, arg1: str, arg2: int) -> List[Dict]:
    """
    Description of what this API method does.
    
    Args:
        arg1: Description of arg1
        arg2: Description of arg2
        
    Returns:
        Response data
        
    Raises:
        ValueError: If the request fails
    """
    path = "/v1/your/api/endpoint"
    data = {"arg1": arg1, "arg2": arg2}
    return self.put(path, data)  # or self.get(path) or self.post(path, data)

Step 3: Register your tool class in the server

  • Add your tool class to the tool_classes list in server.py
  • This list is used by ToolsRegister to instantiate and register all tools
  • The ToolsRegister will automatically set logger and higress_client attributes
tool_classes = [
    CommonTools,
    RequestBlockTools,
    RouteTools,
    ServiceSourceTools,
    YourTools  # Add your tool class here
]
GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →