You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Service
public class MemberTool {
@Tool(description = "Query the user's order")
public Map memberOrderInfo(Long memberId, Long orderNo){
//...
}
}
MCP client
ChatClient.create(chatModel)
.user("query my order by 100001")
.mcpContext(Map.of("memberId", "10")) //Expected Behavior
.call()
.content();
org.springframework.ai.tool.ToolCallback
default String call(String toolInput, @Nullable ToolContext tooContext) {
if (tooContext != null && !tooContext.getContext().isEmpty()) {
throw new UnsupportedOperationException("Tool context is not supported!");
}
return call(toolInput);
}
org.springframework.ai.mcp.AsyncMcpToolCallback || SyncMcpToolCallback
@Override
public String call(String functionInput) {
Map<String, Object> arguments = ModelOptionsUtils.jsonToMap(functionInput);
// Expected Behavior , If there is a duplicate of "memberId", "mcpContext" will be given the highest priority
arguments.putAll(mcpContext);
return this.asyncMcpClient.callTool(new CallToolRequest(this.getToolDefinition().name(), arguments))
.map(response -> ModelOptionsUtils.toJsonString(response.content()))
.block();
}
Of course, the solution won't be as simple as mentioned above. This is also related to the parameter extraction and transformation of the "ai model". Or there could be other ways to pass additional parameters each time interacting with the "MCP Server". This might conflict with the "MCP" protocol
MCP Server
@Service
public class MemberTool {
@Tool(description = "Query the user's order")
public Map memberOrderInfo(Long memberId, Long orderNo){
// Long other = xxxContext.get("other")
}
}
I know this function can be achieved through "Tool Calling".
Service interfaces are provided among project teams through MCP. It is necessary to customize the Settings of sensitive parameters to prevent users from tampering through "ai model prompt"
If MCP could achieve the same function, it would be a very good solution.
Looking forward to your reply. Thank
The text was updated successfully, but these errors were encountered:
Expected Behavior
MCP Server
MCP client
Of course, the solution won't be as simple as mentioned above. This is also related to the parameter extraction and transformation of the "ai model". Or there could be other ways to pass additional parameters each time interacting with the "MCP Server". This might conflict with the "MCP" protocol
MCP Server
I know this function can be achieved through "Tool Calling".
Service interfaces are provided among project teams through MCP. It is necessary to customize the Settings of sensitive parameters to prevent users from tampering through "ai model prompt"
If MCP could achieve the same function, it would be a very good solution.
Looking forward to your reply. Thank
The text was updated successfully, but these errors were encountered: