Skip to content

Commit 234beed

Browse files
committed
chore: add autotest with read only tools
1 parent 0f0b989 commit 234beed

File tree

2 files changed

+209
-0
lines changed

2 files changed

+209
-0
lines changed

main_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ func TestLists(t *testing.T) {
6666
ts.AssertNoErrors(cntrl)
6767
}
6868

69+
func TestReadOnlyLists(t *testing.T) {
70+
ts, err := foxytest.Read("testdata/readonly")
71+
if err != nil {
72+
t.Fatal(err)
73+
}
74+
ts.WithLogging()
75+
ts.WithExecutable("go", []string{"run", "main.go", "--readonly"})
76+
cntrl := foxytest.NewTestRunner(t)
77+
ts.Run(cntrl)
78+
ts.AssertNoErrors(cntrl)
79+
}
80+
6981
const k3dClusterName = "mcp-k8s-integration-test"
7082

7183
func TestInK3dCluster(t *testing.T) {
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
in: { "jsonrpc": "2.0", "method": "tools/list", "id": 1, "params": {} }
2+
out:
3+
{
4+
"id": 1,
5+
"jsonrpc": "2.0",
6+
"result":
7+
{
8+
"tools":
9+
[
10+
{
11+
"name": "get-k8s-pod-logs",
12+
"description": "Get logs for a Kubernetes pod using specific context in a specified namespace",
13+
"inputSchema":
14+
{
15+
"type": "object",
16+
"properties":
17+
{
18+
"context":
19+
{
20+
"description": "Name of the Kubernetes context to use",
21+
"type": "string",
22+
},
23+
"namespace":
24+
{
25+
"description": "Name of the namespace where the pod is located",
26+
"type": "string",
27+
},
28+
"pod":
29+
{
30+
"description": "Name of the pod to get logs from",
31+
"type": "string",
32+
},
33+
"previousContainer":
34+
{
35+
"description": "Return previous terminated container logs, defaults to false.",
36+
"type": "boolean",
37+
},
38+
"sinceDuration":
39+
{
40+
"description": "Only return logs newer than a relative duration like 5s, 2m, or 3h. Only one of sinceTime or sinceDuration may be set.",
41+
"type": "string",
42+
},
43+
"sinceTime":
44+
{
45+
"description": "Only return logs after a specific date (RFC3339). Only one of sinceTime or sinceDuration may be set.",
46+
"type": "string",
47+
},
48+
},
49+
"required": ["context", "namespace", "pod"],
50+
},
51+
},
52+
{
53+
"name": "get-k8s-resource",
54+
"description": "Get details of any Kubernetes resource like pod, node or service - completely as JSON or rendered using template",
55+
"inputSchema":
56+
{
57+
"type": "object",
58+
"properties":
59+
{
60+
"context":
61+
{
62+
"type": "string",
63+
"description": "Name of the Kubernetes context to use, defaults to current context",
64+
},
65+
"namespace":
66+
{
67+
"type": "string",
68+
"description": "Namespace to get resource from, skip for cluster resources",
69+
},
70+
"name":
71+
{
72+
"type": "string",
73+
"description": "Name of the resource to get",
74+
},
75+
"group":
76+
{
77+
"type": "string",
78+
"description": "API Group of the resource to get",
79+
},
80+
"version":
81+
{
82+
"type": "string",
83+
"description": "API Version of the resource to get",
84+
},
85+
"kind":
86+
{
87+
"type": "string",
88+
"description": "Kind of resource to get",
89+
},
90+
},
91+
"required": ["kind", "name"],
92+
},
93+
},
94+
{
95+
"name": "list-k8s-contexts",
96+
"description": "List Kubernetes contexts from configuration files such as kubeconfig",
97+
"inputSchema": { "type": "object" },
98+
},
99+
{
100+
"name": "list-k8s-events",
101+
"description": "List Kubernetes events using specific context in a specified namespace",
102+
"inputSchema":
103+
{
104+
"type": "object",
105+
"properties":
106+
{
107+
"context":
108+
{
109+
"type": "string",
110+
"description": "Name of the Kubernetes context to use",
111+
},
112+
"namespace":
113+
{
114+
"type": "string",
115+
"description": "Name of the namespace to list events from",
116+
},
117+
"limit":
118+
{
119+
"type": "number",
120+
"description": "Maximum number of events to list",
121+
},
122+
},
123+
"required": ["context", "namespace"],
124+
},
125+
},
126+
{
127+
"name": "list-k8s-namespaces",
128+
"description": "List Kubernetes namespaces using specific context",
129+
"inputSchema":
130+
{
131+
"type": "object",
132+
"properties":
133+
{
134+
"context":
135+
{
136+
"type": "string",
137+
"description": "Name of the Kubernetes context to use, defaults to current context",
138+
},
139+
},
140+
},
141+
},
142+
{
143+
"name": "list-k8s-nodes",
144+
"description": "List Kubernetes nodes using specific context",
145+
"inputSchema":
146+
{
147+
"type": "object",
148+
"properties":
149+
{
150+
"context":
151+
{
152+
"type": "string",
153+
"description": "Name of the Kubernetes context to use, defaults to current context",
154+
},
155+
},
156+
},
157+
},
158+
159+
{
160+
"name": "list-k8s-resources",
161+
"description": "List arbitrary Kubernetes resources",
162+
"inputSchema":
163+
{
164+
"type": "object",
165+
"properties":
166+
{
167+
"context":
168+
{
169+
"type": "string",
170+
"description": "Name of the Kubernetes context to use, defaults to current context",
171+
},
172+
"namespace":
173+
{
174+
"type": "string",
175+
"description": "Namespace to list resources from, defaults to all namespaces",
176+
},
177+
"group":
178+
{
179+
"type": "string",
180+
"description": "API Group of resources to list",
181+
},
182+
"version":
183+
{
184+
"type": "string",
185+
"description": "API Version of resources to list",
186+
},
187+
"kind":
188+
{
189+
"type": "string",
190+
"description": "Kind of resources to list",
191+
},
192+
},
193+
},
194+
},
195+
],
196+
},
197+
}

0 commit comments

Comments
 (0)