mirror of
https://github.com/alibaba/higress.git
synced 2026-06-09 04:37:31 +08:00
fix helm README
This commit is contained in:
@@ -295,4 +295,4 @@ The command removes all the Kubernetes components associated with the chart and
|
|||||||
| tracing.skywalking.port | int | `11800` | |
|
| tracing.skywalking.port | int | `11800` | |
|
||||||
| tracing.skywalking.service | string | `""` | |
|
| tracing.skywalking.service | string | `""` | |
|
||||||
| tracing.timeout | int | `500` | |
|
| tracing.timeout | int | `500` | |
|
||||||
| upstream | object | `{"connectionBufferLimits":10485760,"idleTimeout":10}` | Upstream config settings |
|
| upstream | object | `{"connectionBufferLimits":10485760,"idleTimeout":10}` | Upstream config settings |
|
||||||
@@ -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))
|
utils.OnMCPToolCallError(ctx, fmt.Errorf("around search call failed, status: %d", statusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response struct {
|
utils.SendMCPToolTextResult(ctx, string(responseBody))
|
||||||
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))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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))
|
utils.OnMCPToolCallError(ctx, fmt.Errorf("bicycling call failed, status: %d", statusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response struct {
|
utils.SendMCPToolTextResult(ctx, string(responseBody))
|
||||||
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))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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))
|
utils.OnMCPToolCallError(ctx, fmt.Errorf("driving call failed, status: %d", statusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response struct {
|
utils.SendMCPToolTextResult(ctx, string(responseBody))
|
||||||
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))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server"
|
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server"
|
||||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils"
|
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils"
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ server.Tool = TransitIntegratedRequest{}
|
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))
|
utils.OnMCPToolCallError(ctx, fmt.Errorf("transit integrated call failed, status: %d", statusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response struct {
|
utils.SendMCPToolTextResult(ctx, string(responseBody))
|
||||||
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)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server"
|
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server"
|
||||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils"
|
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils"
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ server.Tool = WalkingRequest{}
|
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))
|
utils.OnMCPToolCallError(ctx, fmt.Errorf("walking call failed, status: %d", statusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response struct {
|
utils.SendMCPToolTextResult(ctx, string(responseBody))
|
||||||
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)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server"
|
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server"
|
||||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils"
|
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils"
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ server.Tool = DistanceRequest{}
|
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))
|
utils.OnMCPToolCallError(ctx, fmt.Errorf("distance call failed, status: %d", statusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response struct {
|
utils.SendMCPToolTextResult(ctx, string(responseBody))
|
||||||
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)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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))
|
utils.OnMCPToolCallError(ctx, fmt.Errorf("geo call failed, status: %d", statusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response struct {
|
utils.SendMCPToolTextResult(ctx, string(responseBody))
|
||||||
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))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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))
|
utils.OnMCPToolCallError(ctx, fmt.Errorf("ip location call failed, status: %d", statusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response struct {
|
utils.SendMCPToolTextResult(ctx, string(responseBody))
|
||||||
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)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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))
|
utils.OnMCPToolCallError(ctx, fmt.Errorf("regeocode call failed, status: %d", statusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response struct {
|
utils.SendMCPToolTextResult(ctx, string(responseBody))
|
||||||
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)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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))
|
utils.OnMCPToolCallError(ctx, fmt.Errorf("search detail call failed, status: %d", statusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response struct {
|
utils.SendMCPToolTextResult(ctx, string(responseBody))
|
||||||
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))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server"
|
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/server"
|
||||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils"
|
"github.com/alibaba/higress/plugins/wasm-go/pkg/mcp/utils"
|
||||||
"github.com/tidwall/gjson"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ server.Tool = TextSearchRequest{}
|
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))
|
utils.OnMCPToolCallError(ctx, fmt.Errorf("text search call failed, status: %d", statusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response struct {
|
utils.SendMCPToolTextResult(ctx, string(responseBody))
|
||||||
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)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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))
|
utils.OnMCPToolCallError(ctx, fmt.Errorf("weather call failed, status: %d", statusCode))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response struct {
|
utils.SendMCPToolTextResult(ctx, string(responseBody))
|
||||||
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))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user