|
|
@@ -1,6 +1,5 @@
|
|
|
from __future__ import annotations
|
|
|
|
|
|
-import json
|
|
|
import os
|
|
|
from typing import Any
|
|
|
|
|
|
@@ -8,11 +7,10 @@ from fastmcp import FastMCP
|
|
|
|
|
|
from .auth import load_projects_config
|
|
|
from .config_api import (
|
|
|
- SetPointValueItem,
|
|
|
+ get_command_log as api_get_command_log,
|
|
|
get_ai_online_v2 as api_get_ai_online_v2,
|
|
|
search_ai_rcmd_operations as api_search_ai_rcmd_operations,
|
|
|
search_ai_systems as api_search_ai_systems,
|
|
|
- set_multi_values as api_set_multi_values,
|
|
|
)
|
|
|
|
|
|
|
|
|
@@ -67,19 +65,6 @@ def _append_next_page_hint(payload: Any, page_num: int) -> Any:
|
|
|
return payload
|
|
|
|
|
|
|
|
|
-def _print_set_multi_values_request(project_key: str, points: list[SetPointValueItem], from_: str) -> None:
|
|
|
- print(
|
|
|
- json.dumps(
|
|
|
- {
|
|
|
- "event": "set_multi_values",
|
|
|
- "project_key": project_key,
|
|
|
- "from": from_,
|
|
|
- "points": points,
|
|
|
- },
|
|
|
- ensure_ascii=False,
|
|
|
- )
|
|
|
- )
|
|
|
-
|
|
|
@mcp.tool()
|
|
|
def search_ai_systems(
|
|
|
project_key: str,
|
|
|
@@ -104,11 +89,11 @@ def search_ai_rcmd_operations(
|
|
|
project_key: str,
|
|
|
codes: list[str],
|
|
|
end: str,
|
|
|
- page_size: int = 20,
|
|
|
+ page_size: int = 10,
|
|
|
page_num: int = 1,
|
|
|
order: str = "-create_time",
|
|
|
) -> Any:
|
|
|
- """Search AI strategy records by AI system code. Default page_size is 20 unless explicitly overridden. auto_exec=true means auto control, otherwise recommendation only."""
|
|
|
+ """Search AI strategy records by AI system code. Default page_size is 10 unless explicitly overridden. auto_exec=true means auto control, otherwise recommendation only."""
|
|
|
payload = api_search_ai_rcmd_operations(
|
|
|
project_key,
|
|
|
codes=codes,
|
|
|
@@ -127,10 +112,26 @@ def get_ai_online_v2(project_key: str, codes: list[str]) -> Any:
|
|
|
|
|
|
|
|
|
@mcp.tool()
|
|
|
-def set_multi_values(project_key: str, points: list[SetPointValueItem], from_: str = "M2_BACKEND") -> Any:
|
|
|
- """Write multiple point values to upstream basedataportal."""
|
|
|
- _print_set_multi_values_request(project_key, points, from_)
|
|
|
- return api_set_multi_values(project_key, points=points, from_=from_)
|
|
|
+def get_command_log(
|
|
|
+ project_key: str,
|
|
|
+ point_id: str,
|
|
|
+ begin: int,
|
|
|
+ end: int,
|
|
|
+ page_size: int = 20,
|
|
|
+ page_num: int = 1,
|
|
|
+ export: bool = False,
|
|
|
+) -> Any:
|
|
|
+ """Query command delivery logs by point_id and time range. In returned data, status=1 means the point was delivered successfully."""
|
|
|
+ payload = api_get_command_log(
|
|
|
+ project_key,
|
|
|
+ point_id=point_id,
|
|
|
+ begin=begin,
|
|
|
+ end=end,
|
|
|
+ page_size=page_size,
|
|
|
+ page_num=page_num,
|
|
|
+ export=export,
|
|
|
+ )
|
|
|
+ return _append_next_page_hint(payload, page_num)
|
|
|
|
|
|
|
|
|
def main() -> None:
|