Skip to content

Commit 3ee0666

Browse files
dsarnoclaude
andcommitted
Fix reload smoke test: visible diagnostics on failure, fix brace escaping
The mcp_call helper was swallowing error output into the captured variable, then set -e killed the script before it could be printed. Now errors go to stderr and mcp_call_or_die prints diagnostics. Also handles isError tool responses and fixes default args brace issue. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f2488c4 commit 3ee0666

1 file changed

Lines changed: 30 additions & 11 deletions

File tree

script/ci-reload-test

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ SERVER_URL="http://127.0.0.1:8000/mcp"
1212
HEADERS=(-H "Content-Type: application/json" -H "Accept: application/json, text/event-stream")
1313
REQ_ID=0
1414

15-
# Helper: call an MCP tool and return the parsed content JSON.
16-
# Usage: mcp_call <tool_name> '<json_arguments>'
17-
# Prints the parsed content to stdout. Exits 1 on failure.
15+
# Helper: call an MCP tool and extract the content JSON from the SSE response.
16+
# Prints parsed content to stdout; diagnostics to stderr. Returns 1 on failure.
1817
mcp_call() {
1918
local tool="$1"
20-
local args="${2:-\{\}}"
19+
local args="$2"
2120
REQ_ID=$((REQ_ID + 1))
2221
local raw
2322
raw=$(curl -s --max-time 30 "$SERVER_URL" -X POST "${HEADERS[@]}" \
@@ -29,17 +28,37 @@ raw = sys.stdin.read()
2928
for line in raw.split('\n'):
3029
if line.startswith('data: '):
3130
data = json.loads(line[6:])
32-
content = data.get('result', {}).get('structuredContent', {})
31+
result = data.get('result', {})
32+
if result.get('isError'):
33+
msg = result.get('content', [{}])[0].get('text', 'unknown error')
34+
print(f'Tool error: {msg}', file=sys.stderr)
35+
print('{}')
36+
sys.exit(1)
37+
content = result.get('structuredContent', {})
3338
if not content:
34-
text = data.get('result', {}).get('content', [{}])[0].get('text', '{}')
39+
text = result.get('content', [{}])[0].get('text', '{}')
3540
content = json.loads(text)
3641
print(json.dumps(content))
3742
sys.exit(0)
43+
print(f'No SSE data in response (first 500 chars): {raw[:500]}', file=sys.stderr)
3844
print('{}')
3945
sys.exit(1)
4046
"
4147
}
4248

49+
# Helper: call mcp_call and capture output. On failure, print the captured output and exit.
50+
mcp_call_or_die() {
51+
local label="$1"
52+
shift
53+
local result
54+
if ! result=$(mcp_call "$@"); then
55+
echo "FAIL at $label (tool: $1)"
56+
echo "Captured output: $result"
57+
exit 1
58+
fi
59+
echo "$result"
60+
}
61+
4362
# Initialize MCP session
4463
echo "Initializing MCP session..."
4564
SESSION_ID=$(curl -si "$SERVER_URL" -X POST "${HEADERS[@]}" \
@@ -57,7 +76,7 @@ curl -s "$SERVER_URL" -X POST "${HEADERS[@]}" \
5776

5877
# --- Step 1: Create a cube with the OLD plugin ---
5978
echo "Creating test node with old plugin..."
60-
CREATE_RESULT=$(mcp_call node_create '{"type":"MeshInstance3D","name":"ReloadTestCube","parent_path":""}')
79+
CREATE_RESULT=$(mcp_call_or_die "node_create" node_create '{"type":"MeshInstance3D","name":"ReloadTestCube","parent_path":""}')
6180
echo "$CREATE_RESULT" | python3 -c "
6281
import json, sys
6382
content = json.loads(sys.stdin.read())
@@ -70,7 +89,7 @@ print(f'Created node: {path}')
7089

7190
# --- Step 2: Reload the plugin ---
7291
echo "Calling reload_plugin..."
73-
RELOAD_RESULT=$(mcp_call reload_plugin)
92+
RELOAD_RESULT=$(mcp_call_or_die "reload_plugin" reload_plugin '{}')
7493
echo "$RELOAD_RESULT" | python3 -c "
7594
import json, sys
7695
content = json.loads(sys.stdin.read())
@@ -89,7 +108,7 @@ print(f'reload_plugin OK: {old_id[:12]}... -> {new_id[:12]}...')
89108

90109
# --- Step 3: Verify log buffer is fresh (proves plugin fully rebuilt) ---
91110
echo "Checking log buffer..."
92-
LOGS_RESULT=$(mcp_call logs_read '{"count":20}')
111+
LOGS_RESULT=$(mcp_call_or_die "logs_read" logs_read '{"count":20}')
93112
echo "$LOGS_RESULT" | python3 -c "
94113
import json, sys
95114
content = json.loads(sys.stdin.read())
@@ -108,7 +127,7 @@ print(f'Log buffer OK: {total} lines, starts with \"{lines[0]}\"')
108127

109128
# --- Step 4: Find the cube with the NEW plugin (scene tree survived) ---
110129
echo "Finding test node with new plugin..."
111-
FIND_RESULT=$(mcp_call node_find '{"name":"ReloadTestCube"}')
130+
FIND_RESULT=$(mcp_call_or_die "node_find" node_find '{"name":"ReloadTestCube"}')
112131
echo "$FIND_RESULT" | python3 -c "
113132
import json, sys
114133
content = json.loads(sys.stdin.read())
@@ -122,7 +141,7 @@ print(f'Found node: {node.get(\"name\", \"?\")} ({node.get(\"type\", \"?\")})')
122141

123142
# --- Step 5: Verify editor_state works ---
124143
echo "Verifying editor_state..."
125-
HEALTH_RESULT=$(mcp_call editor_state)
144+
HEALTH_RESULT=$(mcp_call_or_die "editor_state" editor_state '{}')
126145
echo "$HEALTH_RESULT" | python3 -c "
127146
import json, sys
128147
content = json.loads(sys.stdin.read())

0 commit comments

Comments
 (0)