Quellcode durchsuchen

update parametre description in tools

Khanh Nguyen vor 5 Monaten
Ursprung
Commit
2c3b0dbecc
1 geänderte Dateien mit 63 neuen und 84 gelöschten Zeilen
  1. 63 84
      src/server_mcp/tools.py

+ 63 - 84
src/server_mcp/tools.py

@@ -4,6 +4,8 @@ from __future__ import annotations
 
 from typing import Annotated, Any
 
+from pydantic import Field
+
 from mcp.types import ToolAnnotations
 
 from ..services.client_rest import ClientRest, HTTPMethod
@@ -16,131 +18,108 @@ _WRITE_IDEMPOTENT = ToolAnnotations(
 
 # --- createResource / updateResource ---
 
-Pagetitle = Annotated[str, "page title of the resource"]
-PagetitleOpt = Annotated[str | None, "page title of the resource"]
-Alias = Annotated[str | None, "alias that will be used in the URL (default: pagetitle)"]
-Cacheable = Annotated[bool | None, "tells if the resource is cacheable"]
-Content = Annotated[str | None, "content of the resource"]
-ContextKey = Annotated[str | None, "context of the resource (default: web)"]
-Deleted = Annotated[bool | None, "tells if the resource is deleted or not"]
-Description = Annotated[str | None, "description of the resource"]
-Hidemenu = Annotated[
-    bool | None, "tells if the resource should be hidden from menu display"
-]
-Introtext = Annotated[str | None, "introduction of the resource"]
-ResourceIdDuplicate = Annotated[int | None, "a resource id to duplicate"]
-ResourceId = Annotated[int, "a resource id to modify"]
-ResourceIdDelete = Annotated[int, "resource id to delete"]
-Isfolder = Annotated[
-    bool | None, "tells if the resource is to be considered as a folder of resources"
-]
-LinkAttributes = Annotated[
-    str | None, "link attributes that may be used in menu or links"
-]
-Longtitle = Annotated[str | None, "long title of the resource"]
-Menuindex = Annotated[int | None, "order index of the resource in a menu"]
-Menutitle = Annotated[
-    str | None, "title of the resource if displayed in a menu tree"
-]
+Pagetitle = Annotated[str, Field(description="page title of the resource")]
+PagetitleOpt = Annotated[str | None, Field(default=None, description="page title of the resource")]
+Alias = Annotated[str | None, Field(default=None, description="alias that will be used in the URL (default: pagetitle)")]
+Cacheable = Annotated[bool | None, Field(default=None, description="tells if the resource is cacheable")]
+Content = Annotated[str | None, Field(default=None, description="content of the resource")]  
+ContextKey = Annotated[str | None, Field(default=None, description="context of the resource (default: web)")]
+Deleted = Annotated[bool | None, Field(default=None, description="tells if the resource is deleted or not")]
+Description = Annotated[str | None, Field(default=None, description="description of the resource")]
+Hidemenu = Annotated[bool | None, Field(default=None, description="tells if the resource should be hidden from menu display")]
+Introtext = Annotated[str | None, Field(default=None, description="introduction of the resource")]
+ResourceIdDuplicate = Annotated[int | None, Field(default=None, description="a resource id to duplicate")]
+ResourceId = Annotated[int, Field(description="a resource id to modify")]
+ResourceIdDelete = Annotated[int, Field(description="resource id to delete")]
+Isfolder = Annotated[bool | None, Field(default=None, description="tells if the resource is to be considered as a folder of resources")]
+LinkAttributes = Annotated[str | None, Field(default=None, description="link attributes that may be used in menu or links")]
+Longtitle = Annotated[str | None, Field(default=None, description="long title of the resource")]
+Menuindex = Annotated[int | None, Field(default=None, description="order index of the resource in a menu")]
+Menutitle = Annotated[str | None, Field(default=None, description="title of the resource if displayed in a menu tree")]
 PagetitleUnique = Annotated[
-    str | None,
-    "if set, modify pagetitle to get a unique pagetitle and alias "
-    "('1'/'uniqueid' adds uniqid, 'date' adds timestamp; default: 0)",
-]
-Parent = Annotated[int | None, "parent of the resource (default: 0, root)"]
-Published = Annotated[bool | None, "tells if the resource is published"]
-PubDate = Annotated[
-    str | None, "date in the future that the resource should be published"
-]
-Searchable = Annotated[bool | None, "tells if the resource may be found in a search process"]
-TemplateId = Annotated[
-    int | None,
-    "resource id of the template (default: default_template setting, e.g. 12)",
-]
-UnpubDate = Annotated[str | None, "date when the resource should be unpublished"]
-TemplateVars = Annotated[
-    dict[str, Any] | list[Any] | str | None,
-    "json list of template variables content",
-]
+    str | None, Field(default=None, description="if set, modify pagetitle to get a unique pagetitle and alias ('1'/'uniqueid' adds uniqid, 'date' adds timestamp; default: 0)")]
+Parent = Annotated[int | None, Field(default=None, description="parent of the resource (default: 0, root)")]
+Published = Annotated[bool | None, Field(default=None, description="tells if the resource is published")]
+PubDate = Annotated[str | None, Field(default=None, description="date in the future that the resource should be published")]
+Searchable = Annotated[bool | None, Field(default=None, description="tells if the resource may be found in a search process")]
+TemplateId = Annotated[int | None, Field(default=None, description="resource id of the template (default: default_template setting, e.g. 12)")]
+UnpubDate = Annotated[str | None, Field(default=None, description="date when the resource should be unpublished")]
+TemplateVars = Annotated[dict[str, Any] | list[Any] | str | None, Field(default=None, description="json list of template variables content")]
 ResourceGroups = Annotated[
-    dict[str, Any] | list[Any] | str | None,
-    "comma-separated list of resource group ids, or JSON "
-    '[{"id":"<resource id>","access":"<0|1>"}]',
+    dict[str, Any] | list[Any] | str | None, 
+    Field(default=None, description="comma-separated list of resource group ids, or JSON '[{\"id\":\"<resource id>\",\"access\":\"<0|1>\"}]'")
 ]
 ResourceGroupsUpdate = Annotated[
     dict[str, Any] | list[Any] | str | None,
-    "resource groups to add; to remove a group send JSON with access=0",
+    Field(default=None, description="resource groups to add; to remove a group send JSON with access=0")
 ]
 MandatoryParents = Annotated[
     int | str | list[int] | None,
-    "comma-separated list of resource ids giving the authorized parents",
+    Field(default=None, description="comma-separated list of resource ids giving the authorized parents")
 ]
