@@ -589,11 +589,13 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
589
589
590
590
591
591
server . setRequestHandler ( CallToolRequestSchema , async ( request ) => {
592
+ // Generate a unique prompt ID for this request that remains stable across multiple calls
593
+ // We'll use a combination of the current hour and minute to make it stable for a short period
594
+ const now = new Date ( ) ;
595
+ const promptId = `prompt-${ now . getFullYear ( ) } ${ now . getMonth ( ) } ${ now . getDate ( ) } -${ now . getHours ( ) } ${ now . getMinutes ( ) } ` ;
596
+
592
597
try {
593
598
const { name, arguments : args } = request . params ;
594
-
595
- // Generate a unique prompt ID for this request
596
- const promptId = 'prompt-' + Date . now ( ) + '-' + Math . floor ( Math . random ( ) * 10000 ) ;
597
599
598
600
// Get the response from the appropriate tool handler
599
601
let response ;
@@ -839,13 +841,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
839
841
throw new Error ( `Unknown tool: ${ name } ` ) ;
840
842
}
841
843
842
- // Reset validation state after successful response
843
- await resetValidationState ( ) ;
844
+ // Reset validation state after successful response, but preserve state within the same prompt
845
+ await resetValidationState ( promptId ) ;
844
846
845
847
return response ;
846
848
} catch ( error ) {
847
- // Reset validation state even on error
848
- await resetValidationState ( ) ;
849
+ // Reset validation state even on error, but preserve state within the same prompt
850
+ await resetValidationState ( promptId ) ;
849
851
850
852
const errorMessage = error instanceof Error ? error . message : String ( error ) ;
851
853
return {
0 commit comments