Package com.ssgllc.fish.config.mcp
Class McpEntityConfig.EntityTools
java.lang.Object
com.ssgllc.fish.config.mcp.McpEntityConfig.EntityTools
- Enclosing class:
McpEntityConfig
Tool implementations for entity CRUD operations.
Delegates to EntityUtil static methods,
which go through the standard Casetivity service and security layer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.fasterxml.jackson.databind.ObjectMapper -
Method Summary
Modifier and TypeMethodDescriptionprotected StringbytesToString(byte[] bytes) Decodes a byte array to a UTF-8 string.deleteEntity(String entityType, String entityId, String featureBranch) protected StringProduces a standard{"error":"<message>"}JSON response from an exception.findEntity(String entityType, String fieldName, String fieldValue, String expansion) getDomainEntity(String entityType, String entityId) Fetches the entity DTO.protected StringhandleTool(Callable<Object> action) Invokesaction, serializes the result withtoJson(java.lang.Object), and returns it.searchEntity(String entityType, Map<String, Object> searchFields, int searchResultLimit, int page, String sortBy, Boolean sortAscending, String expansion) protected StringSerializesvalueto a compact JSON string (no indent).
-
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. Useexpansionto eagerly load related objects (e.g."assignedTo,notes").- Parameters:
entityType- entity type nameentityId- entity UUID or string idexpansion- optional dot-separated or comma-separated expansion paths- Returns:
- entity DTO as JSON, or an error object if not found
-
getDomainEntity
-
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
Serializesvalueto a compact JSON string (no indent). Returns{"error":"serialization failed"}if serialization throws.- Parameters:
value- the object to serialize; may benull- Returns:
- compact JSON string
-
bytesToString
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
Invokesaction, serializes the result withtoJson(java.lang.Object), and returns it. Any exception thrown by the action is caught and converted to a standard{"error":"<message>"}response viaerrorJson(java.lang.Exception). Use this in every@Toolmethod 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
Produces a standard{"error":"<message>"}JSON response from an exception. Falls back to the simple class name whenThrowable.getMessage()is null.- Parameters:
e- the exception to convert- Returns:
- JSON error string
-