fix(mcp): tools/list emitted an unparseable frame -- the tool was invisible to agents
The tools/list response was built as {"jsonrpc":"2.0","id":N,"result":<MCP_TOOLS_JSON> with no closing brace for the outer object: MCP_TOOLS_JSON is the *value* of "result" and brings only its own braces. yyjson on the other end rejects the line, and scorpiox-connector-mcp's proc_request() treats an unparseable line as "noise on stdout", keeps reading, hits EOF at process exit and reports error: tools/list failed for ntfy: no response so `sx-connector-mcp --list` showed ntfy as a connector but no agent could ever see or call ntfy_send. Reproduced against the installed binary on the node and confirmed against the memory connector as control (9 tools, fine). The suite missed it because the MCP assertions were substring greps -- "ntfy_send" is present in the broken frame. The tools/list check now parses every emitted frame and asserts the parsed shape (non-empty tools, description, object inputSchema, message required), which rejects the old frame. +1 assertion; offline suite 169, 0 fail. Version 1.0.1.
AuthorPico <picobot@scorpioplayer.com>
Date2026-11-14 04:43:25
Commit531d88fa
Parents97c0b32d
Changed files
plugin.json+1−1■■
src/plugin_ntfy.c+13−2■■■■■
tests/run.sh+28−0■■■■■
3 files+42−3
Diff
plugin.json+1−1■■
index 7fc5c2c..d9764e6 100644
--- a/plugin.json
+++ b/plugin.json
@@ -6,7 +6,7 @@
66 "title": "ntfy Push & Pub/Sub Channel Connector",
77 "summary": "Zero-dependency ntfy connector with two faces: an MCP tool (ntfy_send) so the agent can push alerts and report summaries to your phone, and a supervised channel daemon that subscribes to a topic's NDJSON stream, holds every unknown sender in a default-deny pairing queue, forwards only approved senders' messages to a SCORPIOX BOT session through POST /inbox, and publishes the agent's newest reply back to the publish topic. Setup, pairing approval and a live daemon log live behind node authentication; TLS verification is fail-closed against a bundled root store with an SPKI pin option for self-hosted relays.",
88 "category": "network",
9- "version": "1.0.0",
9+ "version": "1.0.1",
1010 "license": "MIT",
1111 "kind": "hybrid",
1212 "mcp": true,
src/plugin_ntfy.c+13−2■■■■■
index e2fe8bf..cdddcd5 100644
--- a/src/plugin_ntfy.c
+++ b/src/plugin_ntfy.c
@@ -100,7 +100,7 @@
100100
101101 #define PLUGIN_SLUG "ntfy"
102102 #define PLUGIN_ID "plugin_ntfy"
103-#define PLUGIN_VER "1.0.0"
103+#define PLUGIN_VER "1.0.1"
104104 #define SELF_SOURCE_ID "scorpiox-bot-plugin-ntfy"
105105
106106 /* The tag every notification THIS plugin publishes carries. A second,
@@ -550,9 +550,20 @@ static int mode_mcp(void)
550550 if (has_id) { char b[64]; snprintf(b, sizeof b, "{\"jsonrpc\":\"2.0\",\"id\":%lld,\"result\":{}}", id); mcp_send_raw(b); }
551551 } else if (!strcmp(method, "tools/list")) {
552552 if (has_id) {
553+ /* +64 for the id digits and the closing brace. The closing
554+ * brace of the *outer* object is ours to emit: MCP_TOOLS_JSON
555+ * is the value of "result", so without it the frame is one
556+ * brace short. yyjson then rejects the line, the router
557+ * (scorpiox-connector-mcp proc_request) skips it as "noise on
558+ * stdout", reads again, hits EOF and reports
559+ * "tools/list failed for ntfy: no response" -- the tool would
560+ * be invisible to every agent. A substring grep in the suite
561+ * passed on the broken frame; the assertion that catches this
562+ * now parses every emitted frame. */
553563 char *buf = malloc(strlen(MCP_TOOLS_JSON) + 64);
554564 if (buf) {
555- sprintf(buf, "{\"jsonrpc\":\"2.0\",\"id\":%lld,\"result\":%s", id, MCP_TOOLS_JSON);
565+ sprintf(buf, "{\"jsonrpc\":\"2.0\",\"id\":%lld,\"result\":%s}",
566+ id, MCP_TOOLS_JSON);
556567 mcp_send_raw(buf);
557568 free(buf);
558569 }
tests/run.sh+28−0■■■■■
index 75e317e..3349313 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -268,6 +268,34 @@ MOUT=$(printf '%s\n%s\n%s\n' \
268268 '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' | $BIN --mcp)
269269 INIT=$(printf '%s\n' "$MOUT" | head -1)
270270 json_ok "initialize answers" "$INIT" "d['result']['serverInfo']['name']=='plugin_ntfy' and 'protocolVersion' in d['result']"
271+# Every frame the MCP server prints must be parseable JSON. This is not
272+# pedantry: scorpiox-connector-mcp's proc_request() treats an unparseable line
273+# as "noise on stdout", keeps reading, hits EOF and reports
274+# `tools/list failed for ntfy: no response` - a connector whose tools the
275+# agent can simply never see. A substring grep passes happily on a frame no
276+# parser will accept, so the tools/list frame is validated the way the router
277+# will actually consume it (the first cut of this handler emitted the result
278+# object without its closing brace and passed every grep).
279+MJSON=$(printf '%s\n' "$MOUT" | python3 -c '
280+import sys, json
281+lines = [l for l in sys.stdin.read().splitlines() if l.strip()]
282+assert lines, "no frames at all"
283+parsed = [json.loads(l) for l in lines]
284+tl = [p for p in parsed if "result" in p and "tools" in p["result"]]
285+assert tl, "no tools/list response among %d frames" % len(parsed)
286+tools = tl[0]["result"]["tools"]
287+assert tools, "tools/list returned an empty list"
288+assert any(t.get("name") == "ntfy_send" for t in tools), [t.get("name") for t in tools]
289+for t in tools:
290+ assert t.get("description"), "tool without a description"
291+ assert isinstance(t.get("inputSchema"), dict), "tool without an inputSchema"
292+ assert t["inputSchema"].get("type") == "object", t["inputSchema"].get("type")
293+ assert "message" in t["inputSchema"].get("properties", {}), "no message param"
294+ assert "message" in t["inputSchema"].get("required", []), "message not required"
295+print("ok")
296+' 2>&1)
297+[ "$MJSON" = "ok" ] && pass "every --mcp frame parses and the tool schema is complete" \
298+ || fail "every --mcp frame parses and the tool schema is complete" "$MJSON"
271299 check "tools/list offers ntfy_send" 'ntfy_send' "$MOUT"
272300 check "the tool schema has message" '"message"' "$MOUT"
273301 check "the tool schema has priority" '"priority"' "$MOUT"
274302
plugin.json+1−1■■
index 7fc5c2c..d9764e6 100644index 7fc5c2c..d9764e6 100644
--- a/plugin.json--- a/plugin.json
+++ b/plugin.json+++ b/plugin.json
@@ -6,7 +6,7 @@@@ -6,7 +6,7 @@
6 "title": "ntfy Push & Pub/Sub Channel Connector",6 "title": "ntfy Push & Pub/Sub Channel Connector",
7 "summary": "Zero-dependency ntfy connector with two faces: an MCP tool (ntfy_send) so the agent can push alerts and report summaries to your phone, and a supervised channel daemon that subscribes to a topic's NDJSON stream, holds every unknown sender in a default-deny pairing queue, forwards only approved senders' messages to a SCORPIOX BOT session through POST /inbox, and publishes the agent's newest reply back to the publish topic. Setup, pairing approval and a live daemon log live behind node authentication; TLS verification is fail-closed against a bundled root store with an SPKI pin option for self-hosted relays.",7 "summary": "Zero-dependency ntfy connector with two faces: an MCP tool (ntfy_send) so the agent can push alerts and report summaries to your phone, and a supervised channel daemon that subscribes to a topic's NDJSON stream, holds every unknown sender in a default-deny pairing queue, forwards only approved senders' messages to a SCORPIOX BOT session through POST /inbox, and publishes the agent's newest reply back to the publish topic. Setup, pairing approval and a live daemon log live behind node authentication; TLS verification is fail-closed against a bundled root store with an SPKI pin option for self-hosted relays.",
8 "category": "network",8 "category": "network",
9- "version": "1.0.0",9+ "version": "1.0.1",
10 "license": "MIT",10 "license": "MIT",
11 "kind": "hybrid",11 "kind": "hybrid",
12 "mcp": true,12 "mcp": true,
src/plugin_ntfy.c+13−2■■■■■
index e2fe8bf..cdddcd5 100644index e2fe8bf..cdddcd5 100644
--- a/src/plugin_ntfy.c--- a/src/plugin_ntfy.c
+++ b/src/plugin_ntfy.c+++ b/src/plugin_ntfy.c
@@ -100,7 +100,7 @@@@ -100,7 +100,7 @@
100 100
101 #define PLUGIN_SLUG "ntfy"101 #define PLUGIN_SLUG "ntfy"
102 #define PLUGIN_ID "plugin_ntfy"102 #define PLUGIN_ID "plugin_ntfy"
103-#define PLUGIN_VER "1.0.0"103+#define PLUGIN_VER "1.0.1"
104 #define SELF_SOURCE_ID "scorpiox-bot-plugin-ntfy"104 #define SELF_SOURCE_ID "scorpiox-bot-plugin-ntfy"
105 105
106 /* The tag every notification THIS plugin publishes carries. A second,106 /* The tag every notification THIS plugin publishes carries. A second,
@@ -550,9 +550,20 @@ static int mode_mcp(void)@@ -550,9 +550,20 @@ static int mode_mcp(void)
550 if (has_id) { char b[64]; snprintf(b, sizeof b, "{\"jsonrpc\":\"2.0\",\"id\":%lld,\"result\":{}}", id); mcp_send_raw(b); }550 if (has_id) { char b[64]; snprintf(b, sizeof b, "{\"jsonrpc\":\"2.0\",\"id\":%lld,\"result\":{}}", id); mcp_send_raw(b); }
551 } else if (!strcmp(method, "tools/list")) {551 } else if (!strcmp(method, "tools/list")) {
552 if (has_id) {552 if (has_id) {
553+ /* +64 for the id digits and the closing brace. The closing
554+ * brace of the *outer* object is ours to emit: MCP_TOOLS_JSON
555+ * is the value of "result", so without it the frame is one
556+ * brace short. yyjson then rejects the line, the router
557+ * (scorpiox-connector-mcp proc_request) skips it as "noise on
558+ * stdout", reads again, hits EOF and reports
559+ * "tools/list failed for ntfy: no response" -- the tool would
560+ * be invisible to every agent. A substring grep in the suite
561+ * passed on the broken frame; the assertion that catches this
562+ * now parses every emitted frame. */
553 char *buf = malloc(strlen(MCP_TOOLS_JSON) + 64);563 char *buf = malloc(strlen(MCP_TOOLS_JSON) + 64);
554 if (buf) {564 if (buf) {
555- sprintf(buf, "{\"jsonrpc\":\"2.0\",\"id\":%lld,\"result\":%s", id, MCP_TOOLS_JSON);565+ sprintf(buf, "{\"jsonrpc\":\"2.0\",\"id\":%lld,\"result\":%s}",
566+ id, MCP_TOOLS_JSON);
556 mcp_send_raw(buf);567 mcp_send_raw(buf);
557 free(buf);568 free(buf);
558 }569 }
tests/run.sh+28−0■■■■■
index 75e317e..3349313 100755index 75e317e..3349313 100755
--- a/tests/run.sh--- a/tests/run.sh
+++ b/tests/run.sh+++ b/tests/run.sh
@@ -268,6 +268,34 @@ MOUT=$(printf '%s\n%s\n%s\n' \@@ -268,6 +268,34 @@ MOUT=$(printf '%s\n%s\n%s\n' \
268 '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' | $BIN --mcp)268 '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' | $BIN --mcp)
269 INIT=$(printf '%s\n' "$MOUT" | head -1)269 INIT=$(printf '%s\n' "$MOUT" | head -1)
270 json_ok "initialize answers" "$INIT" "d['result']['serverInfo']['name']=='plugin_ntfy' and 'protocolVersion' in d['result']"270 json_ok "initialize answers" "$INIT" "d['result']['serverInfo']['name']=='plugin_ntfy' and 'protocolVersion' in d['result']"
271+# Every frame the MCP server prints must be parseable JSON. This is not
272+# pedantry: scorpiox-connector-mcp's proc_request() treats an unparseable line
273+# as "noise on stdout", keeps reading, hits EOF and reports
274+# `tools/list failed for ntfy: no response` - a connector whose tools the
275+# agent can simply never see. A substring grep passes happily on a frame no
276+# parser will accept, so the tools/list frame is validated the way the router
277+# will actually consume it (the first cut of this handler emitted the result
278+# object without its closing brace and passed every grep).
279+MJSON=$(printf '%s\n' "$MOUT" | python3 -c '
280+import sys, json
281+lines = [l for l in sys.stdin.read().splitlines() if l.strip()]
282+assert lines, "no frames at all"
283+parsed = [json.loads(l) for l in lines]
284+tl = [p for p in parsed if "result" in p and "tools" in p["result"]]
285+assert tl, "no tools/list response among %d frames" % len(parsed)
286+tools = tl[0]["result"]["tools"]
287+assert tools, "tools/list returned an empty list"
288+assert any(t.get("name") == "ntfy_send" for t in tools), [t.get("name") for t in tools]
289+for t in tools:
290+ assert t.get("description"), "tool without a description"
291+ assert isinstance(t.get("inputSchema"), dict), "tool without an inputSchema"
292+ assert t["inputSchema"].get("type") == "object", t["inputSchema"].get("type")
293+ assert "message" in t["inputSchema"].get("properties", {}), "no message param"
294+ assert "message" in t["inputSchema"].get("required", []), "message not required"
295+print("ok")
296+' 2>&1)
297+[ "$MJSON" = "ok" ] && pass "every --mcp frame parses and the tool schema is complete" \
298+ || fail "every --mcp frame parses and the tool schema is complete" "$MJSON"
271 check "tools/list offers ntfy_send" 'ntfy_send' "$MOUT"299 check "tools/list offers ntfy_send" 'ntfy_send' "$MOUT"
272 check "the tool schema has message" '"message"' "$MOUT"300 check "the tool schema has message" '"message"' "$MOUT"
273 check "the tool schema has priority" '"priority"' "$MOUT"301 check "the tool schema has priority" '"priority"' "$MOUT"
274302