Package com.ssgllc.fish.config.mcp
Class McpConfigMgmt.ConfigMgmtTools
java.lang.Object
com.ssgllc.fish.config.mcp.McpConfigMgmt.ConfigMgmtTools
- Enclosing class:
McpConfigMgmt
Tool implementations for config-branch management.
Each tool replicates exactly what ConfigMgmtResource does,
including the ROLE_SUPER gate (enforced here with an explicit
SecurityUtils.isCurrentUserSuper() check, because @PreAuthorize does not fire on
MCP tool methods — they are plain POJOs invoked by Spring AI, not Spring-proxied beans).
-
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.deleteConfigBranch(String branch) protected StringProduces a standard{"error":"<message>"}JSON response from an exception.protected StringhandleTool(Callable<Object> action) Invokesaction, serializes the result withtoJson(java.lang.Object), and returns it.mergeConfigBranchToStable(String branch, String message) protected StringSerializesvalueto a compact JSON string (no indent).
-
Field Details
-
mapper
protected final com.fasterxml.jackson.databind.ObjectMapper mapper
-
-
Method Details
-
listConfigBranches
@Tool(name="list-config-branches", description="List the config feature branches in the configuration git repository.") public String listConfigBranches() -
getConfigStatus
@Tool(name="get-config-status", description="Get the configuration git repository status (last/most-recent revision, node, conflict state). Requires ROLE_SUPER.") public String getConfigStatus() -
getConfigCommits
@Tool(name="get-config-commits", description="List config commits on the current feature branch that are not yet on the stable branch. Requires ROLE_SUPER.") public String getConfigCommits() -
mergeConfigBranchToStable
@Tool(name="merge-config-branch-to-stable", description="Squash-merge a config feature branch into the stable branch. Queues the merge and returns immediately; poll get-config-status for completion or conflicts. Requires ROLE_SUPER.") public String mergeConfigBranchToStable(@ToolParam(description="Config feature branch to squash-merge into stable") String branch, @ToolParam(required=false,description="Commit message for the squash-merge") String message) -
deleteConfigBranch
-
resolveConfigConflict
@Tool(name="resolve-config-conflict", description="Clear the repository\'s conflicted flag after a merge conflict has been resolved out-of-band. Requires ROLE_SUPER.") public String resolveConfigConflict() -
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
-