1- import type { CallToolRequest , CallToolResult , ListToolsRequest } from '@modelcontextprotocol/client' ;
1+ import type { CallToolResult , ListToolsRequest } from '@modelcontextprotocol/client' ;
22import { Client , StreamableHTTPClientTransport } from '@modelcontextprotocol/client' ;
33
44/**
@@ -108,58 +108,40 @@ async function listTools(client: Client): Promise<void> {
108108async function startParallelNotificationTools ( client : Client ) : Promise < Record < string , CallToolResult > > {
109109 try {
110110 // Define multiple tool calls with different configurations
111- const toolCalls : Array < { caller : string ; request : CallToolRequest } > = [
111+ const toolCalls = [
112112 {
113113 caller : 'fast-notifier' ,
114- request : {
115- method : 'tools/call' ,
116- params : {
117- name : 'start-notification-stream' ,
118- arguments : {
119- interval : 2 , // 0.5 second between notifications
120- count : 10 , // Send 10 notifications
121- caller : 'fast-notifier' // Identify this tool call
122- }
123- }
114+ args : {
115+ interval : 2 , // 0.5 second between notifications
116+ count : 10 , // Send 10 notifications
117+ caller : 'fast-notifier' // Identify this tool call
124118 }
125119 } ,
126120 {
127121 caller : 'slow-notifier' ,
128- request : {
129- method : 'tools/call' ,
130- params : {
131- name : 'start-notification-stream' ,
132- arguments : {
133- interval : 5 , // 2 seconds between notifications
134- count : 5 , // Send 5 notifications
135- caller : 'slow-notifier' // Identify this tool call
136- }
137- }
122+ args : {
123+ interval : 5 , // 2 seconds between notifications
124+ count : 5 , // Send 5 notifications
125+ caller : 'slow-notifier' // Identify this tool call
138126 }
139127 } ,
140128 {
141129 caller : 'burst-notifier' ,
142- request : {
143- method : 'tools/call' ,
144- params : {
145- name : 'start-notification-stream' ,
146- arguments : {
147- interval : 1 , // 0.1 second between notifications
148- count : 3 , // Send just 3 notifications
149- caller : 'burst-notifier' // Identify this tool call
150- }
151- }
130+ args : {
131+ interval : 1 , // 0.1 second between notifications
132+ count : 3 , // Send just 3 notifications
133+ caller : 'burst-notifier' // Identify this tool call
152134 }
153135 }
154136 ] ;
155137
156138 console . log ( `Starting ${ toolCalls . length } notification tools in parallel...` ) ;
157139
158140 // Start all tool calls in parallel
159- const toolPromises = toolCalls . map ( ( { caller, request } ) => {
141+ const toolPromises = toolCalls . map ( ( { caller, args } ) => {
160142 console . log ( `Starting tool call for ${ caller } ...` ) ;
161143 return client
162- . request ( request )
144+ . callTool ( { name : 'start-notification-stream' , arguments : args } )
163145 . then ( result => ( { caller, result } ) )
164146 . catch ( error => {
165147 console . error ( `Error in tool call for ${ caller } :` , error ) ;
@@ -173,7 +155,7 @@ async function startParallelNotificationTools(client: Client): Promise<Record<st
173155 // Organize results by caller
174156 const resultsByTool : Record < string , CallToolResult > = { } ;
175157 for ( const { caller, result } of results ) {
176- resultsByTool [ caller ] = result as CallToolResult ;
158+ resultsByTool [ caller ] = result ;
177159 }
178160
179161 return resultsByTool ;
0 commit comments