From e6d32aa1cf85b6f7fd031de3a2867ec98ba8c445 Mon Sep 17 00:00:00 2001 From: johnlanni Date: Tue, 1 Apr 2025 23:05:08 +0800 Subject: [PATCH] fix helm README --- helm/higress/README.md | 2 +- .../amap-tools/tools/maps_around_search.go | 22 +----- .../amap-tools/tools/maps_bicycling.go | 30 +-------- .../tools/maps_direction_driving.go | 32 +-------- .../maps_direction_transit_integrated.go | 67 +------------------ .../tools/maps_direction_walking.go | 32 +-------- .../amap-tools/tools/maps_distance.go | 23 +------ .../mcp-servers/amap-tools/tools/maps_geo.go | 44 +----------- .../amap-tools/tools/maps_ip_location.go | 20 +----- .../amap-tools/tools/maps_regeocode.go | 23 +------ .../amap-tools/tools/maps_search_detail.go | 28 +------- .../amap-tools/tools/maps_text_search.go | 33 +-------- .../amap-tools/tools/maps_weather.go | 33 +-------- 13 files changed, 13 insertions(+), 376 deletions(-) diff --git a/helm/higress/README.md b/helm/higress/README.md index eb927c22b..835387f17 100644 --- a/helm/higress/README.md +++ b/helm/higress/README.md @@ -295,4 +295,4 @@ The command removes all the Kubernetes components associated with the chart and | tracing.skywalking.port | int | `11800` | | | tracing.skywalking.service | string | `""` | | | tracing.timeout | int | `500` | | -| upstream | object | `{"connectionBufferLimits":10485760,"idleTimeout":10}` | Upstream config settings | +| upstream | object | `{"connectionBufferLimits":10485760,"idleTimeout":10}` | Upstream config settings | \ No newline at end of file diff --git a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_around_search.go b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_around_search.go index 69b756189..d0b171bf2 100644 --- a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_around_search.go +++ b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_around_search.go @@ -63,26 +63,6 @@ func (t AroundSearchRequest) Call(ctx server.HttpContext, s server.Server) error utils.OnMCPToolCallError(ctx, fmt.Errorf("around search call failed, status: %d", statusCode)) return } - var response struct { - Status string `json:"status"` - Info string `json:"info"` - Pois []struct { - ID string `json:"id"` - Name string `json:"name"` - Address string `json:"address"` - Typecode string `json:"typecode"` - } `json:"pois"` - } - err := json.Unmarshal(responseBody, &response) - if err != nil { - utils.OnMCPToolCallError(ctx, fmt.Errorf("failed to parse around search response: %v", err)) - return - } - if response.Status != "1" { - utils.OnMCPToolCallError(ctx, fmt.Errorf("around search failed: %s", response.Info)) - return - } - result, _ := json.MarshalIndent(response.Pois, "", " ") - utils.SendMCPToolTextResult(ctx, string(result)) + utils.SendMCPToolTextResult(ctx, string(responseBody)) }) } diff --git a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_bicycling.go b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_bicycling.go index cf34eb040..ae47ac96b 100644 --- a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_bicycling.go +++ b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_bicycling.go @@ -62,34 +62,6 @@ func (t BicyclingRequest) Call(ctx server.HttpContext, s server.Server) error { utils.OnMCPToolCallError(ctx, fmt.Errorf("bicycling call failed, status: %d", statusCode)) return } - var response struct { - Errcode int `json:"errcode"` - Data struct { - Origin string `json:"origin"` - Destination string `json:"destination"` - Paths []struct { - Distance string `json:"distance"` - Duration string `json:"duration"` - Steps []struct { - Instruction string `json:"instruction"` - Road string `json:"road"` - Distance string `json:"distance"` - Orientation string `json:"orientation"` - Duration string `json:"duration"` - } `json:"steps"` - } `json:"paths"` - } `json:"data"` - } - err := json.Unmarshal(responseBody, &response) - if err != nil { - utils.OnMCPToolCallError(ctx, fmt.Errorf("failed to parse bicycling response: %v", err)) - return - } - if response.Errcode != 0 { - utils.OnMCPToolCallError(ctx, fmt.Errorf("bicycling failed: %v", response)) - return - } - result, _ := json.MarshalIndent(response.Data.Paths, "", " ") - utils.SendMCPToolTextResult(ctx, string(result)) + utils.SendMCPToolTextResult(ctx, string(responseBody)) }) } diff --git a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_direction_driving.go b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_direction_driving.go index f67e873bf..ca208a79e 100644 --- a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_direction_driving.go +++ b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_direction_driving.go @@ -62,36 +62,6 @@ func (t DrivingRequest) Call(ctx server.HttpContext, s server.Server) error { utils.OnMCPToolCallError(ctx, fmt.Errorf("driving call failed, status: %d", statusCode)) return } - var response struct { - Status string `json:"status"` - Info string `json:"info"` - Route struct { - Origin string `json:"origin"` - Destination string `json:"destination"` - Paths []struct { - Path string `json:"path"` - Distance string `json:"distance"` - Duration string `json:"duration"` - Steps []struct { - Instruction string `json:"instruction"` - Road string `json:"road"` - Distance string `json:"distance"` - Orientation string `json:"orientation"` - Duration string `json:"duration"` - } `json:"steps"` - } `json:"paths"` - } `json:"route"` - } - err := json.Unmarshal(responseBody, &response) - if err != nil { - utils.OnMCPToolCallError(ctx, fmt.Errorf("failed to parse driving response: %v", err)) - return - } - if response.Status != "1" { - utils.OnMCPToolCallError(ctx, fmt.Errorf("driving failed: %s", response.Info)) - return - } - result, _ := json.MarshalIndent(response.Route.Paths, "", " ") - utils.SendMCPToolTextResult(ctx, string(result)) + utils.SendMCPToolTextResult(ctx, string(responseBody)) }) } diff --git a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_direction_transit_integrated.go b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_direction_transit_integrated.go index 1e3e25eab..7ee7ad012 100644 --- a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_direction_transit_integrated.go +++ b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_direction_transit_integrated.go @@ -25,7 +25,6 @@ import ( "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server" "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils" - "github.com/tidwall/gjson" ) var _ server.Tool = TransitIntegratedRequest{} @@ -65,70 +64,6 @@ func (t TransitIntegratedRequest) Call(ctx server.HttpContext, s server.Server) utils.OnMCPToolCallError(ctx, fmt.Errorf("transit integrated call failed, status: %d", statusCode)) return } - var response struct { - Status string `json:"status"` - Info string `json:"info"` - Route struct { - Origin string `json:"origin"` - Destination string `json:"destination"` - Distance string `json:"distance"` - Transits []struct { - Duration string `json:"duration"` - WalkingDistance string `json:"walking_distance"` - Segments []struct { - Walking struct { - Origin string `json:"origin"` - Destination string `json:"destination"` - Distance string `json:"distance"` - Duration string `json:"duration"` - Steps []struct { - Instruction string `json:"instruction"` - Road string `json:"road"` - Distance string `json:"distance"` - Action string `json:"action"` - AssistantAction string `json:"assistant_action"` - } `json:"steps"` - } `json:"walking"` - Bus struct { - Buslines []struct { - Name string `json:"name"` - DepartureStop struct { - Name string `json:"name"` - } `json:"departure_stop"` - ArrivalStop struct { - Name string `json:"name"` - } `json:"arrival_stop"` - Distance string `json:"distance"` - Duration string `json:"duration"` - ViaStops []struct { - Name string `json:"name"` - } `json:"via_stops"` - } `json:"buslines"` - } `json:"bus"` - Entrance struct { - Name string `json:"name"` - } `json:"entrance"` - Exit struct { - Name string `json:"name"` - } `json:"exit"` - Railway struct { - Name string `json:"name"` - Trip string `json:"trip"` - } `json:"railway"` - } `json:"segments"` - } `json:"transits"` - } `json:"route"` - } - err := json.Unmarshal(responseBody, &response) - if err != nil { - utils.OnMCPToolCallError(ctx, fmt.Errorf("failed to parse transit integrated response: %v", err)) - return - } - if response.Status != "1" { - utils.OnMCPToolCallError(ctx, fmt.Errorf("transit integrated failed: %s", response.Info)) - return - } - result := fmt.Sprintf(`{"origin": "%s", "destination": "%s", "distance": "%s", "transits": %s}`, response.Route.Origin, response.Route.Destination, response.Route.Distance, gjson.GetBytes(responseBody, "route.transits").Raw) - utils.SendMCPToolTextResult(ctx, result) + utils.SendMCPToolTextResult(ctx, string(responseBody)) }) } diff --git a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_direction_walking.go b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_direction_walking.go index 459cddca6..45a4adab8 100644 --- a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_direction_walking.go +++ b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_direction_walking.go @@ -25,7 +25,6 @@ import ( "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server" "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils" - "github.com/tidwall/gjson" ) var _ server.Tool = WalkingRequest{} @@ -63,35 +62,6 @@ func (t WalkingRequest) Call(ctx server.HttpContext, s server.Server) error { utils.OnMCPToolCallError(ctx, fmt.Errorf("walking call failed, status: %d", statusCode)) return } - var response struct { - Status string `json:"status"` - Info string `json:"info"` - Route struct { - Origin string `json:"origin"` - Destination string `json:"destination"` - Paths []struct { - Distance string `json:"distance"` - Duration string `json:"duration"` - Steps []struct { - Instruction string `json:"instruction"` - Road string `json:"road"` - Distance string `json:"distance"` - Orientation string `json:"orientation"` - Duration string `json:"duration"` - } `json:"steps"` - } `json:"paths"` - } `json:"route"` - } - err := json.Unmarshal(responseBody, &response) - if err != nil { - utils.OnMCPToolCallError(ctx, fmt.Errorf("failed to parse walking response: %v", err)) - return - } - if response.Status != "1" { - utils.OnMCPToolCallError(ctx, fmt.Errorf("walking failed: %s", response.Info)) - return - } - result := fmt.Sprintf(`{"origin": "%s", "destination": "%s", "paths": %s}`, response.Route.Origin, response.Route.Destination, gjson.GetBytes(responseBody, "route.paths").Raw) - utils.SendMCPToolTextResult(ctx, result) + utils.SendMCPToolTextResult(ctx, string(responseBody)) }) } diff --git a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_distance.go b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_distance.go index 4bfedba94..1ac6d843f 100644 --- a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_distance.go +++ b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_distance.go @@ -25,7 +25,6 @@ import ( "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server" "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils" - "github.com/tidwall/gjson" ) var _ server.Tool = DistanceRequest{} @@ -63,26 +62,6 @@ func (t DistanceRequest) Call(ctx server.HttpContext, s server.Server) error { utils.OnMCPToolCallError(ctx, fmt.Errorf("distance call failed, status: %d", statusCode)) return } - var response struct { - Status string `json:"status"` - Info string `json:"info"` - Results []struct { - OriginID string `json:"origin_id"` - DestID string `json:"dest_id"` - Distance string `json:"distance"` - Duration string `json:"duration"` - } `json:"results"` - } - err := json.Unmarshal(responseBody, &response) - if err != nil { - utils.OnMCPToolCallError(ctx, fmt.Errorf("failed to parse distance response: %v", err)) - return - } - if response.Status != "1" { - utils.OnMCPToolCallError(ctx, fmt.Errorf("distance failed: %s", response.Info)) - return - } - result := fmt.Sprintf(`{"results": %s}`, gjson.GetBytes(responseBody, "results").Raw) - utils.SendMCPToolTextResult(ctx, result) + utils.SendMCPToolTextResult(ctx, string(responseBody)) }) } diff --git a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_geo.go b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_geo.go index 6253d7d58..c013c7129 100644 --- a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_geo.go +++ b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_geo.go @@ -63,48 +63,6 @@ func (t GeoRequest) Call(ctx server.HttpContext, s server.Server) error { utils.OnMCPToolCallError(ctx, fmt.Errorf("geo call failed, status: %d", statusCode)) return } - var response struct { - Status string `json:"status"` - Info string `json:"info"` - Geocodes []struct { - Country string `json:"country"` - Province string `json:"province"` - City string `json:"city"` - Citycode string `json:"citycode"` - District string `json:"district"` - Street string `json:"street"` - Number string `json:"number"` - Adcode string `json:"adcode"` - Location string `json:"location"` - Level string `json:"level"` - } `json:"geocodes"` - } - err := json.Unmarshal(responseBody, &response) - if err != nil { - utils.OnMCPToolCallError(ctx, fmt.Errorf("failed to parse geo response: %v", err)) - return - } - if response.Status != "1" { - utils.OnMCPToolCallError(ctx, fmt.Errorf("geo failed: %s", response.Info)) - return - } - var results []map[string]string - for _, geo := range response.Geocodes { - result := map[string]string{ - "country": geo.Country, - "province": geo.Province, - "city": geo.City, - "citycode": geo.Citycode, - "district": geo.District, - "street": geo.Street, - "number": geo.Number, - "adcode": geo.Adcode, - "location": geo.Location, - "level": geo.Level, - } - results = append(results, result) - } - result, _ := json.Marshal(results) - utils.SendMCPToolTextResult(ctx, string(result)) + utils.SendMCPToolTextResult(ctx, string(responseBody)) }) } diff --git a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_ip_location.go b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_ip_location.go index 2d0d87b6d..2c0e2d7ea 100644 --- a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_ip_location.go +++ b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_ip_location.go @@ -61,24 +61,6 @@ func (t IPLocationRequest) Call(ctx server.HttpContext, s server.Server) error { utils.OnMCPToolCallError(ctx, fmt.Errorf("ip location call failed, status: %d", statusCode)) return } - var response struct { - Status string `json:"status"` - Info string `json:"info"` - Province string `json:"province"` - City string `json:"city"` - Adcode string `json:"adcode"` - Rectangle string `json:"rectangle"` - } - err := json.Unmarshal(responseBody, &response) - if err != nil { - utils.OnMCPToolCallError(ctx, fmt.Errorf("failed to parse ip location response: %v", err)) - return - } - if response.Status != "1" { - utils.OnMCPToolCallError(ctx, fmt.Errorf("ip location failed: %s", response.Info)) - return - } - result := fmt.Sprintf(`{"province": "%s", "city": "%s", "adcode": "%s", "rectangle": "%s"}`, response.Province, response.City, response.Adcode, response.Rectangle) - utils.SendMCPToolTextResult(ctx, result) + utils.SendMCPToolTextResult(ctx, string(responseBody)) }) } diff --git a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_regeocode.go b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_regeocode.go index aa3958739..9a7922d77 100644 --- a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_regeocode.go +++ b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_regeocode.go @@ -61,27 +61,6 @@ func (t ReGeocodeRequest) Call(ctx server.HttpContext, s server.Server) error { utils.OnMCPToolCallError(ctx, fmt.Errorf("regeocode call failed, status: %d", statusCode)) return } - var response struct { - Status string `json:"status"` - Info string `json:"info"` - Regeocode struct { - AddressComponent struct { - Province string `json:"province"` - City string `json:"city"` - District string `json:"district"` - } `json:"addressComponent"` - } `json:"regeocode"` - } - err := json.Unmarshal(responseBody, &response) - if err != nil { - utils.OnMCPToolCallError(ctx, fmt.Errorf("failed to parse regeocode response: %v", err)) - return - } - if response.Status != "1" { - utils.OnMCPToolCallError(ctx, fmt.Errorf("regeocode failed: %s", response.Info)) - return - } - result := fmt.Sprintf(`{"province": "%s", "city": "%s", "district": "%s"}`, response.Regeocode.AddressComponent.Province, response.Regeocode.AddressComponent.City, response.Regeocode.AddressComponent.District) - utils.SendMCPToolTextResult(ctx, result) + utils.SendMCPToolTextResult(ctx, string(responseBody)) }) } diff --git a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_search_detail.go b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_search_detail.go index 1da298031..88d395cc6 100644 --- a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_search_detail.go +++ b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_search_detail.go @@ -61,32 +61,6 @@ func (t SearchDetailRequest) Call(ctx server.HttpContext, s server.Server) error utils.OnMCPToolCallError(ctx, fmt.Errorf("search detail call failed, status: %d", statusCode)) return } - var response struct { - Status string `json:"status"` - Info string `json:"info"` - Pois []struct { - ID string `json:"id"` - Name string `json:"name"` - Location string `json:"location"` - Address string `json:"address"` - BusinessArea string `json:"business_area"` - Cityname string `json:"cityname"` - Type string `json:"type"` - Alias string `json:"alias"` - BizExt map[string]string `json:"biz_ext"` - } `json:"pois"` - } - err := json.Unmarshal(responseBody, &response) - if err != nil { - utils.OnMCPToolCallError(ctx, fmt.Errorf("failed to parse search detail response: %v", err)) - return - } - if response.Status != "1" { - utils.OnMCPToolCallError(ctx, fmt.Errorf("search detail failed: %s", response.Info)) - return - } - poi := response.Pois[0] - result, _ := json.MarshalIndent(poi, "", " ") - utils.SendMCPToolTextResult(ctx, string(result)) + utils.SendMCPToolTextResult(ctx, string(responseBody)) }) } diff --git a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_text_search.go b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_text_search.go index 73b4fab3e..72a634f79 100644 --- a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_text_search.go +++ b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_text_search.go @@ -25,7 +25,6 @@ import ( "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server" "github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils" - "github.com/tidwall/gjson" ) var _ server.Tool = TextSearchRequest{} @@ -64,36 +63,6 @@ func (t TextSearchRequest) Call(ctx server.HttpContext, s server.Server) error { utils.OnMCPToolCallError(ctx, fmt.Errorf("text search call failed, status: %d", statusCode)) return } - var response struct { - Status string `json:"status"` - Info string `json:"info"` - Suggestion struct { - Keywords []string `json:"keywords"` - Cities []struct { - Name string `json:"name"` - } `json:"cities"` - } `json:"suggestion"` - Pois []struct { - ID string `json:"id"` - Name string `json:"name"` - Address string `json:"address"` - Typecode string `json:"typecode"` - } `json:"pois"` - } - err := json.Unmarshal(responseBody, &response) - if err != nil { - utils.OnMCPToolCallError(ctx, fmt.Errorf("failed to parse text search response: %v", err)) - return - } - if response.Status != "1" { - utils.OnMCPToolCallError(ctx, fmt.Errorf("text search failed: %s", response.Info)) - return - } - var cities []string - for _, city := range response.Suggestion.Cities { - cities = append(cities, city.Name) - } - result := fmt.Sprintf(`{"suggestion": {"keywords": %s, "cities": %s}, "pois": %s}`, string(responseBody), string(responseBody), gjson.GetBytes(responseBody, "pois").Raw) - utils.SendMCPToolTextResult(ctx, result) + utils.SendMCPToolTextResult(ctx, string(responseBody)) }) } diff --git a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_weather.go b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_weather.go index 01c9c92d6..ec0c47e94 100644 --- a/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_weather.go +++ b/plugins/wasm-go/mcp-servers/amap-tools/tools/maps_weather.go @@ -61,37 +61,6 @@ func (t WeatherRequest) Call(ctx server.HttpContext, s server.Server) error { utils.OnMCPToolCallError(ctx, fmt.Errorf("weather call failed, status: %d", statusCode)) return } - var response struct { - Status string `json:"status"` - Info string `json:"info"` - Forecasts []struct { - City string `json:"city"` - Casts []struct { - Date string `json:"date"` - Week string `json:"week"` - DayWeather string `json:"dayweather"` - NightWeather string `json:"nightweather"` - DayTemp string `json:"daytemp"` - NightTemp string `json:"nighttemp"` - DayWind string `json:"daywind"` - NightWind string `json:"nightwind"` - DayPower string `json:"daypower"` - NightPower string `json:"nightpower"` - Humidity string `json:"humidity"` - } `json:"casts"` - } `json:"forecasts"` - } - err := json.Unmarshal(responseBody, &response) - if err != nil { - utils.OnMCPToolCallError(ctx, fmt.Errorf("failed to parse weather response: %v", err)) - return - } - if response.Status != "1" { - utils.OnMCPToolCallError(ctx, fmt.Errorf("weather failed: %s", response.Info)) - return - } - forecasts := response.Forecasts[0] - result, _ := json.MarshalIndent(forecasts, "", " ") - utils.SendMCPToolTextResult(ctx, string(result)) + utils.SendMCPToolTextResult(ctx, string(responseBody)) }) }