Skip to content

Commit 1596731

Browse files
Merge pull request #195 from bentito/add-netedge-evals
NO-JIRA: feat: add remaining netedge evaluations (follow-up to #138)
2 parents fedab59 + 7dbaa62 commit 1596731

7 files changed

Lines changed: 97 additions & 96 deletions

File tree

docs/openshift/NETEDGE-validation-how-to.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@ This document outlines the procedure for validating the NetEdge (NIDS) toolset o
77
- **Go**: v1.22+ (Ensure `GOROOT` is set correctly)
88
- **OpenShift Cluster**: Running and accessible (OCP, CRC, or similar). **Note: Evaluations WILL FAIL on Kind.**
99
- **oc** or **kubectl**: Installed and configured to talk to your cluster.
10-
- **gevals**: Built and in the root directory (see Setup below).
10+
- **mcpchecker**: Built and in the root directory (see Setup below).
1111
- **Gemini CLI**: Installed (`npm install -g @google/gemini-cli`)
12-
- **RH_GEMINI_API_KEY**: Required for the Agent.
13-
- **OPENAI_API_KEY**: Required for the Judge (until Gemini compatibility is fully verified).
12+
- **RH_GEMINI_API_KEY**: Required for the Agent and Judge.
1413

1514
## Setup
1615

17-
1. **Build/Install gevals**:
16+
1. **Build/Install mcpchecker**:
1817
if not already present:
1918
```bash
2019
git clone https://github.com/mcpchecker/mcpchecker.git ../mcpchecker
2120
cd ../mcpchecker
22-
go build -o gevals ./cmd/mcpchecker
23-
mv gevals ../openshift-mcp-server/
21+
go build -o mcpchecker ./cmd/mcpchecker
22+
mv mcpchecker ../openshift-mcp-server/
2423
```
2524

2625
2. **Connect to OpenShift Cluster**:
@@ -45,24 +44,44 @@ This document outlines the procedure for validating the NetEdge (NIDS) toolset o
4544
```
4645

4746
3. **Run the Evaluations**:
48-
Run `mcpchecker` (gevals) checks using the Gemini Agent.
47+
Run `mcpchecker` checks using the Gemini Agent.
4948

5049
**Test 1: Get CoreDNS Configuration**
5150
```bash
52-
export RH_GEMINI_API_KEY=$RH_GEMINI_API_KEY && export JUDGE_API_KEY=$OPENAI_API_KEY && export JUDGE_BASE_URL="https://api.openai.com/v1" && export JUDGE_MODEL_NAME="gpt-4o" && ./gevals check evals/gemini-agent/eval.yaml --run "get-coredns-config" -v
51+
export RH_GEMINI_API_KEY=$RH_GEMINI_API_KEY && ./mcpchecker check evals/gemini-agent/eval.yaml --run "get-coredns-config" -v
5352
```
5453

5554
**Test 2: Query Prometheus Diagnostics**
5655
```bash
57-
export RH_GEMINI_API_KEY=$RH_GEMINI_API_KEY && export JUDGE_API_KEY=$OPENAI_API_KEY && export JUDGE_BASE_URL="https://api.openai.com/v1" && export JUDGE_MODEL_NAME="gpt-4o" && ./gevals check evals/gemini-agent/eval.yaml --run "query-prometheus-ingress" -v
56+
export RH_GEMINI_API_KEY=$RH_GEMINI_API_KEY && ./mcpchecker check evals/gemini-agent/eval.yaml --run "query-prometheus-ingress" -v
57+
```
58+
59+
**Test 3: Inspect Route**
60+
```bash
61+
export RH_GEMINI_API_KEY=$RH_GEMINI_API_KEY && ./mcpchecker check evals/gemini-agent/eval.yaml --run "inspect-route" -v
62+
```
63+
64+
**Test 4: Get Service Endpoints**
65+
```bash
66+
export RH_GEMINI_API_KEY=$RH_GEMINI_API_KEY && ./mcpchecker check evals/gemini-agent/eval.yaml --run "get-service-endpoints" -v
67+
```
68+
69+
**Test 5: Probe DNS Local**
70+
```bash
71+
export RH_GEMINI_API_KEY=$RH_GEMINI_API_KEY && ./mcpchecker check evals/gemini-agent/eval.yaml --run "probe-dns-local" -v
72+
```
73+
74+
**Test 6: Probe HTTP**
75+
```bash
76+
export RH_GEMINI_API_KEY=$RH_GEMINI_API_KEY && ./mcpchecker check evals/gemini-agent/eval.yaml --run "probe-http" -v
5877
```
5978

6079
**Tip**: To see the full agent conversation and debug details:
6180
```bash
62-
./gevals view mcpchecker-gemini-agent-netedge-eval-out.json
81+
./mcpchecker view mcpchecker-gemini-agent-netedge-eval-out.json
6382
```
6483

6584
## Observing Results
6685

67-
- **Console Output**: `gevals` will show the Gemini agent's progress.
86+
- **Console Output**: `mcpchecker` will show the Gemini agent's progress.
6887
- **Server Logs**: Watch `server.log` to see the `netedge` toolset servicing requests from Gemini.

evals/gemini-agent/agent.yaml

Lines changed: 3 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,6 @@
11
kind: Agent
22
metadata:
33
name: "gemini-command-agent"
4-
commands:
5-
useVirtualHome: false
6-
argTemplateMcpServer: "{{ .File }}"
7-
argTemplateAllowedTools: "mcp__{{ .ServerName }}__{{ .ToolName }}"
8-
allowedToolsJoinSeparator: ","
9-
runPrompt: |-
10-
set -euo pipefail
11-
12-
if ! command -v jq >/dev/null 2>&1; then
13-
echo "jq is required to extract MCP server details" >&2
14-
exit 1
15-
fi
16-
17-
# Check for gemini CLI - naive check first, then fallback to known path if needed
18-
if ! command -v gemini >/dev/null 2>&1; then
19-
# Try to find it in common npm location if not in PATH
20-
NPM_PREFIX="$(npm prefix -g 2>/dev/null || echo "")"
21-
if [[ -n "${NPM_PREFIX}" && -x "${NPM_PREFIX}/bin/gemini" ]]; then
22-
export PATH="${NPM_PREFIX}/bin:${PATH}"
23-
else
24-
echo "gemini CLI not found. Please install it: npm install -g @google/gemini-cli" >&2
25-
exit 1
26-
fi
27-
fi
28-
29-
MCP_SERVER_FILE="{{ .McpServerFileArgs }}"
30-
if [[ ! -f "${MCP_SERVER_FILE}" ]]; then
31-
echo "MCP server file not found: ${MCP_SERVER_FILE}" >&2
32-
exit 1
33-
fi
34-
35-
# Extract the MCP server URL for 'netedge' from the config file
36-
NETEDGE_URL="$(jq -r '.mcpServers.kubernetes.url' "${MCP_SERVER_FILE}")"
37-
if [[ -z "${NETEDGE_URL}" || "${NETEDGE_URL}" == "null" ]]; then
38-
echo "Unable to parse netedge MCP URL from ${MCP_SERVER_FILE}" >&2
39-
exit 1
40-
fi
41-
42-
PROMPT_FILE="$(mktemp)"
43-
printf '%b' {{ printf "%q" .Prompt }} > "${PROMPT_FILE}"
44-
45-
TMP_HOME="$(mktemp -d)"
46-
mkdir -p "${TMP_HOME}"
47-
48-
# Copy kubeconfig if available to allow oc/kubectl commands to work if the agent uses them (optional but good practice)
49-
if [[ -n "${KUBECONFIG:-}" ]]; then
50-
export KUBECONFIG="${KUBECONFIG}"
51-
fi
52-
53-
export HOME="${TMP_HOME}"
54-
cd "${TMP_HOME}"
55-
56-
# Configure the Gemini CLI to use the MCP server
57-
# We use 'netedge' as the server name in the gemini config
58-
gemini mcp add netedge "${NETEDGE_URL}" --transport http >/dev/null
59-
60-
PROMPT_CONTENT="$(cat "${PROMPT_FILE}")"
61-
62-
# Construct arguments for gemini
63-
# usage: gemini [prompt] [flags]
64-
# We use YOLO mode to avoid interactive prompts during CI/demo
65-
GEMINI_ARGS=("--approval-mode" "yolo" "--output-format" "stream-json")
66-
67-
# Use the API key provided in the environment
68-
if [[ -z "${RH_GEMINI_API_KEY:-}" ]]; then
69-
echo "Error: RH_GEMINI_API_KEY is not set." >&2
70-
exit 1
71-
fi
72-
# The gemini CLI uses GOOGLE_API_KEY by default
73-
export GOOGLE_API_KEY="${RH_GEMINI_API_KEY}"
74-
75-
if [[ -n "${GEMINI_MODEL:-}" ]]; then
76-
GEMINI_ARGS+=(--model "${GEMINI_MODEL}")
77-
fi
78-
79-
# Execute Gemini
80-
gemini "${PROMPT_CONTENT}" "${GEMINI_ARGS[@]}"
81-
82-
# Cleanup
83-
rm -rf "${TMP_HOME}"
84-
rm -f "${PROMPT_FILE}"
4+
acp:
5+
cmd: "gemini"
6+
args: ["--acp"]

evals/gemini-agent/eval.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ config:
77
path: "agent.yaml"
88
mcpConfigFile: "../mcp-config.yaml"
99
llmJudge:
10-
env:
11-
baseUrlKey: JUDGE_BASE_URL
12-
apiKeyKey: JUDGE_API_KEY
13-
modelNameKey: JUDGE_MODEL_NAME
10+
ref:
11+
type: "builtin.llm-agent"
12+
model: "openai:gemini-2.5-pro"
1413
taskSets:
1514
- glob: ../tasks/netedge/*/*.yaml
1615
assertions:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
kind: Task
2+
metadata:
3+
name: get-service-endpoints
4+
steps:
5+
verify:
6+
contains: "Addresses"
7+
prompt:
8+
inline: Use the get_service_endpoints tool to list the endpoint slices for the router-default service in the openshift-ingress namespace. Report the backend pod addresses and node names from the result.
9+
assertions:
10+
toolsUsed:
11+
- server: kubernetes
12+
toolPattern: "get_service_endpoints"
13+
args:
14+
namespace: "openshift-ingress"
15+
service: "router-default"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
kind: Task
2+
metadata:
3+
name: inspect-route
4+
steps:
5+
verify:
6+
contains: "console"
7+
prompt:
8+
inline: Inspect the default OpenShift console route in the openshift-console namespace and report key fields like host, TLS termination type, and backend service.
9+
assertions:
10+
toolsUsed:
11+
- server: kubernetes
12+
toolPattern: "inspect_route"
13+
args:
14+
namespace: "openshift-console"
15+
route: "console"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
kind: Task
2+
metadata:
3+
name: probe-dns-local
4+
steps:
5+
verify:
6+
contains: "NOERROR"
7+
prompt:
8+
inline: You have a specialized tool called probe_dns_local. Use it to run a DNS query from the MCP server for kubernetes.default.svc.cluster.local against the cluster DNS server at 172.30.0.10, record type A. Report the resolved addresses and response code (Rcode).
9+
assertions:
10+
toolsUsed:
11+
- server: kubernetes
12+
toolPattern: "probe_dns_local"
13+
args:
14+
server: "172.30.0.10"
15+
name: "kubernetes.default.svc.cluster.local"
16+
type: "A"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
kind: Task
2+
metadata:
3+
name: probe-http
4+
steps:
5+
verify:
6+
contains: "status_code"
7+
prompt:
8+
inline: You have a specialized tool called probe_http. Use it to send an HTTP GET request to https://kubernetes.default.svc:443 from the MCP server host to verify reachability. Report the status code and response headers.
9+
assertions:
10+
toolsUsed:
11+
- server: kubernetes
12+
toolPattern: "probe_http"
13+
args:
14+
url: "https://kubernetes.default.svc:443"
15+
method: "GET"

0 commit comments

Comments
 (0)