基于langchain4j和远程mcp服务搭建的一个agentdemo,有一些参数不需要大模型来解析传递,而是通过类似上下文那样传递,有办法传么
interface Assistant {
Result<String> chat(String userMessage);
}
McpTransport transport = new HttpMcpTransport.Builder()
.sseUrl("http://localhost:9999/sse")
.logRequests(true) // if you want to see the traffic in the log
.logResponses(true)
.build();
McpClient invoiceClient = new DefaultMcpClient.Builder().key("invoiceClient").transport(transport).build();
McpToolProvider build1 = McpToolProvider.builder().mcpClients(invoiceClient).build();
Assistant mcpAssistant = AiServices.builder(Assistant.class)
.chatModel(chatModel)
.toolProvider(build1)
.chatMemory(MessageWindowChatMemory.withMaxMessages(10))
.build();
//远程mcp方法
@Service
public class InvoiceToolDemo implements InvoiceToolDemoService {
@Override
@Tool(name = "add",description = "计算两个数的和")
public double add(double a, double b,String name) {
return a + b;
}
}
add方法中,a和b是有llm解析传入,但是这个name我希望是在代码里传入的,这个有什么好的办法么,我查了相关资料,都是介绍在一个进程里传递,这种远程mcp服务的没找到相关介绍