-ContentType = Annotated[str | None, "mime type of the resource content (default: text/html)"]
-Syncsite = Annotated[bool | None, "if set, it will refresh the resource cache (default: 0)"]
+ContentType = Annotated[str | None, Field(default=None, description="mime type of the resource content (default: text/html)")]
+Syncsite = Annotated[bool | None, Field(default=None, description="if set, it will refresh the resource cache (default: 0)")]
 MandatoryParent = Annotated[
-    int | None,
-    "set the mandatory parent of the id to verify the resource id is appropriate",
+    int | None, 
+    Field(default=None, description="set the mandatory parent of the id to verify the resource id is appropriate")
 ]
 
 # --- createTemplate / updateTemplate ---
 
-TemplateName = Annotated[str, "name of the template"]
-TemplateNameOpt = Annotated[str | None, "name of the template"]
-TemplateIdMandatory = Annotated[int, "id of the template"]
-TemplateDescription = Annotated[str | None, "description of the template"]
-Category = Annotated[str | None, "category the element belongs in"]
+TemplateName = Annotated[str, Field(description="name of the template")]
+TemplateNameOpt = Annotated[str | None, Field(default=None, description="name of the template")]
+TemplateIdMandatory = Annotated[int, Field(description="id of the template")]
+TemplateDescription = Annotated[str | None, Field(default=None, description="description of the template")]
+Category = Annotated[str | None, Field(default=None, description="category the element belongs in")]
 IsStatic = Annotated[
-    bool | None,
-    "if true, the element source is stored in an external file (default: false)",
+    bool | None, 
+    Field(default=None, description="if true, the element source is stored in an external file (default: false)")
 ]
 StaticFile = Annotated[
     str | None,
-    "if isStatic true, path of the external file where the element source is stored",
+    Field(default=None, description="if isStatic true, path of the external file where the element source is stored")
 ]
