generate some README
This commit is contained in:
parent
c248642d52
commit
b378ab73dd
1 changed files with 166 additions and 13 deletions
|
|
@ -28,7 +28,7 @@ public class McpApplication {
|
|||
return args -> {
|
||||
|
||||
var chatClient = chatClientBuilder.defaultFunctions(functionCallbacks.toArray(new McpFunctionCallback[0]))
|
||||
.build();
|
||||
.build();
|
||||
|
||||
var response = chatClient.prompt("What is the content of the test.txt file?").call().content();
|
||||
|
||||
|
|
@ -36,8 +36,8 @@ public class McpApplication {
|
|||
|
||||
response = chatClient.prompt(
|
||||
"Please summarize the content of the test.txt file, covert the result in markdown format and store it into test.md")
|
||||
.call()
|
||||
.content();
|
||||
.call()
|
||||
.content();
|
||||
System.out.println("Summary:" + response);
|
||||
};
|
||||
}
|
||||
|
|
@ -46,22 +46,22 @@ public class McpApplication {
|
|||
public List<McpFunctionCallback> functionCallbacks(McpSyncClient mcpClient) {
|
||||
|
||||
return mcpClient.listTools(null)
|
||||
.tools()
|
||||
.stream()
|
||||
.map(tool -> new McpFunctionCallback(mcpClient, tool))
|
||||
.toList();
|
||||
.tools()
|
||||
.stream()
|
||||
.map(tool -> new McpFunctionCallback(mcpClient, tool))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Bean(destroyMethod = "close")
|
||||
public McpSyncClient clientSession() {
|
||||
|
||||
var stdioParams = ServerParameters.builder("npx")
|
||||
.args("-y", "@modelcontextprotocol/server-filesystem",
|
||||
"/Users/christiantzolov/Dev/projects/demo/mcp-server/dir")
|
||||
.build();
|
||||
.args("-y", "@modelcontextprotocol/server-filesystem",
|
||||
"/Users/christiantzolov/Dev/projects/demo/mcp-server/dir")
|
||||
.build();
|
||||
|
||||
McpSyncClient mcpClient = null;
|
||||
try {
|
||||
try {
|
||||
mcpClient = McpClient.sync(new StdioServerTransport(stdioParams),
|
||||
Duration.ofSeconds(10), new ObjectMapper());
|
||||
|
||||
|
|
@ -70,8 +70,7 @@ public class McpApplication {
|
|||
System.out.println("MCP Initialized: " + init);
|
||||
|
||||
return mcpClient;
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue