Class McpEntityConfig.EntityTools

java.lang.Object
com.ssgllc.fish.config.mcp.McpEntityConfig.EntityTools
Enclosing class:
McpEntityConfig

public static class McpEntityConfig.EntityTools extends Object
Tool implementations for entity CRUD operations.

Delegates to EntityUtil static methods, which go through the standard Casetivity service and security layer.

  • Field Details

    • mapper

      protected final com.fasterxml.jackson.databind.ObjectMapper mapper
  • Method Details

    • getEntity

      @Tool(name="get-entity", description="Get an entity DTO by type and id.") public String getEntity(@ToolParam(description="Entity type name") String entityType, @ToolParam(description="Entity id") String entityId, @ToolParam(required=false,description="Expansion paths") String expansion)
      Fetches the entity DTO. Use expansion to eagerly load related objects (e.g. "assignedTo,notes").
      Parameters:
      entityType - entity type name
      entityId - entity UUID or string id
      expansion - optional dot-separated or comma-separated expansion paths
      Returns:
      entity DTO as JSON, or an error object if not found
    • getDomainEntity

      @Tool(name="get-domain-entity", description="Get the raw JPA domain object by type and id.") public String getDomainEntity(@ToolParam(description="Entity type name") String entityType, @ToolParam(description="Entity id") String entityId)
    • findEntity

      @Tool(name="find-entity", description="Find a single entity by exact field match.") public String findEntity(@ToolParam(description="Entity type name") String entityType, @ToolParam(description="Field name to match") String fieldName, @ToolParam(description="Field value to match") String fieldValue, @ToolParam(required=false,description="Expansion paths") String expansion)
    • searchEntity

      @Tool(name="search-entity", description="Search entities by type with filter criteria.") public String searchEntity(@ToolParam(description="Entity type name") String entityType, @ToolParam(description="Search criteria map") Map<String,Object> searchFields, @ToolParam(description="Max results; -1 for no limit") int searchResultLimit, @ToolParam(description="0-indexed page number") int page, @ToolParam(required=false,description="Sort field(s), comma-separated") String sortBy, @ToolParam(required=false,description="Sort ascending; defaults to true") Boolean sortAscending, @ToolParam(required=false,description="Expansion paths") String expansion)
    • createEntity

      @Tool(name="create-entity", description="Create a new entity with the given field values.") public String createEntity(@ToolParam(description="Entity type name") String entityType, @ToolParam(description="Field names to values") Map<String,Object> fields, @ToolParam(required=false,description="Config audit feature branch") String featureBranch)
    • updateEntity

      @Tool(name="update-entity", description="Update an existing entity\'s fields by type and id.") public String updateEntity(@ToolParam(description="Entity type name") String entityType, @ToolParam(description="Entity id to update") String entityId, @ToolParam(description="Field names to updated values") Map<String,Object> fields, @ToolParam(required=false,description="Config audit feature branch") String featureBranch)
    • deleteEntity

      @Tool(name="delete-entity", description="Delete an entity by type and id.") public String deleteEntity(@ToolParam(description="Entity type name") String entityType, @ToolParam(description="Entity id to delete") String entityId, @ToolParam(required=false,description="Config audit feature branch") String featureBranch)
    • toJson

      protected String toJson(Object value)
      Serializes value to a compact JSON string (no indent). Returns {"error":"serialization failed"} if serialization throws.
      Parameters:
      value - the object to serialize; may be null
      Returns:
      compact JSON string
    • bytesToString

      protected String bytesToString(byte[] bytes)
      Decodes a byte array to a UTF-8 string. Used to convert binary report output to a returnable string.
      Parameters:
      bytes - raw bytes
      Returns:
      decoded string
    • handleTool

      protected String handleTool(Callable<Object> action)
      Invokes action, serializes the result with toJson(java.lang.Object), and returns it. Any exception thrown by the action is caught and converted to a standard {"error":"<message>"} response via errorJson(java.lang.Exception). Use this in every @Tool method to eliminate identical try/catch boilerplate.
      Parameters:
      action - the tool logic to invoke; may throw any exception
      Returns:
      compact JSON string — the serialized result on success, or an error object on failure
    • errorJson

      protected String errorJson(Exception e)
      Produces a standard {"error":"<message>"} JSON response from an exception. Falls back to the simple class name when Throwable.getMessage() is null.
      Parameters:
      e - the exception to convert
      Returns:
      JSON error string