Skip to content

Commit f6cc5a5

Browse files
authored
build: update mcp-go-sdk version to v1.4.0 (#64)
we need to stick to the mcp/go-sdk version 1.4.0 because the latest version (v1.4.1) upgraded to Go 1.25 which is not compatible with our Go version :/ Also, validate the schemas for the tools, panic via `log.Fatalf()` in the `init()` functions. See modelcontextprotocol/go-sdk#470 for more details on why we need to register an schema for the `metav1.Time` type (which uses the `time.Time` type as an embedded field) --------- Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
1 parent 5c04c99 commit f6cc5a5

8 files changed

Lines changed: 120 additions & 50 deletions

.govulncheck.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
ignored-vulnerabilities:
2-
# MCP Go SDK Vulnerable to Improper Handling of Case Sensitivity in github.com/modelcontextprotocol/go-sdk
3-
# Found in: github.com/modelcontextprotocol/go-sdk/mcp@v1.2.0
4-
# Fixed in: github.com/modelcontextprotocol/go-sdk/mcp@v1.3.1
5-
- id: GO-2026-4569
6-
info: https://pkg.go.dev/vuln/GO-2026-4569
7-
silence-until: 2026-04-22
82
# Incorrect parsing of IPv6 host literals in net/url
93
# Found in: net/url@go1.24.13
104
# Fixed in: net/url@go1.25.8

cmd/start_server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ var startServerCmd = &cobra.Command{
9292
mux.Handle("/mcp", mcp.NewStreamableHTTPHandler(func(*http.Request) *mcp.Server {
9393
return srv
9494
}, &mcp.StreamableHTTPOptions{
95-
Stateless: stateless,
95+
Stateless: stateless,
96+
DisableLocalhostProtection: true,
9697
}))
9798

9899
// Metrics endpoint

go.mod

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
module github.com/codeready-toolchain/argocd-mcp-server
22

3-
go 1.24.13
3+
go 1.24.6
4+
5+
toolchain go1.24.13
46

57
require (
68
github.com/argoproj/argo-cd/v3 v3.1.11
79
github.com/argoproj/gitops-engine v0.7.1-0.20250905160054-e48120133eec
810
github.com/codeready-toolchain/mcp-common v0.0.0-20260311065550-14ceedd27660
911
github.com/codeready-toolchain/toolchain-e2e v0.0.0-20260112152755-eb77a8e22ccb
10-
github.com/google/jsonschema-go v0.3.0
12+
github.com/google/jsonschema-go v0.4.2
1113
github.com/h2non/gock v1.2.0
12-
github.com/modelcontextprotocol/go-sdk v1.2.0
14+
github.com/modelcontextprotocol/go-sdk v1.4.0
1315
github.com/prometheus/client_golang v1.22.0
1416
github.com/spf13/cobra v1.10.1
1517
github.com/spf13/pflag v1.0.9
@@ -65,7 +67,7 @@ require (
6567
github.com/gobwas/glob v0.2.3 // indirect
6668
github.com/gogo/protobuf v1.3.2 // indirect
6769
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
68-
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
70+
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
6971
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
7072
github.com/google/btree v1.1.3 // indirect
7173
github.com/google/gnostic-models v0.6.9 // indirect
@@ -113,6 +115,8 @@ require (
113115
github.com/redis/go-redis/v9 v9.8.0 // indirect
114116
github.com/robfig/cron/v3 v3.0.2-0.20210106135023-bc59245fe10e // indirect
115117
github.com/russross/blackfriday/v2 v2.1.0 // indirect
118+
github.com/segmentio/asm v1.1.3 // indirect
119+
github.com/segmentio/encoding v0.5.4 // indirect
116120
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
117121
github.com/sirupsen/logrus v1.9.3 // indirect
118122
github.com/skeema/knownhosts v1.3.1 // indirect
@@ -131,7 +135,7 @@ require (
131135
golang.org/x/net v0.48.0 // indirect
132136
golang.org/x/oauth2 v0.34.0 // indirect
133137
golang.org/x/sync v0.19.0 // indirect
134-
golang.org/x/sys v0.39.0 // indirect
138+
golang.org/x/sys v0.40.0 // indirect
135139
golang.org/x/term v0.38.0 // indirect
136140
golang.org/x/text v0.32.0 // indirect
137141
golang.org/x/time v0.12.0 // indirect

go.sum

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
149149
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
150150
github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI=
151151
github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
152-
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
153-
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
152+
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
153+
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
154154
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
155155
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
156156
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
@@ -174,8 +174,8 @@ github.com/google/go-github/v72 v72.0.0/go.mod h1:WWtw8GMRiL62mvIquf1kO3onRHeWWK
174174
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
175175
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
176176
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
177-
github.com/google/jsonschema-go v0.3.0 h1:6AH2TxVNtk3IlvkkhjrtbUc4S8AvO0Xii0DxIygDg+Q=
178-
github.com/google/jsonschema-go v0.3.0/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
177+
github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8=
178+
github.com/google/jsonschema-go v0.4.2/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
179179
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
180180
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo=
181181
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
@@ -245,8 +245,8 @@ github.com/moby/spdystream v0.5.0 h1:7r0J1Si3QO/kjRitvSLVVFUjxMEb/YLj6S9FF62JBCU
245245
github.com/moby/spdystream v0.5.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI=
246246
github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ=
247247
github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc=
248-
github.com/modelcontextprotocol/go-sdk v1.2.0 h1:Y23co09300CEk8iZ/tMxIX1dVmKZkzoSBZOpJwUnc/s=
249-
github.com/modelcontextprotocol/go-sdk v1.2.0/go.mod h1:6fM3LCm3yV7pAs8isnKLn07oKtB0MP9LHd3DfAcKw10=
248+
github.com/modelcontextprotocol/go-sdk v1.4.0 h1:u0kr8lbJc1oBcawK7Df+/ajNMpIDFE41OEPxdeTLOn8=
249+
github.com/modelcontextprotocol/go-sdk v1.4.0/go.mod h1:Nxc2n+n/GdCebUaqCOhTetptS17SXXNu9IfNTaLDi1E=
250250
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
251251
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
252252
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -326,6 +326,10 @@ github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0t
326326
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
327327
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
328328
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
329+
github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc=
330+
github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg=
331+
github.com/segmentio/encoding v0.5.4 h1:OW1VRern8Nw6ITAtwSZ7Idrl3MXCFwXHPgqESYfvNt0=
332+
github.com/segmentio/encoding v0.5.4/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0=
329333
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
330334
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
331335
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
@@ -464,8 +468,8 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
464468
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
465469
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
466470
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
467-
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
468-
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
471+
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
472+
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
469473
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
470474
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
471475
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -495,8 +499,8 @@ golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E
495499
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
496500
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
497501
golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ=
498-
golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ=
499-
golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
502+
golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc=
503+
golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg=
500504
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
501505
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
502506
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

internal/argocd/unhealthy_application_resources.go

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"log"
78
"log/slog"
9+
"reflect"
810

911
argocdv3 "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
1012
"github.com/argoproj/gitops-engine/pkg/health"
1113
"github.com/google/jsonschema-go/jsonschema"
1214
"github.com/modelcontextprotocol/go-sdk/mcp"
15+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1316
)
1417

1518
var UnhealthyResourcesPrompt = &mcp.Prompt{
@@ -56,26 +59,40 @@ func UnhealthyApplicationResourcesPromptHandle(logger *slog.Logger, cl *Client)
5659
}
5760
}
5861

59-
var UnhealthyApplicationResourcesTool = &mcp.Tool{
60-
Name: "argocd_list_unhealthy_application_resources",
61-
Description: "list unhealthy resources of a given Argo CD Application",
62-
InputSchema: &jsonschema.Schema{
63-
Type: "object",
64-
Properties: map[string]*jsonschema.Schema{
65-
"name": {
66-
Type: "string",
67-
Description: "the name of the Argo CD Application to get details of",
68-
},
69-
},
70-
Required: []string{"name"},
71-
},
72-
OutputSchema: UnhealthyApplicationResourcesOutputSchema,
62+
var UnhealthyApplicationResourcesTool *mcp.Tool
63+
64+
type UnhealthyApplicationResourcesInput struct {
65+
Name string `json:"name" jsonschema:"the name of the Argo CD Application to get details of"`
7366
}
7467

75-
var UnhealthyApplicationResourcesOutputSchema, _ = jsonschema.For[UnhealthyApplicationResourcesOutput](&jsonschema.ForOptions{})
68+
var UnhealthyApplicationResourcesInputSchema *jsonschema.Schema
69+
var UnhealthyApplicationResourcesOutputSchema *jsonschema.Schema
7670

77-
type UnhealthyApplicationResourcesInput struct {
78-
Name string `json:"name"`
71+
func init() {
72+
var err error
73+
// create the input schema
74+
UnhealthyApplicationResourcesInputSchema, err = jsonschema.For[UnhealthyApplicationResourcesInput](&jsonschema.ForOptions{})
75+
if err != nil {
76+
log.Fatalf("failed to create UnhealthyApplicationResourcesInputSchema: %v", err.Error())
77+
}
78+
log.Println("UnhealthyApplicationResourcesInputSchema initialized")
79+
// create the output schema
80+
UnhealthyApplicationResourcesOutputSchema, err = jsonschema.For[UnhealthyApplicationResourcesOutput](&jsonschema.ForOptions{
81+
TypeSchemas: map[reflect.Type]*jsonschema.Schema{
82+
reflect.TypeFor[metav1.Time](): {
83+
Type: "string", // see https://github.com/modelcontextprotocol/go-sdk/pull/470
84+
},
85+
},
86+
})
87+
if err != nil {
88+
log.Fatalf("failed to create UnhealthyApplicationResourcesOutputSchema: %v", err.Error())
89+
}
90+
UnhealthyApplicationResourcesTool = &mcp.Tool{
91+
Name: "argocd_list_unhealthy_application_resources",
92+
Description: "list unhealthy resources of a given Argo CD Application",
93+
InputSchema: UnhealthyApplicationResourcesInputSchema,
94+
OutputSchema: UnhealthyApplicationResourcesOutputSchema,
95+
}
7996
}
8097

8198
type UnhealthyApplicationResourcesOutput UnhealthyResources

internal/argocd/unhealthy_application_resources_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import (
44
"context"
55
"log/slog"
66
"os"
7+
"reflect"
78
"testing"
89

910
testresources "github.com/codeready-toolchain/argocd-mcp-server/test/resources"
1011

1112
argocdv3 "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
13+
"github.com/google/jsonschema-go/jsonschema"
1214
"github.com/h2non/gock"
1315
"github.com/stretchr/testify/assert"
1416
"github.com/stretchr/testify/require"
17+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1518
)
1619

1720
func TestListUnhealthyApplicationResources(t *testing.T) {
@@ -92,3 +95,22 @@ func TestListUnhealthyApplicationResources(t *testing.T) {
9295
assert.EqualError(t, err, "unexpected 500 response for GET http://argocd.example.com/api/v1/applications?name=example: mock error!")
9396
})
9497
}
98+
99+
func TestUnhealthyApplicationResourcesSchemas(t *testing.T) {
100+
101+
t.Run("output schema", func(t *testing.T) {
102+
// when
103+
schema, err := jsonschema.For[UnhealthyApplicationResourcesOutput](&jsonschema.ForOptions{
104+
TypeSchemas: map[reflect.Type]*jsonschema.Schema{
105+
// reflect.TypeFor[UnhealthyResources](): resourcesStatusSchema,
106+
reflect.TypeFor[metav1.Time](): {
107+
Type: "string", // see https://github.com/modelcontextprotocol/go-sdk/pull/470
108+
},
109+
},
110+
})
111+
112+
// then
113+
require.NoError(t, err)
114+
assert.Equal(t, UnhealthyApplicationResourcesOutputSchema, schema)
115+
})
116+
}

internal/argocd/unhealthy_applications.go

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package argocd
33
import (
44
"context"
55
"encoding/json"
6+
"log"
67
"log/slog"
78

89
"github.com/google/jsonschema-go/jsonschema"
@@ -12,21 +13,35 @@ import (
1213
argocdhealth "github.com/argoproj/gitops-engine/pkg/health"
1314
)
1415

15-
var UnhealthyApplicationsTool = &mcp.Tool{
16-
Name: "argocd_list_unhealthy_applications",
17-
Description: "list the unhealthy ('degraded' and 'progressing') Applications in Argo CD",
18-
InputSchema: UnhealthyApplicationsInputSchema,
19-
OutputSchema: UnhealthyApplicationsOutputSchema,
20-
}
21-
22-
type UnhealthyApplicationsInput struct {
23-
}
16+
type UnhealthyApplicationsInput struct{}
17+
type UnhealthyApplicationsOutput UnhealthyApplications
2418

2519
var UnhealthyApplicationsInputSchema, _ = jsonschema.For[UnhealthyApplicationsInput](&jsonschema.ForOptions{})
20+
var UnhealthyApplicationsOutputSchema, _ = jsonschema.For[UnhealthyApplicationsOutput](&jsonschema.ForOptions{})
2621

27-
type UnhealthyApplicationsOutput UnhealthyApplications
22+
var UnhealthyApplicationsTool *mcp.Tool
2823

29-
var UnhealthyApplicationsOutputSchema, _ = jsonschema.For[UnhealthyApplicationsOutput](&jsonschema.ForOptions{})
24+
func init() {
25+
var err error
26+
// create the input schema
27+
UnhealthyApplicationsInputSchema, err = jsonschema.For[UnhealthyApplicationsInput](&jsonschema.ForOptions{})
28+
if err != nil {
29+
log.Fatalf("failed to create UnhealthyApplicationsInputSchema: %v", err.Error())
30+
}
31+
log.Println("UnhealthyApplicationsInputSchema initialized")
32+
// create the output schema
33+
UnhealthyApplicationsOutputSchema, err = jsonschema.For[UnhealthyApplicationsOutput](&jsonschema.ForOptions{})
34+
if err != nil {
35+
log.Fatalf("failed to create UnhealthyApplicationsOutputSchema: %v", err.Error())
36+
}
37+
log.Println("UnhealthyApplicationsOutputSchema initialized")
38+
UnhealthyApplicationsTool = &mcp.Tool{
39+
Name: "argocd_list_unhealthy_applications",
40+
Description: "list the unhealthy ('degraded' and 'progressing') Applications in Argo CD",
41+
InputSchema: UnhealthyApplicationsInputSchema,
42+
OutputSchema: UnhealthyApplicationsOutputSchema,
43+
}
44+
}
3045

3146
func UnhealthyApplicationsToolHandle(logger *slog.Logger, cl *Client) mcp.ToolHandlerFor[UnhealthyApplicationsInput, UnhealthyApplicationsOutput] {
3247
return func(ctx context.Context, _ *mcp.CallToolRequest, _ UnhealthyApplicationsInput) (*mcp.CallToolResult, UnhealthyApplicationsOutput, error) {

internal/argocd/unhealthy_applications_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
testresources "github.com/codeready-toolchain/argocd-mcp-server/test/resources"
1010

11+
"github.com/google/jsonschema-go/jsonschema"
1112
"github.com/h2non/gock"
1213
"github.com/stretchr/testify/assert"
1314
"github.com/stretchr/testify/require"
@@ -66,3 +67,15 @@ func TestListUnhealthyApplications(t *testing.T) {
6667
assert.EqualError(t, err, "unexpected 500 response for GET http://argocd.example.com/api/v1/applications: mock error!")
6768
})
6869
}
70+
71+
func TestUnhealthyApplicationsSchemas(t *testing.T) {
72+
73+
t.Run("output schema", func(t *testing.T) {
74+
// when
75+
schema, err := jsonschema.For[UnhealthyApplicationsOutput](&jsonschema.ForOptions{})
76+
77+
// then
78+
require.NoError(t, err)
79+
assert.Equal(t, UnhealthyApplicationsOutputSchema, schema)
80+
})
81+
}

0 commit comments

Comments
 (0)