Skip to content

Commit bdd3f3b

Browse files
committed
Fixed round counter, and prettified output and removed unused cli options
1 parent 56f8209 commit bdd3f3b

File tree

4 files changed

+34
-66
lines changed

4 files changed

+34
-66
lines changed

mcp-test-client/src/generic-orchestrator.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,22 @@ export class GenericOrchestrator {
6969
console.log(chalk.gray(` ${JSON.stringify(capabilities, null, 2).substring(0, 500)}...`));
7070
}
7171

72-
let round = 0;
72+
let round = 1; // Start at 1 since initial LLM call is Round 1
7373
const maxRounds = this.config.maxRounds || 10;
7474
const steps: ExecutionStep[] = [];
7575

76+
// Round 1: Initial LLM call
77+
if (this.config.enableLogging) {
78+
console.log(chalk.blue(`\n${'='.repeat(80)}`));
79+
console.log(chalk.blue(`🔄 [Orchestrator] Round ${round}/${maxRounds}`));
80+
console.log(chalk.blue(`${'='.repeat(80)}`));
81+
}
82+
7683
// Start conversation with LLM
7784
let llmResponse = await this.llm.processUserPrompt(userPrompt, capabilities);
7885

7986
if (this.config.enableLogging) {
80-
console.log(chalk.magenta(`\n🤖 [Orchestrator] LLM Initial Response:`));
87+
console.log(chalk.magenta(`\n🤖 [Orchestrator] LLM Round ${round} Response:`));
8188
console.log(chalk.gray(` 📝 Content: ${llmResponse.content?.substring(0, 100) || 'No content'}...`));
8289
console.log(chalk.gray(` 🔄 Needs more data: ${llmResponse.needsMoreData}`));
8390
console.log(chalk.gray(` 📋 Requests: ${llmResponse.requests?.length || 0}`));
@@ -90,16 +97,19 @@ export class GenericOrchestrator {
9097

9198
// Multi-round conversation loop
9299
while (llmResponse.needsMoreData && round < maxRounds) {
100+
// Execute requests from current round
101+
const results = await this.executeRequests(llmResponse.requests || [], steps);
102+
103+
// Move to next round
93104
round++;
94105

95106
if (this.config.enableLogging) {
96-
console.log(chalk.blue(`\n🔄 [Orchestrator] Round ${round}/${maxRounds}`));
107+
console.log(chalk.blue(`\n${'='.repeat(80)}`));
108+
console.log(chalk.blue(`🔄 [Orchestrator] Round ${round}/${maxRounds}`));
109+
console.log(chalk.blue(`${'='.repeat(80)}`));
97110
}
98-
99-
// Execute LLM's requests
100-
const results = await this.executeRequests(llmResponse.requests || [], steps);
101111

102-
// Send results back to LLM
112+
// Send results back to LLM for next round
103113
llmResponse = await this.llm.processResults(results);
104114

105115
if (this.config.enableLogging) {
@@ -110,6 +120,13 @@ export class GenericOrchestrator {
110120
}
111121
}
112122

123+
// Add closing separator
124+
if (this.config.enableLogging) {
125+
console.log(chalk.blue(`\n${'='.repeat(80)}`));
126+
console.log(chalk.blue(`📊 [Orchestrator] Conversation Complete`));
127+
console.log(chalk.blue(`${'='.repeat(80)}`));
128+
}
129+
113130
// Circuit breaker check
114131
const success = round < maxRounds;
115132
if (!success && this.config.enableLogging) {

mcp-test-client/src/index.ts

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ async function main() {
106106
name: 'action',
107107
message: 'What would you like to do?',
108108
choices: [
109-
{ name: '💬 Ask a custom question (Real LLM)', value: 'custom_prompt' },
110109
{ name: '🎬 Try a scenario prompt (Real LLM)', value: 'run_scenario' },
111-
{ name: '📋 List MCP capabilities', value: 'list_capabilities' },
112110
{ name: '🚪 Exit', value: 'exit' }
113111
]
114112
}
@@ -119,14 +117,6 @@ async function main() {
119117
await runScenarioWithRealLLM(orchestrator, testData);
120118
break;
121119

122-
case 'custom_prompt':
123-
await askCustomQuestion(orchestrator);
124-
break;
125-
126-
case 'list_capabilities':
127-
await listCapabilities(orchestrator);
128-
break;
129-
130120
case 'exit':
131121
exit = true;
132122
console.log(chalk.blue(`👋 Goodbye!`));
@@ -161,52 +151,14 @@ async function runScenarioWithRealLLM(orchestrator: GenericOrchestrator, testDat
161151
console.log(chalk.blue(`\n📊 Results:`));
162152
console.log(chalk.gray(` ${result.success ? '✅' : '❌'} Success: ${result.success}`));
163153
console.log(chalk.gray(` 🔄 Rounds: ${result.rounds}`));
164-
console.log(chalk.gray(` 📋 Steps: ${result.steps.length}`));
165154

166155
if (result.response) {
167156
console.log(chalk.green(`\n💬 Final Response:`));
168157
console.log(chalk.white(result.response));
169158
}
170159
}
171160

172-
async function askCustomQuestion(orchestrator: GenericOrchestrator) {
173-
const { userPrompt } = await inquirer.prompt([
174-
{
175-
type: 'input',
176-
name: 'userPrompt',
177-
message: 'What would you like to ask the LLM?',
178-
validate: (input: string) => input.trim().length > 0 || 'Please enter a question'
179-
}
180-
]);
181-
182-
console.log(chalk.cyan(`\n🤖 Processing your question...`));
183-
console.log(chalk.gray(`📝 Question: "${userPrompt}"`));
184-
185-
const result = await orchestrator.handleUserPrompt(userPrompt);
186-
187-
console.log(chalk.blue(`\n📊 Results:`));
188-
console.log(chalk.gray(` ${result.success ? '✅' : '❌'} Success: ${result.success}`));
189-
console.log(chalk.gray(` 🔄 Rounds: ${result.rounds}`));
190-
console.log(chalk.gray(` 📋 Steps: ${result.steps.length}`));
191-
192-
if (result.response) {
193-
console.log(chalk.green(`\n💬 Final Response:`));
194-
console.log(chalk.white(result.response));
195-
}
196-
}
197161

198-
async function listCapabilities(orchestrator: GenericOrchestrator) {
199-
console.log(chalk.blue(`\n📋 Available MCP Capabilities:`));
200-
201-
try {
202-
// This is a bit of a hack since GenericOrchestrator doesn't expose getCapabilities
203-
// We'll need to add a method for this or access the client directly
204-
console.log(chalk.yellow(` ⚠️ Capability listing not yet implemented in configuration-driven architecture`));
205-
console.log(chalk.gray(` This would show available tools, resources, and prompts from connected MCP servers`));
206-
} catch (error) {
207-
console.log(chalk.red(` ❌ Error listing capabilities: ${(error as Error).message}`));
208-
}
209-
}
210162

211163
// Run the main function if this file is executed directly
212164
if (import.meta.url === `file://${process.argv[1]}`) {

mcp-test-client/tests/generic-orchestrator.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ describe('GenericOrchestrator', () => {
153153

154154
expect(result.success).toBe(true);
155155
expect(result.response).toBe('Hello, this is my response');
156-
expect(result.rounds).toBe(0);
156+
expect(result.rounds).toBe(1);
157157
expect(result.steps).toHaveLength(0);
158158
});
159159

@@ -179,7 +179,7 @@ describe('GenericOrchestrator', () => {
179179
const result = await orchestrator.handleUserPrompt('Execute a tool');
180180

181181
expect(result.success).toBe(true);
182-
expect(result.rounds).toBe(1);
182+
expect(result.rounds).toBe(2);
183183
expect(result.steps).toHaveLength(1);
184184
expect(result.steps[0].type).toBe('tool');
185185
expect(result.steps[0].name).toBe('test-tool');
@@ -208,7 +208,7 @@ describe('GenericOrchestrator', () => {
208208
const result = await orchestrator.handleUserPrompt('Get resource data');
209209

210210
expect(result.success).toBe(true);
211-
expect(result.rounds).toBe(1);
211+
expect(result.rounds).toBe(2);
212212
expect(result.steps).toHaveLength(1);
213213
expect(result.steps[0].type).toBe('resource');
214214
expect(result.steps[0].name).toBe('test://resource');
@@ -237,7 +237,7 @@ describe('GenericOrchestrator', () => {
237237
const result = await orchestrator.handleUserPrompt('Use a prompt');
238238

239239
expect(result.success).toBe(true);
240-
expect(result.rounds).toBe(1);
240+
expect(result.rounds).toBe(2);
241241
expect(result.steps).toHaveLength(1);
242242
expect(result.steps[0].type).toBe('prompt');
243243
expect(result.steps[0].name).toBe('test-prompt');
@@ -277,7 +277,7 @@ describe('GenericOrchestrator', () => {
277277
const result = await orchestrator.handleUserPrompt('Execute workflow');
278278

279279
expect(result.success).toBe(true);
280-
expect(result.rounds).toBe(2);
280+
expect(result.rounds).toBe(3);
281281
expect(result.steps).toHaveLength(2);
282282
expect(result.steps[0].type).toBe('resource');
283283
expect(result.steps[1].type).toBe('tool');
@@ -376,7 +376,7 @@ describe('GenericOrchestrator', () => {
376376
const result = await orchestrator.runScenario(testScenario);
377377

378378
expect(result.success).toBe(true);
379-
expect(result.rounds).toBe(1);
379+
expect(result.rounds).toBe(2);
380380
expect(result.steps).toHaveLength(1);
381381
});
382382
});
@@ -397,7 +397,7 @@ describe('GenericOrchestrator', () => {
397397
const result = await orchestrator.handleUserPrompt('Empty request');
398398

399399
expect(result.success).toBe(true);
400-
expect(result.rounds).toBe(1);
400+
expect(result.rounds).toBe(2);
401401
expect(result.steps).toHaveLength(0);
402402
});
403403

@@ -416,7 +416,7 @@ describe('GenericOrchestrator', () => {
416416
const result = await orchestrator.handleUserPrompt('Undefined requests');
417417

418418
expect(result.success).toBe(true);
419-
expect(result.rounds).toBe(1);
419+
expect(result.rounds).toBe(2);
420420
expect(result.steps).toHaveLength(0);
421421
});
422422

mcp-test-client/tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"moduleResolution": "node",
66
"lib": ["ES2022"],
77
"outDir": "./dist",
8-
8+
"rootDir": "./src",
99
"strict": true,
1010
"esModuleInterop": true,
1111
"skipLibCheck": true,
@@ -19,8 +19,7 @@
1919
"types": ["jest", "node"]
2020
},
2121
"include": [
22-
"src/**/*",
23-
"tests/**/*"
22+
"src/**/*"
2423
],
2524
"exclude": [
2625
"node_modules",

0 commit comments

Comments
 (0)