avancement planning
This commit is contained in:
Generated
Vendored
+7
-6
@@ -1,6 +1,6 @@
|
||||
import { Client } from '../../client/index.js';
|
||||
import { StreamableHTTPClientTransport } from '../../client/streamableHttp.js';
|
||||
import { ListToolsResultSchema, CallToolResultSchema, LoggingMessageNotificationSchema, } from '../../types.js';
|
||||
import { ListToolsResultSchema, CallToolResultSchema, LoggingMessageNotificationSchema } from '../../types.js';
|
||||
/**
|
||||
* Parallel Tool Calls MCP Client
|
||||
*
|
||||
@@ -23,7 +23,7 @@ async function main() {
|
||||
name: 'parallel-tool-calls-client',
|
||||
version: '1.0.0'
|
||||
});
|
||||
client.onerror = (error) => {
|
||||
client.onerror = error => {
|
||||
console.error('Client error:', error);
|
||||
};
|
||||
// Connect to the server
|
||||
@@ -31,12 +31,12 @@ async function main() {
|
||||
await client.connect(transport);
|
||||
console.log('Successfully connected to MCP server');
|
||||
// Set up notification handler with caller identification
|
||||
client.setNotificationHandler(LoggingMessageNotificationSchema, (notification) => {
|
||||
client.setNotificationHandler(LoggingMessageNotificationSchema, notification => {
|
||||
console.log(`Notification: ${notification.params.data}`);
|
||||
});
|
||||
console.log("List tools");
|
||||
console.log('List tools');
|
||||
const toolsRequest = await listTools(client);
|
||||
console.log("Tools: ", toolsRequest);
|
||||
console.log('Tools: ', toolsRequest);
|
||||
// 2. Start multiple notification tools in parallel
|
||||
console.log('\n=== Starting Multiple Notification Streams in Parallel ===');
|
||||
const toolResults = await startParallelNotificationTools(client);
|
||||
@@ -144,7 +144,8 @@ async function startParallelNotificationTools(client) {
|
||||
// Start all tool calls in parallel
|
||||
const toolPromises = toolCalls.map(({ caller, request }) => {
|
||||
console.log(`Starting tool call for ${caller}...`);
|
||||
return client.request(request, CallToolResultSchema)
|
||||
return client
|
||||
.request(request, CallToolResultSchema)
|
||||
.then(result => ({ caller, result }))
|
||||
.catch(error => {
|
||||
console.error(`Error in tool call for ${caller}:`, error);
|
||||
|
||||
Reference in New Issue
Block a user