This commit is contained in:
ihrpr 2025-04-21 15:31:38 +01:00
commit 6050aa9f05
No known key found for this signature in database
2 changed files with 13 additions and 264 deletions

View file

@ -4,6 +4,7 @@ import {
CallToolRequest,
CallToolResultSchema,
LoggingMessageNotificationSchema,
CallToolResult,
} from '../../types.js';
/**
@ -23,12 +24,12 @@ interface ClientConfig {
id: string;
name: string;
toolName: string;
toolArguments: Record<string, any>;
toolArguments: Record<string, string | number | boolean>;
}
async function createAndRunClient(config: ClientConfig): Promise<{ id: string; result: any }> {
async function createAndRunClient(config: ClientConfig): Promise<{ id: string; result: CallToolResult }> {
console.log(`[${config.id}] Creating client: ${config.name}`);
const client = new Client({
name: config.name,
version: '1.0.0'
@ -101,7 +102,7 @@ async function main(): Promise<void> {
}
},
{
id: 'client2',
id: 'client2',
name: 'basic-client-2',
toolName: 'start-notification-stream',
toolArguments: {

View file

@ -3,9 +3,9 @@ import { StreamableHTTPClientTransport } from '../../client/streamableHttp.js';
import {
ListToolsRequest,
ListToolsResultSchema,
CallToolRequest,
CallToolResultSchema,
LoggingMessageNotificationSchema,
CallToolResult,
} from '../../types.js';
/**
@ -57,11 +57,11 @@ async function main(): Promise<void> {
// 2. Start multiple notification tools in parallel
console.log('\n=== Starting Multiple Notification Streams in Parallel ===');
const toolResults = await startParallelNotificationTools(client);
// Log the results from each tool call
for (const [caller, result] of Object.entries(toolResults)) {
console.log(`\n=== Tool result for ${caller} ===`);
result.content.forEach((item: { type: string; text: any; }) => {
result.content.forEach((item: { type: string; text?: string; }) => {
if (item.type === 'text') {
console.log(` ${item.text}`);
} else {
@ -113,7 +113,7 @@ async function listTools(client: Client): Promise<void> {
* Start multiple notification tools in parallel with different configurations
* Each tool call includes a caller parameter to identify its notifications
*/
async function startParallelNotificationTools(client: Client): Promise<Record<string, any>> {
async function startParallelNotificationTools(client: Client): Promise<Record<string, CallToolResult>> {
try {
// Define multiple tool calls with different configurations
const toolCalls = [
@ -162,7 +162,7 @@ async function startParallelNotificationTools(client: Client): Promise<Record<st
];
console.log(`Starting ${toolCalls.length} notification tools in parallel...`);
// Start all tool calls in parallel
const toolPromises = toolCalls.map(({ caller, request }) => {
console.log(`Starting tool call for ${caller}...`);
@ -176,9 +176,9 @@ async function startParallelNotificationTools(client: Client): Promise<Record<st
// Wait for all tool calls to complete
const results = await Promise.all(toolPromises);
// Organize results by caller
const resultsByTool: Record<string, any> = {};
const resultsByTool: Record<string, CallToolResult> = {};
results.forEach(({ caller, result }) => {
resultsByTool[caller] = result;
});