|
@@ -0,0 +1,485 @@
|
|
|
|
|
+"""Definition des outils MCP (operations d'ecriture)."""
|
|
|
|
|
+
|
|
|
|
|
+from __future__ import annotations
|
|
|
|
|
+
|
|
|
|
|
+from typing import Annotated, Any
|
|
|
|
|
+
|
|
|
|
|
+from mcp.types import ToolAnnotations
|
|
|
|
|
+
|
|
|
|
|
+from ..services.client_rest import ClientRest, HTTPMethod
|
|
|
|
|
+
|
|
|
|
|
+_WRITE_ONLY = ToolAnnotations(readOnlyHint=False, destructiveHint=False)
|
|
|
|
|
+_WRITE_DESTRUCTIVE = ToolAnnotations(readOnlyHint=False, destructiveHint=True)
|
|
|
|
|
+_WRITE_IDEMPOTENT = ToolAnnotations(
|
|
|
|
|
+ readOnlyHint=False, destructiveHint=True, idempotentHint=True
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+# --- 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"
|
|
|
|
|
+]
|
|
|
|
|
+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",
|
|
|
|
|
+]
|
|
|
|
|
+ResourceGroups = Annotated[
|
|
|
|
|
+ dict[str, Any] | list[Any] | str | None,
|
|
|
|
|
+ "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",
|
|
|
|
|
+]
|
|
|
|
|
+MandatoryParents = Annotated[
|
|
|
|
|
+ int | str | list[int] | None,
|
|
|
|
|
+ "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)"]
|
|
|
|
|
+MandatoryParent = Annotated[
|
|
|
|
|
+ int | None,
|
|
|
|
|
+ "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"]
|
|
|
|
|
+IsStatic = Annotated[
|
|
|
|
|
+ bool | None,
|
|
|
|
|
+ "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",
|
|
|
|
|
+]
|
|
|
|
|
+MediaSourceForStaticFile = Annotated[
|
|
|
|
|
+ str | None,
|
|
|
|
|
+ "media source base path for static element file (default: Filesystem)",
|
|
|
|
|
+]
|
|
|
|
|
+TemplateContent = Annotated[str | None, "template code (HTML)"]
|
|
|
|
|
+LockTemplate = Annotated[
|
|
|
|
|
+ bool | None,
|
|
|
|
|
+ "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: {})",
|
|
|
|
|
+]
|
|
|
|
|
+
|
|
|
|
|
+# --- 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"]
|
|
|
|
|
+TvElement = Annotated[
|
|
|
|
|
+ str | None,
|
|
|
|
|
+ "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",
|
|
|
|
|
+]
|
|
|
|
|
+TvInputPropeties = Annotated[
|
|
|
|
|
+ str | None, "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: {})",
|
|
|
|
|
+]
|
|
|
|
|
+
|
|
|
|
|
+# --- 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)"]
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def _omit_none(**kwargs: Any) -> dict[str, Any]:
|
|
|
|
|
+ return {key: value for key, value in kwargs.items() if value is not None}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def register_tools(mcp_server: Any, client_rest: ClientRest) -> None:
|
|
|
|
|
+ """Enregistre les outils d'ecriture du serveur MCP."""
|
|
|
|
|
+
|
|
|
|
|
+ @mcp_server.tool(
|
|
|
|
|
+ description="Creer une ressource MODX",
|
|
|
|
|
+ annotations=_WRITE_ONLY,
|
|
|
|
|
+ )
|
|
|
|
|
+ def createResource(
|
|
|
|
|
+ pagetitle: Pagetitle,
|
|
|
|
|
+ alias: Alias = None,
|
|
|
|
|
+ cacheable: Cacheable = None,
|
|
|
|
|
+ content: Content = None,
|
|
|
|
|
+ context_key: ContextKey = None,
|
|
|
|
|
+ deleted: Deleted = None,
|
|
|
|
|
+ description: Description = None,
|
|
|
|
|
+ hidemenu: Hidemenu = None,
|
|
|
|
|
+ introtext: Introtext = None,
|
|
|
|
|
+ id: ResourceIdDuplicate = None,
|
|
|
|
|
+ isfolder: Isfolder = None,
|
|
|
|
|
+ link_attributes: LinkAttributes = None,
|
|
|
|
|
+ longtitle: Longtitle = None,
|
|
|
|
|
+ menuindex: Menuindex = None,
|
|
|
|
|
+ menutitle: Menutitle = None,
|
|
|
|
|
+ pagetitleUnique: PagetitleUnique = None,
|
|
|
|
|
+ parent: Parent = None,
|
|
|
|
|
+ published: Published = None,
|
|
|
|
|
+ pub_date: PubDate = None,
|
|
|
|
|
+ searchable: Searchable = None,
|
|
|
|
|
+ template: TemplateId = None,
|
|
|
|
|
+ unpub_date: UnpubDate = None,
|
|
|
|
|
+ templateVars: TemplateVars = None,
|
|
|
|
|
+ resourceGroups: ResourceGroups = None,
|
|
|
|
|
+ mandatoryParents: MandatoryParents = None,
|
|
|
|
|
+ content_type: ContentType = None,
|
|
|
|
|
+ syncsite: Syncsite = None,
|
|
|
|
|
+ ) -> dict[str, Any]:
|
|
|
|
|
+ return client_rest.execute(
|
|
|
|
|
+ method=HTTPMethod.POST,
|
|
|
|
|
+ endpoint="/rest/tools/resource",
|
|
|
|
|
+ params=_omit_none(
|
|
|
|
|
+ pagetitle=pagetitle,
|
|
|
|
|
+ alias=alias,
|
|
|
|
|
+ cacheable=cacheable,
|
|
|
|
|
+ content=content,
|
|
|
|
|
+ context_key=context_key,
|
|
|
|
|
+ deleted=deleted,
|
|
|
|
|
+ description=description,
|
|
|
|
|
+ hidemenu=hidemenu,
|
|
|
|
|
+ introtext=introtext,
|
|
|
|
|
+ id=id,
|
|
|
|
|
+ isfolder=isfolder,
|
|
|
|
|
+ link_attributes=link_attributes,
|
|
|
|
|
+ longtitle=longtitle,
|
|
|
|
|
+ menuindex=menuindex,
|
|
|
|
|
+ menutitle=menutitle,
|
|
|
|
|
+ pagetitleUnique=pagetitleUnique,
|
|
|
|
|
+ parent=parent,
|
|
|
|
|
+ published=published,
|
|
|
|
|
+ pub_date=pub_date,
|
|
|
|
|
+ searchable=searchable,
|
|
|
|
|
+ template=template,
|
|
|
|
|
+ unpub_date=unpub_date,
|
|
|
|
|
+ templateVars=templateVars,
|
|
|
|
|
+ resourceGroups=resourceGroups,
|
|
|
|
|
+ mandatoryParents=mandatoryParents,
|
|
|
|
|
+ content_type=content_type,
|
|
|
|
|
+ syncsite=syncsite,
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ @mcp_server.tool(
|
|
|
|
|
+ description=(
|
|
|
|
|
+ "Mettre a jour une ressource MODX. "
|
|
|
|
|
+ "Attention: les nouveaux parametres ecraseront les anciens, "
|
|
|
|
|
+ "meme s'ils ne sont pas renseignes; faire un get_resource au prealable."
|
|
|
|
|
+ ),
|
|
|
|
|
+ annotations=_WRITE_IDEMPOTENT,
|
|
|
|
|
+ )
|
|
|
|
|
+ def updateResource(
|
|
|
|
|
+ id: ResourceId,
|
|
|
|
|
+ alias: Alias = None,
|
|
|
|
|
+ cacheable: Cacheable = None,
|
|
|
|
|
+ content: Content = None,
|
|
|
|
|
+ deleted: Deleted = None,
|
|
|
|
|
+ description: Description = None,
|
|
|
|
|
+ hidemenu: Hidemenu = None,
|
|
|
|
|
+ introtext: Introtext = None,
|
|
|
|
|
+ isfolder: Isfolder = None,
|
|
|
|
|
+ link_attributes: LinkAttributes = None,
|
|
|
|
|
+ longtitle: Longtitle = None,
|
|
|
|
|
+ menuindex: Menuindex = None,
|
|
|
|
|
+ menutitle: Menutitle = None,
|
|
|
|
|
+ pagetitle: PagetitleOpt = None,
|
|
|
|
|
+ parent: Parent = None,
|
|
|
|
|
+ published: Published = None,
|
|
|
|
|
+ pub_date: PubDate = None,
|
|
|
|
|
+ resourceGroups: ResourceGroupsUpdate = None,
|
|
|
|
|
+ searchable: Searchable = None,
|
|
|
|
|
+ template: TemplateId = None,
|
|
|
|
|
+ templateVars: TemplateVars = None,
|
|
|
|
|
+ unpub_date: UnpubDate = None,
|
|
|
|
|
+ syncsite: Syncsite = None,
|
|
|
|
|
+ ) -> dict[str, Any]:
|
|
|
|
|
+ return client_rest.execute(
|
|
|
|
|
+ method=HTTPMethod.PUT,
|
|
|
|
|
+ endpoint="/rest/tools/resource",
|
|
|
|
|
+ params=_omit_none(
|
|
|
|
|
+ id=id,
|
|
|
|
|
+ alias=alias,
|
|
|
|
|
+ cacheable=cacheable,
|
|
|
|
|
+ content=content,
|
|
|
|
|
+ deleted=deleted,
|
|
|
|
|
+ description=description,
|
|
|
|
|
+ hidemenu=hidemenu,
|
|
|
|
|
+ introtext=introtext,
|
|
|
|
|
+ isfolder=isfolder,
|
|
|
|
|
+ link_attributes=link_attributes,
|
|
|
|
|
+ longtitle=longtitle,
|
|
|
|
|
+ menuindex=menuindex,
|
|
|
|
|
+ menutitle=menutitle,
|
|
|
|
|
+ pagetitle=pagetitle,
|
|
|
|
|
+ parent=parent,
|
|
|
|
|
+ published=published,
|
|
|
|
|
+ pub_date=pub_date,
|
|
|
|
|
+ resourceGroups=resourceGroups,
|
|
|
|
|
+ searchable=searchable,
|
|
|
|
|
+ template=template,
|
|
|
|
|
+ templateVars=templateVars,
|
|
|
|
|
+ unpub_date=unpub_date,
|
|
|
|
|
+ syncsite=syncsite,
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ @mcp_server.tool(
|
|
|
|
|
+ description="Supprimer une ressource MODX",
|
|
|
|
|
+ annotations=_WRITE_DESTRUCTIVE,
|
|
|
|
|
+ )
|
|
|
|
|
+ def deleteResource(
|
|
|
|
|
+ id: ResourceIdDelete,
|
|
|
|
|
+ mandatoryParent: MandatoryParent = None,
|
|
|
|
|
+ syncsite: Syncsite = None,
|
|
|
|
|
+ ) -> dict[str, Any]:
|
|
|
|
|
+ return client_rest.execute(
|
|
|
|
|
+ method=HTTPMethod.DELETE,
|
|
|
|
|
+ endpoint="/rest/tools/resource",
|
|
|
|
|
+ params=_omit_none(
|
|
|
|
|
+ id=id,
|
|
|
|
|
+ mandatoryParent=mandatoryParent,
|
|
|
|
|
+ syncsite=syncsite,
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ @mcp_server.tool(
|
|
|
|
|
+ description="Creer un template MODX",
|
|
|
|
|
+ annotations=_WRITE_ONLY,
|
|
|
|
|
+ )
|
|
|
|
|
+ def createTemplate(
|
|
|
|
|
+ name: TemplateName,
|
|
|
|
|
+ description: TemplateDescription = None,
|
|
|
|
|
+ category: Category = None,
|
|
|
|
|
+ isStatic: IsStatic = None,
|
|
|
|
|
+ staticFile: StaticFile = None,
|
|
|
|
|
+ mediaSourceForStaticFile: MediaSourceForStaticFile = None,
|
|
|
|
|
+ content: TemplateContent = None,
|
|
|
|
|
+ lockTemplate: LockTemplate = None,
|
|
|
|
|
+ templateVars: TemplateVarsAccess = None,
|
|
|
|
|
+ ) -> dict[str, Any]:
|
|
|
|
|
+ return client_rest.execute(
|
|
|
|
|
+ method=HTTPMethod.POST,
|
|
|
|
|
+ endpoint="/rest/tools/template",
|
|
|
|
|
+ params=_omit_none(
|
|
|
|
|
+ name=name,
|
|
|
|
|
+ description=description,
|
|
|
|
|
+ category=category,
|
|
|
|
|
+ isStatic=isStatic,
|
|
|
|
|
+ staticFile=staticFile,
|
|
|
|
|
+ mediaSourceForStaticFile=mediaSourceForStaticFile,
|
|
|
|
|
+ content=content,
|
|
|
|
|
+ lockTemplate=lockTemplate,
|
|
|
|
|
+ templateVars=templateVars,
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ @mcp_server.tool(
|
|
|
|
|
+ description=(
|
|
|
|
|
+ "Mettre a jour un template MODX. "
|
|
|
|
|
+ "Attention: les nouveaux parametres ecraseront les anciens; "
|
|
|
|
|
+ "faire un get_template au prealable."
|
|
|
|
|
+ ),
|
|
|
|
|
+ annotations=_WRITE_IDEMPOTENT,
|
|
|
|
|
+ )
|
|
|
|
|
+ def updateTemplate(
|
|
|
|
|
+ id: TemplateIdMandatory,
|
|
|
|
|
+ name: TemplateNameOpt = None,
|
|
|
|
|
+ description: TemplateDescription = None,
|
|
|
|
|
+ category: Category = None,
|
|
|
|
|
+ isStatic: IsStatic = None,
|
|
|
|
|
+ staticFile: StaticFile = None,
|
|
|
|
|
+ mediaSourceForStaticFile: MediaSourceForStaticFile = None,
|
|
|
|
|
+ content: TemplateContent = None,
|
|
|
|
|
+ lockTemplate: LockTemplate = None,
|
|
|
|
|
+ templateVars: TemplateVarsAccess = None,
|
|
|
|
|
+ ) -> dict[str, Any]:
|
|
|
|
|
+ return client_rest.execute(
|
|
|
|
|
+ method=HTTPMethod.PUT,
|
|
|
|
|
+ endpoint="/rest/tools/template",
|
|
|
|
|
+ params=_omit_none(
|
|
|
|
|
+ id=id,
|
|
|
|
|
+ name=name,
|
|
|
|
|
+ description=description,
|
|
|
|
|
+ category=category,
|
|
|
|
|
+ isStatic=isStatic,
|
|
|
|
|
+ staticFile=staticFile,
|
|
|
|
|
+ mediaSourceForStaticFile=mediaSourceForStaticFile,
|
|
|
|
|
+ content=content,
|
|
|
|
|
+ lockTemplate=lockTemplate,
|
|
|
|
|
+ templateVars=templateVars,
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ @mcp_server.tool(
|
|
|
|
|
+ description="Creer une template variable MODX",
|
|
|
|
|
+ annotations=_WRITE_ONLY,
|
|
|
|
|
+ )
|
|
|
|
|
+ def createTv(
|
|
|
|
|
+ name: TvName,
|
|
|
|
|
+ description: TvDescription = None,
|
|
|
|
|
+ caption: TvCaption = None,
|
|
|
|
|
+ category: TvCategory = None,
|
|
|
|
|
+ type: TvType = None,
|
|
|
|
|
+ element: TvElement = None,
|
|
|
|
|
+ defaultText: TvDefaultText = None,
|
|
|
|
|
+ lockTemplate: LockTemplate = None,
|
|
|
|
|
+ inputPropeties: TvInputPropeties = None,
|
|
|
|
|
+ isStatic: IsStatic = None,
|
|
|
|
|
+ staticFile: StaticFile = None,
|
|
|
|
|
+ templates: TvTemplates = None,
|
|
|
|
|
+ ) -> dict[str, Any]:
|
|
|
|
|
+ return client_rest.execute(
|
|
|
|
|
+ method=HTTPMethod.POST,
|
|
|
|
|
+ endpoint="/rest/tools/tv",
|
|
|
|
|
+ params=_omit_none(
|
|
|
|
|
+ name=name,
|
|
|
|
|
+ description=description,
|
|
|
|
|
+ caption=caption,
|
|
|
|
|
+ category=category,
|
|
|
|
|
+ type=type,
|
|
|
|
|
+ element=element,
|
|
|
|
|
+ defaultText=defaultText,
|
|
|
|
|
+ lockTemplate=lockTemplate,
|
|
|
|
|
+ inputPropeties=inputPropeties,
|
|
|
|
|
+ isStatic=isStatic,
|
|
|
|
|
+ staticFile=staticFile,
|
|
|
|
|
+ templates=templates,
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ @mcp_server.tool(
|
|
|
|
|
+ description=(
|
|
|
|
|
+ "Mettre a jour une template variable MODX. "
|
|
|
|
|
+ "Attention: les nouveaux parametres ecraseront les anciens; "
|
|
|
|
|
+ "faire un get_tv au prealable."
|
|
|
|
|
+ ),
|
|
|
|
|
+ annotations=_WRITE_IDEMPOTENT,
|
|
|
|
|
+ )
|
|
|
|
|
+ def updateTv(
|
|
|
|
|
+ id: TvId,
|
|
|
|
|
+ name: TvNameOpt = None,
|
|
|
|
|
+ description: TvDescription = None,
|
|
|
|
|
+ caption: TvCaption = None,
|
|
|
|
|
+ category: TvCategory = None,
|
|
|
|
|
+ type: TvType = None,
|
|
|
|
|
+ element: TvElement = None,
|
|
|
|
|
+ defaultText: TvDefaultText = None,
|
|
|
|
|
+ lockTemplate: LockTemplate = None,
|
|
|
|
|
+ inputPropeties: TvInputPropeties = None,
|
|
|
|
|
+ isStatic: IsStatic = None,
|
|
|
|
|
+ staticFile: StaticFile = None,
|
|
|
|
|
+ templates: TvTemplates = None,
|
|
|
|
|
+ ) -> dict[str, Any]:
|
|
|
|
|
+ return client_rest.execute(
|
|
|
|
|
+ method=HTTPMethod.PUT,
|
|
|
|
|
+ endpoint="/rest/tools/tv",
|
|
|
|
|
+ params=_omit_none(
|
|
|
|
|
+ id=id,
|
|
|
|
|
+ name=name,
|
|
|
|
|
+ description=description,
|
|
|
|
|
+ caption=caption,
|
|
|
|
|
+ category=category,
|
|
|
|
|
+ type=type,
|
|
|
|
|
+ element=element,
|
|
|
|
|
+ defaultText=defaultText,
|
|
|
|
|
+ lockTemplate=lockTemplate,
|
|
|
|
|
+ inputPropeties=inputPropeties,
|
|
|
|
|
+ isStatic=isStatic,
|
|
|
|
|
+ staticFile=staticFile,
|
|
|
|
|
+ templates=templates,
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ @mcp_server.tool(
|
|
|
|
|
+ description="Creer une categorie MODX",
|
|
|
|
|
+ annotations=_WRITE_ONLY,
|
|
|
|
|
+ )
|
|
|
|
|
+ def createCategory(
|
|
|
|
|
+ category: CategoryName,
|
|
|
|
|
+ parent: CategoryParent = None,
|
|
|
|
|
+ ) -> dict[str, Any]:
|
|
|
|
|
+ return client_rest.execute(
|
|
|
|
|
+ method=HTTPMethod.POST,
|
|
|
|
|
+ endpoint="/rest/tools/category",
|
|
|
|
|
+ params=_omit_none(category=category, parent=parent),
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ @mcp_server.tool(
|
|
|
|
|
+ description=(
|
|
|
|
|
+ "Mettre a jour une categorie MODX. "
|
|
|
|
|
+ "Attention: les nouveaux parametres ecraseront les anciens; "
|
|
|
|
|
+ "faire un get_category au prealable."
|
|
|
|
|
+ ),
|
|
|
|
|
+ annotations=_WRITE_IDEMPOTENT,
|
|
|
|
|
+ )
|
|
|
|
|
+ def updateCategory(
|
|
|
|
|
+ id: CategoryId,
|
|
|
|
|
+ category: CategoryNameOpt = None,
|
|
|
|
|
+ parent: CategoryParent = None,
|
|
|
|
|
+ ) -> dict[str, Any]:
|
|
|
|
|
+ return client_rest.execute(
|
|
|
|
|
+ method=HTTPMethod.PUT,
|
|
|
|
|
+ endpoint="/rest/tools/category",
|
|
|
|
|
+ params=_omit_none(id=id, category=category, parent=parent),
|
|
|
|
|
+ )
|