Skip to main content

MCP Server for Higress

Project description

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
]

Step 4: Add your tool to SENSITIVE_TOOLS if it requires human confirmation

  • Tools in this list will require human confirmation before execution
# Define write operations that require human confirmation
SENSITIVE_TOOLS = [
    "add_route", 
    "add_service_source",
    "update_route",
    "update_request_block_plugin", 
    "update_service_source",
    "your_tool_function"  # Add your tool name here if it requires confirmation
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mseep_higress_mcp_server-0.1.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mseep_higress_mcp_server-0.1.1-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file mseep_higress_mcp_server-0.1.1.tar.gz.

File metadata

  • Download URL: mseep_higress_mcp_server-0.1.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for mseep_higress_mcp_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0a737f9b40c8f924bf86eea5b24fd53bc5cb4ab2889dfc20fdd5f32e9477b5ee
MD5 d3356d6db3321b54c96c353333e83309
BLAKE2b-256 56219a792cd64495950c8193a2095ac730f547130f0c7dff204492926be18ac7

See more details on using hashes here.

File details

Details for the file mseep_higress_mcp_server-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mseep_higress_mcp_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 27f8b93c5bab979332cd3124c5d7c007b63a0361fea049b2a754837a3c6d78ad
MD5 252a25e2b51762072ea1d28455f0f543
BLAKE2b-256 987a46fcc46d5a75da27fc44549ce9db9d5c9fd05faf746cc21cd99bd7af41c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page