@@ -38,8 +38,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
3838 type : "object" ,
3939 properties : {
4040 bmi : { type : "number" , description : "Body Mass Index" } ,
41- category : {
42- type : "string" ,
41+ category : {
42+ type : "string" ,
4343 enum : [ "underweight" , "normal" , "overweight" , "obese" ] ,
4444 description : "BMI category"
4545 } ,
@@ -102,22 +102,22 @@ server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest)
102102 switch ( request . params . name ) {
103103 case "calculate_bmi" : {
104104 const { height_cm, weight_kg } = request . params . arguments as { height_cm : number ; weight_kg: number } ;
105-
105+
106106 const height_m = height_cm / 100 ;
107107 const bmi = weight_kg / ( height_m * height_m ) ;
108-
108+
109109 let category : string ;
110110 if ( bmi < 18.5 ) category = "underweight" ;
111111 else if ( bmi < 25 ) category = "normal" ;
112112 else if ( bmi < 30 ) category = "overweight" ;
113113 else category = "obese" ;
114-
114+
115115 // Calculate healthy weight range for normal BMI (18.5-24.9)
116116 const min_healthy_bmi = 18.5 ;
117117 const max_healthy_bmi = 24.9 ;
118118 const min_healthy_weight = min_healthy_bmi * height_m * height_m ;
119119 const max_healthy_weight = max_healthy_bmi * height_m * height_m ;
120-
120+
121121 // Return structured content matching the outputSchema
122122 return {
123123 structuredContent : {
@@ -130,39 +130,39 @@ server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest)
130130 }
131131 } ;
132132 }
133-
133+
134134 case "analyze_text" : {
135135 const { text } = request . params . arguments as { text : string } ;
136-
136+
137137 // Simple text analysis
138138 const words = text . trim ( ) . split ( / \s + / ) ;
139139 const sentences = text . split ( / [ . ! ? ] + / ) . filter ( s => s . trim ( ) . length > 0 ) ;
140140 const wordsPerMinute = 200 ; // Average reading speed
141-
141+
142142 // Very simple sentiment analysis (for demo purposes)
143143 const positiveWords = [ "good" , "great" , "excellent" , "happy" , "positive" , "amazing" ] ;
144144 const negativeWords = [ "bad" , "poor" , "terrible" , "sad" , "negative" , "awful" ] ;
145-
145+
146146 let positiveCount = 0 ;
147147 let negativeCount = 0 ;
148148 words . forEach ( word => {
149149 if ( positiveWords . includes ( word . toLowerCase ( ) ) ) positiveCount ++ ;
150150 if ( negativeWords . includes ( word . toLowerCase ( ) ) ) negativeCount ++ ;
151151 } ) ;
152-
152+
153153 let sentiment : string ;
154154 if ( positiveCount > negativeCount ) sentiment = "positive" ;
155155 else if ( negativeCount > positiveCount ) sentiment = "negative" ;
156156 else sentiment = "neutral" ;
157-
157+
158158 // Extract key phrases (simple approach - just common bigrams)
159159 const keyPhrases : string [ ] = [ ] ;
160160 for ( let i = 0 ; i < words . length - 1 ; i ++ ) {
161161 if ( words [ i ] . length > 3 && words [ i + 1 ] . length > 3 ) {
162162 keyPhrases . push ( `${ words [ i ] } ${ words [ i + 1 ] } ` ) ;
163163 }
164164 }
165-
165+
166166 return {
167167 structuredContent : {
168168 word_count : words . length ,
@@ -174,21 +174,21 @@ server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest)
174174 }
175175 } ;
176176 }
177-
177+
178178 case "traditional_tool" : {
179179 const { message } = request . params . arguments as { message : string } ;
180-
180+
181181 // Traditional tool returns content array
182182 return {
183183 content : [
184- {
185- type : "text" ,
186- text : `Processed message: ${ message . toUpperCase ( ) } `
184+ {
185+ type : "text" ,
186+ text : `Processed message: ${ message . toUpperCase ( ) } `
187187 }
188188 ]
189189 } ;
190190 }
191-
191+
192192 default:
193193 throw new McpError (
194194 ErrorCode . MethodNotFound ,
0 commit comments