Package io.meeds.mcp.server.util
Class McpToolUtils
java.lang.Object
io.meeds.mcp.server.util.McpToolUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatDate(Long time) static StringformatDate(Date date) static final ToolDefinitionMethodsfromJsonString(String value) static ToolDefinitionMethodsfromJsonStringBase64(String value) static StringResolves the AI chat conversation in which the current Tool is executed.static StringResolves the user on behalf of whom the current Tool is executed: the kernelConversationStateidentity when set, else, for the internal client-credentials call only, theTOOL_CONTEXT_USER_NAME_PARAMrequest header, else the authenticated principal.static ObjectgetMethodToolFieldValue(org.springframework.ai.tool.method.MethodToolCallback toolCallback, String fieldName) static TimeZonestatic StringmarkdownToHtml(String markdown) static List<SimpleToolDefinition> parseToolDefinitions(URL url) static StringtoCamelCase(String name) static Datestatic StringtoJsonStringBase64(ToolDefinitionMethods toolDefinitions) static StringtoSnakeCase(String name)
-
Field Details
-
AI_AGENT_TOOL_EXECUTION_EVENT
- See Also:
-
MCP_OAUTH2_CLIENT_CREDENTIALS_REGISTRATION_ID
- See Also:
-
TOOL_CONTEXT_USER_NAME_PARAM
- See Also:
-
TOOL_CONTEXT_ID_PARAM
- See Also:
-
TOOL_CONTEXT_CONVERSATION_ID_PARAM
- See Also:
-
TOOL_CONTEXT_ID
-
TOOL_READ_SCOPE
- See Also:
-
TOOL_WRITE_SCOPE
- See Also:
-
TOOL_WRITE_APPROVE_SCOPE
- See Also:
-
EVENT_TOOL_UPDATED
- See Also:
-
AI_AGENT_TOOL_APPROVED_PARAM
- See Also:
-
AI_AGENT_TOOL_USERNAME_PARAM
- See Also:
-
AI_AGENT_TOOL_CONVERSATION_ID_PARAM
- See Also:
-
AI_AGENT_TOOL_INPUT_PARAM
- See Also:
-
AI_AGENT_TOOL_OUTPUT_PARAM
- See Also:
-
AI_AGENT_TOOL_TYPE_PARAM
- See Also:
-
AI_AGENT_TOOL_DURATION_PARAM
- See Also:
-
AI_AGENT_TOOL_START_TIME_PARAM
- See Also:
-
AI_AGENT_TOOL_ID_PARAM
- See Also:
-
AI_AGENT_TOOL_NAME_PARAM
- See Also:
-
AI_AGENT_TOOL_EXEC_COMPLETED_PARAM
- See Also:
-
-
Method Details
-
parseToolDefinitions
-
fromJsonString
-
fromJsonStringBase64
-
toJsonStringBase64
-
toSnakeCase
-
toCamelCase
-
getMethodToolFieldValue
public static Object getMethodToolFieldValue(org.springframework.ai.tool.method.MethodToolCallback toolCallback, String fieldName) throws NoSuchFieldException, IllegalAccessException -
getCurrentUserName
Resolves the user on behalf of whom the current Tool is executed: the kernelConversationStateidentity when set, else, for the internal client-credentials call only, theTOOL_CONTEXT_USER_NAME_PARAMrequest header, else the authenticated principal. The header is trusted under the gate ofgetInternalToolCallRequest()and nowhere else; the internal call is recognized by the OAuth client that owns the token (isInternalClientAuthentication(Authentication)), never by the token subject, so a user whose login happens to be the internal client id is just that user.- Returns:
- the user name, or null when no user can be resolved
-
getCurrentConversationId
Resolves the AI chat conversation in which the current Tool is executed. The id travels in theTOOL_CONTEXT_CONVERSATION_ID_PARAMrequest header set by the internal MCP client and is trusted under exactly the same gate as the user name (getInternalToolCallRequest()): any other caller, an external OAuth MCP client for instance, gets null whatever it sends, so it can never choose the conversation its Tool executions are recorded in.- Returns:
- the conversation id, or null when the call isn't the internal client's or carries no conversation
-
markdownToHtml
-
toDate
-
formatDate
-
formatDate
-
getUserTimeZone
-