@@ -22,13 +22,17 @@ function buildAllContentItemAttributes(content: unknown[]): Record<string, strin
2222 } ;
2323
2424 for ( const [ i , item ] of content . entries ( ) ) {
25- if ( typeof item !== 'object' || item === null ) continue ;
25+ if ( typeof item !== 'object' || item === null ) {
26+ continue ;
27+ }
2628
2729 const contentItem = item as Record < string , unknown > ;
2830 const prefix = content . length === 1 ? 'mcp.tool.result' : `mcp.tool.result.${ i } ` ;
2931
3032 const safeSet = ( key : string , value : unknown ) : void => {
31- if ( typeof value === 'string' ) attributes [ `${ prefix } .${ key } ` ] = value ;
33+ if ( typeof value === 'string' ) {
34+ attributes [ `${ prefix } .${ key } ` ] = value ;
35+ }
3236 } ;
3337
3438 safeSet ( 'content_type' , contentItem . type ) ;
@@ -39,7 +43,11 @@ function buildAllContentItemAttributes(content: unknown[]): Record<string, strin
3943 if ( typeof contentItem . text === 'string' ) {
4044 const text = contentItem . text ;
4145 const maxLength = 500 ;
42- attributes [ `${ prefix } .content` ] = text . length > maxLength ? `${ text . slice ( 0 , maxLength - 3 ) } ...` : text ;
46+ if ( text . length > maxLength ) {
47+ attributes [ `${ prefix } .content` ] = `${ text . slice ( 0 , maxLength - 3 ) } ...` ;
48+ } else {
49+ attributes [ `${ prefix } .content` ] = text ;
50+ }
4351 }
4452
4553 if ( typeof contentItem . data === 'string' ) {
@@ -64,7 +72,9 @@ function buildAllContentItemAttributes(content: unknown[]): Record<string, strin
6472 */
6573export function extractToolResultAttributes ( result : unknown ) : Record < string , string | number | boolean > {
6674 let attributes : Record < string , string | number | boolean > = { } ;
67- if ( typeof result !== 'object' || result === null ) return attributes ;
75+ if ( typeof result !== 'object' || result === null ) {
76+ return attributes ;
77+ }
6878
6979 const resultObj = result as Record < string , unknown > ;
7080 if ( typeof resultObj . isError === 'boolean' ) {
@@ -83,19 +93,24 @@ export function extractToolResultAttributes(result: unknown): Record<string, str
8393 */
8494export function extractPromptResultAttributes ( result : unknown ) : Record < string , string | number | boolean > {
8595 const attributes : Record < string , string | number | boolean > = { } ;
86- if ( typeof result !== 'object' || result === null ) return attributes ;
96+ if ( typeof result !== 'object' || result === null ) {
97+ return attributes ;
98+ }
8799
88100 const resultObj = result as Record < string , unknown > ;
89101
90- if ( typeof resultObj . description === 'string' )
102+ if ( typeof resultObj . description === 'string' ) {
91103 attributes [ MCP_PROMPT_RESULT_DESCRIPTION_ATTRIBUTE ] = resultObj . description ;
104+ }
92105
93106 if ( Array . isArray ( resultObj . messages ) ) {
94107 attributes [ MCP_PROMPT_RESULT_MESSAGE_COUNT_ATTRIBUTE ] = resultObj . messages . length ;
95108
96109 const messages = resultObj . messages ;
97110 for ( const [ i , message ] of messages . entries ( ) ) {
98- if ( typeof message !== 'object' || message === null ) continue ;
111+ if ( typeof message !== 'object' || message === null ) {
112+ continue ;
113+ }
99114
100115 const messageObj = message as Record < string , unknown > ;
101116 const prefix = messages . length === 1 ? 'mcp.prompt.result' : `mcp.prompt.result.${ i } ` ;
0 commit comments