@@ -20,7 +20,7 @@ server.registerTool(
2020 "get_weather" ,
2121 {
2222 description : "Get weather information for a city" ,
23- inputSchema :{
23+ inputSchema : {
2424 city : z . string ( ) . describe ( "City name" ) ,
2525 country : z . string ( ) . describe ( "Country code (e.g., US, UK)" )
2626 } ,
@@ -45,20 +45,26 @@ server.registerTool(
4545 const temp_c = Math . round ( ( Math . random ( ) * 35 - 5 ) * 10 ) / 10 ;
4646 const conditions = [ "sunny" , "cloudy" , "rainy" , "stormy" , "snowy" ] [ Math . floor ( Math . random ( ) * 5 ) ] ;
4747
48- return {
49- structuredContent : {
50- temperature : {
51- celsius : temp_c ,
52- fahrenheit : Math . round ( ( temp_c * 9 / 5 + 32 ) * 10 ) / 10
53- } ,
54- conditions,
55- humidity : Math . round ( Math . random ( ) * 100 ) ,
56- wind : {
57- speed_kmh : Math . round ( Math . random ( ) * 50 ) ,
58- direction : [ "N" , "NE" , "E" , "SE" , "S" , "SW" , "W" , "NW" ] [ Math . floor ( Math . random ( ) * 8 ) ]
59- }
48+ const structuredContent = {
49+ temperature : {
50+ celsius : temp_c ,
51+ fahrenheit : Math . round ( ( temp_c * 9 / 5 + 32 ) * 10 ) / 10
52+ } ,
53+ conditions,
54+ humidity : Math . round ( Math . random ( ) * 100 ) ,
55+ wind : {
56+ speed_kmh : Math . round ( Math . random ( ) * 50 ) ,
57+ direction : [ "N" , "NE" , "E" , "SE" , "S" , "SW" , "W" , "NW" ] [ Math . floor ( Math . random ( ) * 8 ) ]
6058 }
6159 } ;
60+
61+ return {
62+ content : [ {
63+ type : "text" ,
64+ text : JSON . stringify ( structuredContent , null , 2 )
65+ } ] ,
66+ structuredContent
67+ } ;
6268 }
6369) ;
6470
0 commit comments