-TemplateContent = Annotated[str | None, "template code (HTML)"]
+TemplateContent = Annotated[str | None, Field(default=None, description="template code (HTML)")]
 LockTemplate = Annotated[
-    bool | None,
-    "lock template for editing; requires edit_locked attribute (default: false)",
+    bool | None, 
+    Field(default=None, description="lock template for editing; requires edit_locked attribute (default: false)")
 ]
 TemplateVarsAccess = Annotated[
     dict[str, Any] | list[Any] | str | None,
-    "JSON list that indicates the access of template vars (default: {})",
+    Field(default=None, description="JSON list that indicates the access of template vars (default: {})")
 ]
 
 # --- createTv / updateTv ---
 
-TvName = Annotated[str, "name of the template variable"]
-TvNameOpt = Annotated[str | None, "name of the TV"]
-TvId = Annotated[int, "id of the TV"]
-TvDescription = Annotated[str | None, "description of the template variable"]
-TvCaption = Annotated[
-    str | None,
-    "text displayed beside the TV when editing it in a Resource",
-]
-TvCategory = Annotated[str | None, "category the TV belongs in"]
-TvType = Annotated[str | None, "the type of TV"]
+TvName = Annotated[str, Field(description="name of the template variable")]
+TvNameOpt = Annotated[str | None, Field(default=None, description="name of the TV")]
+TvId = Annotated[int, Field(description="id of the TV")]
+TvDescription = Annotated[str | None, Field(default=None, description="description of the template variable")]
+TvCaption = Annotated[str | None, Field(default=None, description="text displayed beside the TV when editing it in a Resource")]
+TvCategory = Annotated[str | None, Field(default=None, description="category the TV belongs in")]
+TvType = Annotated[str | None, Field(default=None, description="the type of TV")]
 TvElements = Annotated[
     str | None,
-    "list of options for TV; only use if the type of TV is listbox",
+    Field(default=None, description="list of options for TV; only use if the type of TV is listbox"),
 ]
 TvDefaultText = Annotated[
     str | None,
-    "default option for TV; only use if the type of TV is listbox",
+    Field(default=None, description="default option for TV; only use if the type of TV is listbox"),
 ]
 TvInputPropeties = Annotated[
-    str | None, "JSON list of the input properties of the TV"
+    str | None, Field(default=None, description="JSON list of the input properties of the TV")
 ]
 TvTemplates = Annotated[
     dict[str, Any] | list[Any] | str | None,
-    "JSON list that indicates the access of templates (default: {})",
+    Field(default=None, description="JSON list that indicates the access of templates (default: {})")
 ]
 
 # --- createCategory / updateCategory ---
 
-CategoryName = Annotated[str, "name of the category"]
-CategoryNameOpt = Annotated[str | None, "name of the category"]
-CategoryId = Annotated[int, "id of the category"]
-CategoryParent = Annotated[int | None, "parent id of the category (default: 0)"]
+CategoryName = Annotated[str, Field(description="name of the category")]
+CategoryNameOpt = Annotated[str | None, Field(default=None, description="name of the category")]
+CategoryId = Annotated[int, Field(description="id of the category")]
+CategoryParent = Annotated[int | None, Field(default=None, description="parent id of the category (default: 0)")]
 
 
 def _omit_none(**kwargs: Any) -> dict[str, Any]: