HG

higress-group/higress-ops-mcp-server

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

23 stars 8 forks Качество 36 Тренд 10

Реализация сервера Model Context Protocol (MCP), которая обеспечивает полную конфигурацию и управление Higress.

Обзор

Реализация сервера Model Context Protocol (MCP), которая обеспечивает полную конфигурацию и управление Higress. Этот репозиторий также предоставляет клиент MCP, построенный поверх адаптеров LangGraph и LangChain MCP, что облегчает взаимодействие с сервером Higress MCP через хорошо продуманную архитектуру потока агентов. [[Т0]] Скопируйте файл .env.example в .env и заполните соответствующие значения. В режиме stdio процесс MCP-сервера запускается клиентской программой MCP. Выполните следующую команду для запуска клиента MCP и сервера MCP: Создать новый файл в каталоге инструментов, если добавить совершенно новую категорию инструментов Или добавьте инструмент в существующий класс, если он соответствует существующей категории. Добавьте методы в utils/higress client.py, которые инкапсулируют вызовы API - Используйте существующие методы HTTP (get, put, post) для фактической связи API Добавьте свой класс инструментов в список tool classes на сервере.

Обзор (машинный перевод)

Реализация сервера Model Context Protocol (MCP), которая обеспечивает полную конфигурацию и управление Higress. Этот репозиторий также предоставляет клиент MCP, построенный поверх адаптеров LangGraph и LangChain MCP, что облегчает взаимодействие с сервером Higress MCP через хорошо продуманную архитектуру потока агентов.

Демо

[[Т0]]

Переменные конфигурационной среды

Скопируйте .env.example файл .env и заполните соответствующие значения.

Запустите MCP-клиент и MCP-сервер

В режиме stdio процесс MCP-сервера запускается клиентской программой MCP. Выполните следующую команду для запуска клиента MCP и сервера MCP:

Добавить новый инструмент

Шаг 1: Создайте новый класс инструментов или расширьте существующий

Создать новый файл в каталоге инструментов, если добавить совершенно новую категорию инструментов Или добавьте инструмент в существующий класс, если он соответствует существующей категории.

Шаг 2: Добавьте новый метод в HigressClient, если ваш инструмент должен взаимодействовать с API консоли Higress

Добавить методы в utils/higress client.py, которые инкапсулируют вызовы API Используйте существующие методы HTTP (get, put, post) для фактической связи API

Эта страница переведена автоматически. Технические детали смотрите в оригинале.

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
]
Открыть полный README на GitHub

Установка

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

Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →