Class LayoutMcpTool

java.lang.Object
io.meeds.layout.mcp.LayoutMcpTool
All Implemented Interfaces:
io.meeds.mcp.server.plugin.McpToolPlugin

@Service @Profile("mcp-server") public class LayoutMcpTool extends Object implements io.meeds.mcp.server.plugin.McpToolPlugin
The read tools of the layout, the site tools, the site layout tools and the navigation item tools: every public method is an MCP tool described in ai-tool-definitions.json. A tool maps its arguments, checks them against the vocabulary the editors accept, calls the Services as the current user and translates their refusals into the fixed texts the agent reads: does not exist: <object>, not allowed: <object>, value is not accepted for <option>. A change to a site's properties applies at once, as the sites administration's does, and so does a change to its navigation, as the navigation drawer's; a change to its layout, or to a page's, is the user's draft until publish_layout, as in the layout editors.
  • Field Details

  • Constructor Details

    • LayoutMcpTool

      public LayoutMcpTool()
  • Method Details

    • listSites

      public List<SiteSummary> listSites(String keyword)
      Lists the sites the current user can view: without a keyword the portal sites, in display order; with one, the portal sites whose name or label contains it and the group sites, a space's site among them, whose own name contains it. Read-only.
    • getSite

      public SiteDescription getSite(Long siteId, String version) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Reads a site's properties and its layout: left and right sidebars, topbars and bottom bars with their options, styling and applications. The user's site draft is returned by default when they have one (draft: true), the published layout otherwise; version: "draft" or "published" asks for one of them. What the user cannot access is absent. Read-only.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • listSitePages

      public List<NavigationItemDescription> listSitePages(Long siteId, Boolean includeHidden) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Lists the navigation items of a site as a tree, each with its identifier, its name and translations, its URL name, its type, icon, visibility and schedule, and the permissions of its page. Hidden items are listed only when include_hidden is true and the user can edit the site's navigation; draft items are never listed. Read-only.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • getPageLayout

      public PageDescription getPageLayout(String pageRef, String version) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Reads the whole page in the shape set_page_layout takes: its sections, their columns or cells, and the applications they hold with their styling and visibility. The user's draft is returned by default when their co-editing revision names one, the published layout otherwise; version: "draft" or "published" asks for one of them. Reads through the editor's own page read: a page still carrying a legacy addon container is rewritten once by that read, as it is when the editor opens it.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • listLayoutApplications

      public List<LayoutApplicationEntry> listLayoutApplications(Long categoryId, String keyword)
      Lists the applications the current user can place on a page or in a site container, with their catalog identifier, content identifier, name, description and category; category_id narrows the list to one category, keyword to the names and descriptions containing it. Read-only.
    • uploadLayoutImage

      public UploadedImage uploadLayoutImage(String imageBase64, String fileName)
      Stages an image given as base64 bytes, never fetched from an address, so that one later call consumes it: a site banner, or the background of a section, an application, a site container or a text role. The bytes are checked by content (png, jpeg, gif or webp) and capped; the id answered is unguessable, usable once, consumed and released by the call that takes it whether that call succeeds or fails.
    • createSite

      public SiteDescription createSite(String name, String label, String description, String template, String bannerUploadId, List<String> accessPermissions, String editPermission, Boolean displayed, String icon) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Creates a portal site from a site template, as the sites administration does: the name is the site's key and URL segment and never changes, the label is what users see. The template is the user's choice and is required, as the sites administration asks it before anything else; none is taken by default. Omitted options take the administration's defaults: not displayed in the sites menu, the fa-globe icon, administrators as access and edit permissions. Every value is checked before anything is written. Applies at once; not a draft. Returns the site as stored, which the permissions written may no longer let the caller read through get_site.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • updateSite

      public SiteDescription updateSite(Long siteId, String label, String description, List<String> accessPermissions, String editPermission, Boolean displayed, String icon, String bannerUploadId, Boolean removeBanner) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Updates a site's label, description, icon, display in the sites menu, banner and permissions: an option omitted keeps its stored value. The name is the site's key and cannot change. Only a site the sites administration lists, a portal site that is not a space's public site, can be updated. The permissions are written first, then the properties, and what was written is put back when a later step fails. Applies at once; not a draft. Returns the site as stored, which the permissions written (the edit right handed to a group the caller is not in) may no longer let the caller read through get_site.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • deleteSite

      public void deleteSite(Long siteId) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Deletes a site with its pages and navigation, at once and for every user, as the sites administration does after its confirmation; a site the administration never offers to delete is refused: one the platform ships as not removable, and one it does not list, a space's site or public site, a user's site, a template.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • setSiteLayout

      public SiteDescription setSiteLayout(Long siteId, SiteContainerDescription leftSidebar, SiteContainerDescription rightSidebar, List<SiteContainerDescription> topbars, List<SiteContainerDescription> bottomBars) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Replaces the structure of the user's site draft: the sidebars, topbars and bottom bars given, with their options and styling, a sidebar with its applications and a topbar or a bottom bar with its columns, one application per column, as the site layout editor lays them out; a sidebar or a list omitted is absent from the draft, while an option, a styling block or a display left null on a kept element keeps what it holds. Ids address the layout get_site returned: the user's draft when they have one, the published layout otherwise, in which case the draft is created by this call and every kept application becomes a copy carrying its preferences. Every value is checked before anything is written. Returns the draft as get_site does, with its ids.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • publishLayout

      public Object publishLayout(Long siteId, String pageRef) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Makes the user's draft the published layout, for every viewer at once, as the editors' publish does: the draft the user's revision names is written over the live site or page, every container and application taking a new id, and the draft ends. Exactly one of site_id and page_ref names what is published. Returns the site as get_site does, or the page as get_page_layout does, as published, with the new ids.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • discardLayoutDraft

      public Object discardLayoutDraft(Long siteId, String pageRef) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Drops the user's draft and starts a new one from the published layout, as the editors' "start again" does. Exactly one of site_id and page_ref names the site or the page. Returns the new draft, with its ids.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • setPageLayout

      public PageDescription setPageLayout(String pageRef, List<SectionDescription> sections) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Replaces the whole content of the current user's draft of a page, as the page editor's draft save does: the sections in order, each a dynamic section of 1, 2, 3, 4, 6 or 12 columns holding its applications in order per column, or a grid of up to 12 rows and 12 columns holding one application per cell, with the styling and display of sections and applications. Ids address the layout get_page_layout returned: the user's draft when they have one, the published layout otherwise, in which case the draft is created by this call through the editor's own path and every kept application is the draft's copy of it, carrying its preferences as the editor's draft does. Every value is checked before anything is written; one save. Returns the draft as get_page_layout does, with the ids of every section, cell and application.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • setLayoutStyles

      public Object setLayoutStyles(Long siteId, String pageRef, List<ElementStyling> elements) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Sets the styling of sections, applications, topbars, bottom bars and sidebars of the current user's draft of a page or a site, as the editors' styling drawers do, in one draft save: each element addressed by the id the read answered takes the blocks given merged over its stored ones, every other element staying as it is. Exactly one of site_id and page_ref names the layout. Ids address the layout get_page_layout or get_site returned: the user's draft when they have one, the published layout otherwise, in which case the draft is created by this call. Every value is checked before anything is written. Returns the draft as get_page_layout or get_site does, with its ids.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • setLayoutVisibility

      public Object setLayoutVisibility(Long siteId, String pageRef, List<ElementDisplay> elements) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Sets where sections, applications, topbars, bottom bars and sidebars of the current user's draft of a page or a site are displayed, as the editors' visibility choice does, in one draft save: each element addressed by the id the read answered is displayed on desktop and mobile, hidden on mobile or hidden on desktop, every other element staying as it is. Exactly one of site_id and page_ref names the layout. Ids address the layout get_page_layout or get_site returned: the user's draft when they have one, the published layout otherwise, in which case the draft is created by this call. Every value is checked before anything is written. Returns the draft as get_page_layout or get_site does, with its ids.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • configureLayoutApplications

      public Object configureLayoutApplications(Long siteId, String pageRef, List<ApplicationSettingsEntry> applications) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Sets the settings of applications placed on the current user's draft of a page or a site, as each application's settings drawer does: Links, News list, Content list, My Applications, Block of content and Image, any other application being refused as not configurable through tools. Each application addressed by the id the read answered takes the settings given, a setting omitted keeping its stored value. Exactly one of site_id and page_ref names the layout; ids address the layout get_page_layout or get_site returned: the user's draft when they have one, the published layout otherwise, in which case the draft is created by this call. Every application is validated, its own permission rule included, before the first one is written; then they are written one after the other, and a failure names the applications already written, which stay written, and says when the call created the draft, which stays. Returns the draft as get_page_layout or get_site does, with the settings of each configurable application.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • moveLayoutApplication

      public ApplicationPlacement moveLayoutApplication(Long siteId, String pageRef, String applicationId, ApplicationToPlace application, ApplicationPosition position) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Places an application from the catalog, or moves one the read answered, on the current user's draft of a page or a site, in one draft save, without resending the layout. Exactly one of site_id and page_ref names the layout, and exactly one of application_id (move) and application (place). Ids address the layout get_page_layout or get_site returned: the user's draft when they have one, the published layout otherwise, in which case the draft is created by this call. Returns the id the application has in the draft and the layout as get_page_layout or get_site does.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • removeLayoutApplication

      public Object removeLayoutApplication(Long siteId, String pageRef, String applicationId) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Removes an application the read answered from the current user's draft of a page or a site, in one draft save; the column, cell or container it leaves stays, empty when it held no other application. Exactly one of site_id and page_ref names the layout. Returns the layout as get_page_layout or get_site does.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • createPage

      public NavigationItemDescription createPage(Long siteId, Long parentNodeId, String label, Map<String,String> labels, String urlName, String type, Long pageTemplateId, String pageRef, String url, String target, String icon, Boolean visible, ScheduleDescription scheduled, List<String> accessPermissions, String editPermission) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Creates a navigation item of a site with the 'Add an item' drawer's inputs: a translatable name, a URL name chosen now and never changed, a type with what it needs (a new page from a page template, an existing page, a link, a group of pages), the tab it opens in, an icon, a visibility and its schedule, and the permissions of a page created here; the item goes last under its parent. An item opens from the menus in the same tab unless its target says otherwise; the storage keeps the same tab on a blank one. Every value is checked before anything is written: the page first, then the item, a page left behind by an item failure being removed. Applies at once; not a draft. Returns the item as list_site_pages describes it, its labels omitted when the permissions written leave the caller no view right on the page, as the navigation drawer cannot read them then either.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • updatePage

      public NavigationItemDescription updatePage(Long nodeId, String label, Map<String,String> labels, String urlName, String type, Long pageTemplateId, String pageRef, String url, String target, String icon, Boolean visible, ScheduleDescription scheduled, List<String> accessPermissions, String editPermission) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Updates a navigation item's name and translations, type, icon, visibility and schedule and the permissions of its page: an option omitted keeps its stored value, a translation given is merged over the stored ones. The URL name is chosen at creation and cannot change: a different one is refused with that reason. A type given changes the item's page as the drawer's edit does: a group detaches the page, an existing page re-points the item, a link rewrites the item's link page or creates one, a page creates a new one from a template, on an item that already points at a page only when the template is given, so the type read back can be sent back unchanged; the previous page is kept, so a repeated call that replaces a page leaves one behind each time; the tab the item opens in stays as stored unless a target is given, as the drawer's edit keeps it. An item whose page no longer exists keeps its reference: type group drops it, page_ref points it elsewhere, and type page without a template changes nothing on it. The permissions go on the item's page, never in the call that points it at another page. The page steps come first, then the item, and what was written is put back when a later step fails. Applies at once; not a draft. Returns the item as list_site_pages describes it, its labels omitted when the permissions written leave the caller no view right on the page, as the navigation drawer cannot read them then either.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • deletePage

      public void deletePage(Long nodeId) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Deletes a navigation item with the items under it, at once and for every user, as the navigation drawer does after its confirmation; the page the item pointed to is kept, as the drawer keeps it. An item the platform manages itself (system visibility) is refused.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException