Skip to content

Commit b31c973

Browse files
sandyydkHarness
authored andcommitted
fix: [CCM-24794]: Fix handling of string array parameters (#131)
* Add support for a separate client for Commitment Orchestrator * fix: [CCM-24794]: Fix handling of string array parameters (#132) * harness-auto-fix created this fix * Fix handling of string array parameters
1 parent 38bcbb9 commit b31c973

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

cmd/harness-mcp-server/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ type Config struct {
3333
ArtifactRegistrySecret string
3434
NextgenCEBaseURL string
3535
NextgenCESecret string
36+
CCMCommOrchBaseURL string
37+
CCMCommOrchSecret string
3638
IDPSvcBaseURL string
3739
IDPSvcSecret string
3840
McpSvcSecret string

cmd/harness-mcp-server/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ var (
162162
ArtifactRegistrySecret: viper.GetString("artifact_registry_secret"),
163163
NextgenCEBaseURL: viper.GetString("nextgen_ce_base_url"),
164164
NextgenCESecret: viper.GetString("nextgen_ce_secret"),
165+
CCMCommOrchBaseURL: viper.GetString("ccm_comm_orch_base_url"),
166+
CCMCommOrchSecret: viper.GetString("ccm_comm_orch_secret"),
165167
IDPSvcBaseURL: viper.GetString("idp_svc_base_url"),
166168
IDPSvcSecret: viper.GetString("idp_svc_secret"),
167169
McpSvcSecret: viper.GetString("mcp_svc_secret"),

pkg/harness/tools/ccmcosts.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,10 @@ func FetchCommitmentUtilisationTool(config *config.Config, client *client.CloudC
496496
mcp.Description("Optional service to filter commitment utilisation"),
497497
),
498498
mcp.WithArray("cloud_account_ids",
499+
mcp.WithStringItems(),
499500
mcp.Description("Optional cloud account IDs to filter commitment utilisation"),
500-
mcp.Items(map[string]any{
501-
"type": "string",
502-
}),
503-
),
504-
WithScope(config, false),
501+
),
502+
WithScope(config, false),
505503
),
506504
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
507505
accountId, err := getAccountID(config, request)
@@ -522,11 +520,11 @@ func FetchCommitmentUtilisationTool(config *config.Config, client *client.CloudC
522520
}
523521

524522
// Handle cloud account IDs parameter
525-
cloudAccountIDs, ok, err := OptionalParamOK[[]string](request, "cloud_account_ids")
523+
cloudAccountIDs, err := OptionalStringArrayParam(request, "cloud_account_ids")
526524
if err != nil {
527525
return mcp.NewToolResultError(err.Error()), nil
528526
}
529-
if ok && len(cloudAccountIDs) > 0 {
527+
if len(cloudAccountIDs) > 0 {
530528
params.CloudAccountIDs = cloudAccountIDs
531529
}
532530

pkg/modules/ccm.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ func RegisterCloudCostManagement(config *config.Config, tsg *toolsets.ToolsetGro
7777
Client: c,
7878
}
7979

80+
commOrchBaseURL := utils.BuildServiceURL(config, config.CCMCommOrchBaseURL, config.BaseURL, "")
81+
commOrchSecret := config.CCMCommOrchSecret
82+
83+
// Create base client for CCM
84+
commOrchClient, err := utils.CreateClient(commOrchBaseURL, config, commOrchSecret)
85+
if err != nil {
86+
return err
87+
}
88+
89+
ccmCommOrchClient := &client.CloudCostManagementService{
90+
Client: commOrchClient,
91+
}
92+
8093
// Create the CCM toolset
8194
ccm := toolsets.NewToolset("ccm", "Harness Cloud Cost Management related tools").
8295
AddReadTools(
@@ -105,11 +118,11 @@ func RegisterCloudCostManagement(config *config.Config, tsg *toolsets.ToolsetGro
105118
toolsets.NewServerTool(tools.GetCcmRecommendationsStatsTool(config, ccmClient)),
106119
toolsets.NewServerTool(tools.UpdateCcmRecommendationStateTool(config, ccmClient)),
107120
toolsets.NewServerTool(tools.OverrideCcmRecommendationSavingsTool(config, ccmClient)),
108-
toolsets.NewServerTool(tools.FetchCommitmentCoverageTool(config, ccmClient)),
109-
toolsets.NewServerTool(tools.FetchCommitmentSavingsTool(config, ccmClient)),
110-
toolsets.NewServerTool(tools.FetchCommitmentUtilisationTool(config, ccmClient)),
111-
toolsets.NewServerTool(tools.FetchEstimatedSavingsTool(config, ccmClient)),
112-
toolsets.NewServerTool(tools.FetchEC2AnalysisTool(config, ccmClient)),
121+
toolsets.NewServerTool(tools.FetchCommitmentCoverageTool(config, ccmCommOrchClient)),
122+
toolsets.NewServerTool(tools.FetchCommitmentSavingsTool(config, ccmCommOrchClient)),
123+
toolsets.NewServerTool(tools.FetchCommitmentUtilisationTool(config, ccmCommOrchClient)),
124+
toolsets.NewServerTool(tools.FetchEstimatedSavingsTool(config, ccmCommOrchClient)),
125+
toolsets.NewServerTool(tools.FetchEC2AnalysisTool(config, ccmCommOrchClient)),
113126
)
114127

115128
// Add toolset to the group

0 commit comments

Comments
 (0)