@@ -151,14 +151,9 @@ export const registerTriggerAgenticSamplingTool = (server: McpServer) => {
151151 "tools" in samplingCapability ;
152152
153153 if ( ! clientSupportsSamplingWithTools ) {
154- console . log (
155- "[trigger-agentic-sampling] Not registering - client does not support sampling.tools"
156- ) ;
157154 return ;
158155 }
159156
160- console . log ( "[trigger-agentic-sampling] Registering - client supports sampling.tools" ) ;
161-
162157 server . registerTool ( name , config , async ( args , extra ) : Promise < CallToolResult > => {
163158 const validatedArgs = TriggerAgenticSamplingSchema . parse ( args ) ;
164159 const { prompt, maxTokens, maxIterations, availableTools } = validatedArgs ;
@@ -180,7 +175,7 @@ export const registerTriggerAgenticSamplingTool = (server: McpServer) => {
180175 } ;
181176 }
182177
183- console . log (
178+ console . error (
184179 `[trigger-agentic-sampling] Starting with prompt: "${ prompt . substring ( 0 , 50 ) } ..." ` +
185180 `(${ tools . length } tools, max ${ maxIterations } iterations)`
186181 ) ;
@@ -200,7 +195,7 @@ export const registerTriggerAgenticSamplingTool = (server: McpServer) => {
200195 // Agentic loop
201196 while ( iteration < maxIterations ) {
202197 iteration ++ ;
203- console . log ( `[trigger-agentic-sampling] Iteration ${ iteration } /${ maxIterations } ` ) ;
198+ console . error ( `[trigger-agentic-sampling] Iteration ${ iteration } /${ maxIterations } ` ) ;
204199
205200 // Build and send sampling request
206201 // On last iteration, use toolChoice: none to force final response
@@ -223,7 +218,7 @@ export const registerTriggerAgenticSamplingTool = (server: McpServer) => {
223218 // Send the sampling request to the client
224219 const result = await extra . sendRequest ( request , CreateMessageResultWithToolsSchema ) ;
225220
226- console . log ( `[trigger-agentic-sampling] Got response with stopReason: ${ result . stopReason } ` ) ;
221+ console . error ( `[trigger-agentic-sampling] Got response with stopReason: ${ result . stopReason } ` ) ;
227222
228223 // Check if LLM wants to use tools
229224 if ( result . stopReason === "toolUse" ) {
@@ -234,7 +229,7 @@ export const registerTriggerAgenticSamplingTool = (server: McpServer) => {
234229 ) ;
235230
236231 if ( toolUseBlocks . length === 0 ) {
237- console . log (
232+ console . error (
238233 "[trigger-agentic-sampling] stopReason=toolUse but no tool_use blocks found"
239234 ) ;
240235 finalResponse = "Error: Received toolUse stop reason but no tool_use blocks" ;
@@ -250,7 +245,7 @@ export const registerTriggerAgenticSamplingTool = (server: McpServer) => {
250245 // Execute each tool and collect results
251246 const toolResults : ToolResultContent [ ] = [ ] ;
252247 for ( const toolUse of toolUseBlocks ) {
253- console . log (
248+ console . error (
254249 `[trigger-agentic-sampling] Executing tool: ${ toolUse . name } (${ JSON . stringify ( toolUse . input ) } )`
255250 ) ;
256251
@@ -284,7 +279,7 @@ export const registerTriggerAgenticSamplingTool = (server: McpServer) => {
284279 textBlock ?. type === "text"
285280 ? ( textBlock as TextContent ) . text
286281 : JSON . stringify ( result . content ) ;
287- console . log (
282+ console . error (
288283 `[trigger-agentic-sampling] Final response received (stopReason: ${ result . stopReason } )`
289284 ) ;
290285 break ;
0 commit comments