@@ -229,7 +229,7 @@ export class MCPClient {
229229 throw new Error ( `Prompt not found: ${ promptName } ` ) ;
230230 }
231231
232- console . log ( chalk . magenta ( `💬 [MCP Client] Executing prompt: ${ promptName } ` ) ) ;
232+ console . log ( chalk . magenta ( `💬 [MCP Client] Getting prompt template : ${ promptName } ` ) ) ;
233233 console . log ( chalk . gray ( ` 📋 Parameters: ${ JSON . stringify ( parameters ) } ` ) ) ;
234234
235235 try {
@@ -239,16 +239,18 @@ export class MCPClient {
239239 } ) ;
240240
241241 if ( response . error ) {
242- console . log ( chalk . yellow ( `⚠️ [MCP Client] Simulating prompt response due to error: ${ response . error . message } ` ) ) ;
243- return this . simulatePromptResponse ( promptName , parameters ) ;
242+ throw new Error ( `Failed to get prompt template: ${ response . error . message } ` ) ;
244243 }
245244
246- const result = response . result ?. messages ?. [ 0 ] ?. content ?. text || 'Prompt response received' ;
247- console . log ( chalk . green ( `✅ [MCP Client] Prompt executed successfully` ) ) ;
248- return result ;
245+ // Return the complete prompt template structure - this should be sent to LLM
246+ const promptTemplate = response . result ;
247+ console . log ( chalk . green ( `✅ [MCP Client] Retrieved prompt template successfully` ) ) ;
248+ console . log ( chalk . gray ( ` 📄 Template has ${ promptTemplate ?. messages ?. length || 0 } messages` ) ) ;
249+
250+ return promptTemplate ;
249251 } catch ( error ) {
250- console . log ( chalk . yellow ( `⚠️ [MCP Client] Simulating prompt response due to error : ${ ( error as Error ) . message } `) ) ;
251- return this . simulatePromptResponse ( promptName , parameters ) ;
252+ console . log ( chalk . red ( `❌ [MCP Client] Failed to get prompt template : ${ ( error as Error ) . message } `) ) ;
253+ throw error ;
252254 }
253255 }
254256
@@ -280,8 +282,7 @@ export class MCPClient {
280282 } ) ;
281283
282284 if ( response . error ) {
283- console . log ( chalk . yellow ( `⚠️ [MCP Client] Simulating resource response due to error: ${ response . error . message } ` ) ) ;
284- return this . simulateResourceResponse ( resourceUri ) ;
285+ throw new Error ( `Resource read error: ${ response . error . message } ` ) ;
285286 }
286287
287288 const result = response . result ?. contents ?. [ 0 ] ;
@@ -299,43 +300,10 @@ export class MCPClient {
299300 console . log ( chalk . green ( `✅ [MCP Client] Resource read successfully` ) ) ;
300301 return result ;
301302 } catch ( error ) {
302- console . log ( chalk . yellow ( `⚠️ [MCP Client] Simulating resource response due to error: ${ ( error as Error ) . message } ` ) ) ;
303- return this . simulateResourceResponse ( resourceUri ) ;
304- }
305- }
306-
307- private simulatePromptResponse ( promptName : string , parameters : Record < string , any > ) : string {
308- if ( promptName === 'fraud_analysis' ) {
309- return 'Based on the payment data provided, this appears to be a legitimate utility payment. The payee "Power Company Australia" is a known utility provider, and the payment amount of $750 is within normal range for utility bills.' ;
310- } else if ( promptName === 'loan_recommendation' ) {
311- return 'Based on the account history and current products (Complete Freedom Savings and Business Cheque), I recommend considering our Personal Loan at 6.5% APR for amounts up to $50,000, or our Home Equity Line of Credit at 4.2% APR for larger amounts.' ;
303+ console . log ( chalk . red ( `❌ [MCP Client] Resource read failed: ${ ( error as Error ) . message } ` ) ) ;
304+ throw error ;
312305 }
313- return `Analysis complete for ${ promptName } . This is a simulated response with parameters: ${ JSON . stringify ( parameters ) } ` ;
314306 }
315307
316- private simulateResourceResponse ( resourceUri : string ) : any {
317- if ( resourceUri . includes ( 'products' ) ) {
318- return {
319- contents : [ {
320- uri : resourceUri ,
321- mimeType : 'application/json' ,
322- text : JSON . stringify ( {
323- products : [
324- { id : 'SAV_001' , name : 'Basic Savings' , type : 'savings' , rate : 0.5 } ,
325- { id : 'CHK_001' , name : 'Premium Checking' , type : 'checking' , monthlyFee : 15 } ,
326- { id : 'LOAN_001' , name : 'Auto Loan' , type : 'loan' , rate : 4.5 }
327- ]
328- } )
329- } ]
330- } ;
331- }
332308
333- return {
334- contents : [ {
335- uri : resourceUri ,
336- mimeType : 'application/json' ,
337- text : JSON . stringify ( { data : `Resource data for ${ resourceUri } ` } )
338- } ]
339- } ;
340- }
341309}
0 commit comments