@@ -23,7 +23,13 @@ import { createProgressReporter, type ProgressReporter } from './tools/utils/pro
2323import { env } from './env.js' ;
2424import { createTemplateRenderer } from './tools/utils/templateRenderer.js' ;
2525import { createErrorTemplateRenderer } from './tools/utils/errorTemplateRenderer.js' ;
26- import { createTelemetryClient , detectPaginationUsed , parseTelemetryFlag , TelemetrySession , type ITelemetryClient } from './telemetry/index.js' ;
26+ import {
27+ createTelemetryClient ,
28+ detectPaginationUsed ,
29+ parseTelemetryFlag ,
30+ TelemetrySession ,
31+ type ITelemetryClient ,
32+ } from './telemetry/index.js' ;
2733import { generateSrvTrace } from './telemetry/srvTrace.js' ;
2834
2935const SUPPORTED_REGIONS = {
@@ -206,16 +212,20 @@ async function run() {
206212 . sort ( toolSorter ) ;
207213
208214 // Determine region for telemetry
209- const region : 'us' | 'eu' = ( regionIndex !== - 1 && regionIndex + 1 < args . length && isValidRegion ( args [ regionIndex + 1 ] ) )
210- ? args [ regionIndex + 1 ] as 'us' | 'eu'
211- : 'us' ;
215+ const region : 'us' | 'eu' =
216+ regionIndex !== - 1 && regionIndex + 1 < args . length && isValidRegion ( args [ regionIndex + 1 ] )
217+ ? ( args [ regionIndex + 1 ] as 'us' | 'eu' )
218+ : 'us' ;
212219
213220 // Telemetry is OFF by default for the open-source STDIO server. Users must
214221 // opt in explicitly with POSTMAN_MCP_TELEMETRY=true; any other value (or
215222 // unset) keeps telemetry disabled.
216223 const telemetryEnabled = parseTelemetryFlag ( process . env . POSTMAN_MCP_TELEMETRY ) ?? false ;
217224 if ( telemetryEnabled ) {
218- log ( 'info' , 'Telemetry enabled (POSTMAN_MCP_TELEMETRY=true). Set POSTMAN_MCP_TELEMETRY=false to disable.' ) ;
225+ log (
226+ 'info' ,
227+ 'Telemetry enabled (POSTMAN_MCP_TELEMETRY=true). Set POSTMAN_MCP_TELEMETRY=false to disable.'
228+ ) ;
219229 }
220230 const telemetry : ITelemetryClient = createTelemetryClient ( {
221231 telemetryEnabled,
@@ -356,12 +366,14 @@ async function run() {
356366 authMethod : 'api_key' ,
357367 paginationUsed,
358368 srvTraceId,
359- meta : extra ?. _meta ? {
360- trigger : ( extra . _meta as any ) . trigger ?? '' ,
361- conversation_id : ( extra . _meta as any ) . conversation_id ?? '' ,
362- task_type : ( extra . _meta as any ) . task_type ?? '' ,
363- model_name : ( extra . _meta as any ) . model_name ?? '' ,
364- } : undefined ,
369+ meta : extra ?. _meta
370+ ? {
371+ trigger : ( extra . _meta as any ) . trigger ?? '' ,
372+ conversation_id : ( extra . _meta as any ) . conversation_id ?? '' ,
373+ task_type : ( extra . _meta as any ) . task_type ?? '' ,
374+ model_name : ( extra . _meta as any ) . model_name ?? '' ,
375+ }
376+ : undefined ,
365377 metaRaw,
366378 } ) ;
367379
@@ -380,12 +392,14 @@ async function run() {
380392 logBoth ( server , 'error' , `Tool invocation failed: ${ toolName } : ${ errMsg } ` , { toolName } ) ;
381393
382394 const errDurationMs = Date . now ( ) - start ;
383- const errorMeta = extra ?. _meta ? {
384- trigger : ( extra . _meta as any ) . trigger ?? '' ,
385- conversation_id : ( extra . _meta as any ) . conversation_id ?? '' ,
386- task_type : ( extra . _meta as any ) . task_type ?? '' ,
387- model_name : ( extra . _meta as any ) . model_name ?? '' ,
388- } : undefined ;
395+ const errorMeta = extra ?. _meta
396+ ? {
397+ trigger : ( extra . _meta as any ) . trigger ?? '' ,
398+ conversation_id : ( extra . _meta as any ) . conversation_id ?? '' ,
399+ task_type : ( extra . _meta as any ) . task_type ?? '' ,
400+ model_name : ( extra . _meta as any ) . model_name ?? '' ,
401+ }
402+ : undefined ;
389403
390404 if ( error instanceof McpError ) {
391405 const httpStatus = ( error . data as Record < string , unknown > ) ?. httpStatus ;
@@ -401,13 +415,16 @@ async function run() {
401415 paginationUsed,
402416 srvTraceId,
403417 errorType : 'tool' ,
404- errorCode : typeof httpStatus === 'number' && ( httpStatus === 401 || httpStatus === 403 )
405- ? 'AUTH_ERROR'
406- : typeof httpStatus === 'number' && httpStatus === 429
407- ? 'RATE_LIMITED'
408- : 'UPSTREAM_ERROR' ,
409- errorStage : typeof httpStatus === 'number' && ( httpStatus === 401 || httpStatus === 403 )
410- ? 'auth' : 'upstream' ,
418+ errorCode :
419+ typeof httpStatus === 'number' && ( httpStatus === 401 || httpStatus === 403 )
420+ ? 'AUTH_ERROR'
421+ : typeof httpStatus === 'number' && httpStatus === 429
422+ ? 'RATE_LIMITED'
423+ : 'UPSTREAM_ERROR' ,
424+ errorStage :
425+ typeof httpStatus === 'number' && ( httpStatus === 401 || httpStatus === 403 )
426+ ? 'auth'
427+ : 'upstream' ,
411428 errorUpstream : 'postman-api' ,
412429 rateLimited : typeof httpStatus === 'number' && httpStatus === 429 ,
413430 meta : errorMeta ,
0 commit comments