11package mcp
22
33import (
4+ "github.com/mark3labs/mcp-go/mcp"
45 corev1 "k8s.io/api/core/v1"
56 rbacv1 "k8s.io/api/rbac/v1"
67 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -27,7 +28,7 @@ func TestPodsListInAllNamespaces(t *testing.T) {
2728 }
2829 })
2930 var decoded []unstructured.Unstructured
30- err = yaml .Unmarshal ([]byte (toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) ), & decoded )
31+ err = yaml .Unmarshal ([]byte (toolResult .Content [0 ].(mcp. TextContent ). Text ), & decoded )
3132 t .Run ("pods_list has yaml content" , func (t * testing.T ) {
3233 if err != nil {
3334 t .Fatalf ("invalid tool result content %v" , err )
@@ -102,7 +103,7 @@ func TestPodsListInAllNamespacesUnauthorized(t *testing.T) {
102103 }
103104 })
104105 var decoded []unstructured.Unstructured
105- err = yaml .Unmarshal ([]byte (toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) ), & decoded )
106+ err = yaml .Unmarshal ([]byte (toolResult .Content [0 ].(mcp. TextContent ). Text ), & decoded )
106107 t .Run ("pods_list has yaml content" , func (t * testing.T ) {
107108 if err != nil {
108109 t .Fatalf ("invalid tool result content %v" , err )
@@ -137,8 +138,8 @@ func TestPodsListInNamespace(t *testing.T) {
137138 t .Fatalf ("call tool should fail" )
138139 return
139140 }
140- if toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) != "failed to list pods in namespace, missing argument namespace" {
141- t .Fatalf ("invalid error message, got %v" , toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) )
141+ if toolResult .Content [0 ].(mcp. TextContent ). Text != "failed to list pods in namespace, missing argument namespace" {
142+ t .Fatalf ("invalid error message, got %v" , toolResult .Content [0 ].(mcp. TextContent ). Text )
142143 return
143144 }
144145 })
@@ -156,7 +157,7 @@ func TestPodsListInNamespace(t *testing.T) {
156157 }
157158 })
158159 var decoded []unstructured.Unstructured
159- err = yaml .Unmarshal ([]byte (toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) ), & decoded )
160+ err = yaml .Unmarshal ([]byte (toolResult .Content [0 ].(mcp. TextContent ). Text ), & decoded )
160161 t .Run ("pods_list_in_namespace has yaml content" , func (t * testing.T ) {
161162 if err != nil {
162163 t .Fatalf ("invalid tool result content %v" , err )
@@ -197,8 +198,8 @@ func TestPodsGet(t *testing.T) {
197198 t .Fatalf ("call tool should fail" )
198199 return
199200 }
200- if toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) != "failed to get pod, missing argument name" {
201- t .Fatalf ("invalid error message, got %v" , toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) )
201+ if toolResult .Content [0 ].(mcp. TextContent ). Text != "failed to get pod, missing argument name" {
202+ t .Fatalf ("invalid error message, got %v" , toolResult .Content [0 ].(mcp. TextContent ). Text )
202203 return
203204 }
204205 })
@@ -208,8 +209,8 @@ func TestPodsGet(t *testing.T) {
208209 t .Fatalf ("call tool should fail" )
209210 return
210211 }
211- if toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) != "failed to get pod not-found in namespace : pods \" not-found\" not found" {
212- t .Fatalf ("invalid error message, got %v" , toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) )
212+ if toolResult .Content [0 ].(mcp. TextContent ). Text != "failed to get pod not-found in namespace : pods \" not-found\" not found" {
213+ t .Fatalf ("invalid error message, got %v" , toolResult .Content [0 ].(mcp. TextContent ). Text )
213214 return
214215 }
215216 })
@@ -227,7 +228,7 @@ func TestPodsGet(t *testing.T) {
227228 }
228229 })
229230 var decodedNilNamespace unstructured.Unstructured
230- err = yaml .Unmarshal ([]byte (podsGetNilNamespace .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) ), & decodedNilNamespace )
231+ err = yaml .Unmarshal ([]byte (podsGetNilNamespace .Content [0 ].(mcp. TextContent ). Text ), & decodedNilNamespace )
231232 t .Run ("pods_get with name and nil namespace has yaml content" , func (t * testing.T ) {
232233 if err != nil {
233234 t .Fatalf ("invalid tool result content %v" , err )
@@ -265,7 +266,7 @@ func TestPodsGet(t *testing.T) {
265266 }
266267 })
267268 var decodedInNamespace unstructured.Unstructured
268- err = yaml .Unmarshal ([]byte (podsGetInNamespace .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) ), & decodedInNamespace )
269+ err = yaml .Unmarshal ([]byte (podsGetInNamespace .Content [0 ].(mcp. TextContent ). Text ), & decodedInNamespace )
269270 t .Run ("pods_get with name and namespace has yaml content" , func (t * testing.T ) {
270271 if err != nil {
271272 t .Fatalf ("invalid tool result content %v" , err )
@@ -295,8 +296,8 @@ func TestPodsDelete(t *testing.T) {
295296 t .Errorf ("call tool should fail" )
296297 return
297298 }
298- if toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) != "failed to delete pod, missing argument name" {
299- t .Errorf ("invalid error message, got %v" , toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) )
299+ if toolResult .Content [0 ].(mcp. TextContent ). Text != "failed to delete pod, missing argument name" {
300+ t .Errorf ("invalid error message, got %v" , toolResult .Content [0 ].(mcp. TextContent ). Text )
300301 return
301302 }
302303 })
@@ -306,8 +307,8 @@ func TestPodsDelete(t *testing.T) {
306307 t .Errorf ("call tool should fail" )
307308 return
308309 }
309- if toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) != "failed to delete pod not-found in namespace : pods \" not-found\" not found" {
310- t .Errorf ("invalid error message, got %v" , toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) )
310+ if toolResult .Content [0 ].(mcp. TextContent ). Text != "failed to delete pod not-found in namespace : pods \" not-found\" not found" {
311+ t .Errorf ("invalid error message, got %v" , toolResult .Content [0 ].(mcp. TextContent ). Text )
311312 return
312313 }
313314 })
@@ -329,8 +330,8 @@ func TestPodsDelete(t *testing.T) {
329330 t .Errorf ("call tool failed" )
330331 return
331332 }
332- if podsDeleteNilNamespace .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) != "Pod deleted successfully" {
333- t .Errorf ("invalid tool result content, got %v" , podsDeleteNilNamespace .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) )
333+ if podsDeleteNilNamespace .Content [0 ].(mcp. TextContent ). Text != "Pod deleted successfully" {
334+ t .Errorf ("invalid tool result content, got %v" , podsDeleteNilNamespace .Content [0 ].(mcp. TextContent ). Text )
334335 return
335336 }
336337 })
@@ -359,8 +360,8 @@ func TestPodsDelete(t *testing.T) {
359360 t .Errorf ("call tool failed" )
360361 return
361362 }
362- if podsDeleteInNamespace .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) != "Pod deleted successfully" {
363- t .Errorf ("invalid tool result content, got %v" , podsDeleteInNamespace .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) )
363+ if podsDeleteInNamespace .Content [0 ].(mcp. TextContent ). Text != "Pod deleted successfully" {
364+ t .Errorf ("invalid tool result content, got %v" , podsDeleteInNamespace .Content [0 ].(mcp. TextContent ). Text )
364365 return
365366 }
366367 })
@@ -396,8 +397,8 @@ func TestPodsDelete(t *testing.T) {
396397 t .Errorf ("call tool failed" )
397398 return
398399 }
399- if podsDeleteManaged .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) != "Pod deleted successfully" {
400- t .Errorf ("invalid tool result content, got %v" , podsDeleteManaged .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) )
400+ if podsDeleteManaged .Content [0 ].(mcp. TextContent ). Text != "Pod deleted successfully" {
401+ t .Errorf ("invalid tool result content, got %v" , podsDeleteManaged .Content [0 ].(mcp. TextContent ). Text )
401402 return
402403 }
403404 })
@@ -451,8 +452,8 @@ func TestPodsDeleteInOpenShift(t *testing.T) {
451452 t .Errorf ("call tool failed" )
452453 return
453454 }
454- if podsDeleteManagedOpenShift .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) != "Pod deleted successfully" {
455- t .Errorf ("invalid tool result content, got %v" , podsDeleteManagedOpenShift .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) )
455+ if podsDeleteManagedOpenShift .Content [0 ].(mcp. TextContent ). Text != "Pod deleted successfully" {
456+ t .Errorf ("invalid tool result content, got %v" , podsDeleteManagedOpenShift .Content [0 ].(mcp. TextContent ). Text )
456457 return
457458 }
458459 })
@@ -482,8 +483,8 @@ func TestPodsLog(t *testing.T) {
482483 t .Fatalf ("call tool should fail" )
483484 return
484485 }
485- if toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) != "failed to get pod log, missing argument name" {
486- t .Fatalf ("invalid error message, got %v" , toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) )
486+ if toolResult .Content [0 ].(mcp. TextContent ). Text != "failed to get pod log, missing argument name" {
487+ t .Fatalf ("invalid error message, got %v" , toolResult .Content [0 ].(mcp. TextContent ). Text )
487488 return
488489 }
489490 })
@@ -493,8 +494,8 @@ func TestPodsLog(t *testing.T) {
493494 t .Fatalf ("call tool should fail" )
494495 return
495496 }
496- if toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) != "failed to get pod not-found log in namespace : pods \" not-found\" not found" {
497- t .Fatalf ("invalid error message, got %v" , toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) )
497+ if toolResult .Content [0 ].(mcp. TextContent ). Text != "failed to get pod not-found log in namespace : pods \" not-found\" not found" {
498+ t .Fatalf ("invalid error message, got %v" , toolResult .Content [0 ].(mcp. TextContent ). Text )
498499 return
499500 }
500501 })
@@ -537,8 +538,8 @@ func TestPodsRun(t *testing.T) {
537538 t .Errorf ("call tool should fail" )
538539 return
539540 }
540- if toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) != "failed to run pod, missing argument image" {
541- t .Errorf ("invalid error message, got %v" , toolResult .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) )
541+ if toolResult .Content [0 ].(mcp. TextContent ). Text != "failed to run pod, missing argument image" {
542+ t .Errorf ("invalid error message, got %v" , toolResult .Content [0 ].(mcp. TextContent ). Text )
542543 return
543544 }
544545 })
@@ -554,7 +555,7 @@ func TestPodsRun(t *testing.T) {
554555 }
555556 })
556557 var decodedNilNamespace []unstructured.Unstructured
557- err = yaml .Unmarshal ([]byte (podsRunNilNamespace .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) ), & decodedNilNamespace )
558+ err = yaml .Unmarshal ([]byte (podsRunNilNamespace .Content [0 ].(mcp. TextContent ). Text ), & decodedNilNamespace )
558559 t .Run ("pods_run with image and nil namespace has yaml content" , func (t * testing.T ) {
559560 if err != nil {
560561 t .Errorf ("invalid tool result content %v" , err )
@@ -622,7 +623,7 @@ func TestPodsRun(t *testing.T) {
622623 }
623624 })
624625 var decodedNamespaceAndPort []unstructured.Unstructured
625- err = yaml .Unmarshal ([]byte (podsRunNamespaceAndPort .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) ), & decodedNamespaceAndPort )
626+ err = yaml .Unmarshal ([]byte (podsRunNamespaceAndPort .Content [0 ].(mcp. TextContent ). Text ), & decodedNamespaceAndPort )
626627 t .Run ("pods_run with image, namespace, and port has yaml content" , func (t * testing.T ) {
627628 if err != nil {
628629 t .Errorf ("invalid tool result content %v" , err )
@@ -692,7 +693,7 @@ func TestPodsRunInOpenShift(t *testing.T) {
692693 return
693694 }
694695 var decodedPodServiceRoute []unstructured.Unstructured
695- err = yaml .Unmarshal ([]byte (podsRunInOpenShift .Content [0 ].(map [ string ] interface {})[ "text" ].( string ) ), & decodedPodServiceRoute )
696+ err = yaml .Unmarshal ([]byte (podsRunInOpenShift .Content [0 ].(mcp. TextContent ). Text ), & decodedPodServiceRoute )
696697 if err != nil {
697698 t .Errorf ("invalid tool result content %v" , err )
698699 return
0 commit comments