Higress OPS MCP 서버
Higress 의 포괄적인 구성 및 관리를 지원하는 모델 컨텍스트 프로토콜(MCP) 서버 구현입니다. 이 저장소는 LangGraph 및 LangChain MCP 어댑터를 기반으로 구축된 MCP 클라이언트도 제공하며, 잘 설계된 에이전트 흐름 아키텍처를 통해 Higress MCP 서버와의 상호 작용을 용이하게 합니다.
데모
https://github.com/user-attachments/assets/bae66b77-a158-452e-9196-98060bac0df7
Related MCP server: MCP-Server-TESS
구성 환경 변수
.env.example 파일을 .env 로 복사하고 해당 값을 입력합니다.
MCP 클라이언트 및 MCP 서버 시작
stdio 모드에서 MCP 서버 프로세스는 MCP 클라이언트 프로그램에 의해 시작됩니다. 다음 명령을 실행하여 MCP 클라이언트와 MCP 서버를 시작하세요.
지엑스피1
새로운 도구 추가
1단계: 새 도구 클래스를 만들거나 기존 도구 클래스를 확장합니다.
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)
2단계: 도구가 Higress Console API와 상호 작용해야 하는 경우 HigressClient에 새 메서드를 추가합니다.
API 호출을 캡슐화하는 utils/higress_client.py에 메서드를 추가합니다.
실제 API 통신을 위해 기존 HTTP 메서드(get, put, post)를 사용합니다.
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)
3단계: 서버에 도구 클래스 등록
server.py의 tool_classes 목록에 도구 클래스를 추가합니다.
이 목록은 ToolsRegister에서 모든 도구를 인스턴스화하고 등록하는 데 사용됩니다.
ToolsRegister는 자동으로 logger 및 higress_client 속성을 설정합니다.
tool_classes = [
CommonTools,
RequestBlockTools,
RouteTools,
ServiceSourceTools,
YourTools # Add your tool class here
]
4단계: 인간의 확인이 필요한 경우
# 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
]