Agent skill that turns natural language, code, Terraform/K8s, SQL, OpenAPI, AsyncAPI, Protobuf and GraphQL sources into editable, tested draw.io architecture diagrams: incremental sync, multi-view projection, drift diff, CI architecture tests, whiteboard derasterize, interactive HTML/PPTX/Mermaid exports.
Python agent-skillsarchitecturearchitecture-diagramasyncapibpmnc4-modelclaude-codediagramdiagrams-as-codedrawioflowchartgithub-actionsgraphqlimage-to-diagramkubernetesmcp-serverprotobufsysmlterraformuml
fix: validate MCP requests and architecture policies (#137)
Agents365.aic40c2d8833a6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 02cc478..8ac7a6a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,24 @@ on [Keep a Changelog](https://keepachangelog.com/), and the project followssemantic-ish versioning (the `metadata.version` field in`skills/drawio-skill/SKILL.md`).+## [Unreleased]++### Fixed++- **MCP server: nonzero tool exits now set `isError`**: `architecture_test`+ contract failures (exit 1) and strict-warning failures were reported as+ success. Any nonzero `diagramctl` exit now maps to `isError: true`.+- **MCP server: malformed JSON-RPC input no longer terminates the stdio+ server**: a non-object request, a wrong `jsonrpc` version, a non-string+ method, non-object `params`, or tool arguments with missing, wrong-typed,+ unknown, or out-of-enum fields now return JSON-RPC `-32600` / `-32602`+ errors with readable diagnostics, and later requests in the same process are+ still served. Unknown tools keep a distinct message.+- **Unknown architecture rule ids are rejected**: `semantic_findings` raises+ `ValueError` listing the unrecognized ids and the valid rules instead of+ silently skipping the check; `diagramctl test` reports it on stderr and+ exits 2. `review()` and all eight existing rule ids are unchanged.+## [3.4.0] - 2026-09-14### Addeddiff --git a/skills/drawio-skill/SKILL.md b/skills/drawio-skill/SKILL.mdindex 5599e6e..72dd568 100644--- a/skills/drawio-skill/SKILL.md+++ b/skills/drawio-skill/SKILL.md@@ -4,7 +4,7 @@ name: drawio-skilldescription: Create and edit draw.io/diagrams.net diagrams as editable `.drawio` files. Covers architecture, UML/ERD/sequence, BPMN, network, and swimlane views authored from a description or converted from code, IaC, SQL, and API schemas, plus sync, query, test, review, export, and publish of existing diagrams. Use when the user asks for draw.io/diagrams.net or an editable diagram; prefer Mermaid/PlantUML when diagrams-as-code is enough.license: MITallowed-tools: [Bash, Read, Write, WebFetch]-metadata: {"openclaw":{"requires":{"anyBins":["python3"]},"emoji":"📐","os":["darwin","linux","win32"],"install":[{"id":"brew-drawio","kind":"brew","formula":"drawio","bins":["drawio"],"label":"Install draw.io for native exports","os":["darwin"],"optional":true},{"id":"brew-graphviz","kind":"brew","formula":"graphviz","bins":["dot"],"label":"Install Graphviz for automatic layout","os":["darwin"],"optional":true}]},"hermes":{"tags":["drawio","diagram","architecture","visualization","uml"],"category":"design","requires_tools":["python3"],"related_skills":["mermaid","excalidraw","plantuml"]},"author":"Agents365-ai","version":"3.4.0","homepage":"https://github.com/Agents365-ai/drawio-skill","compatibility":"Core IR, XML, sync, query, test, review, and Story workflows need Python 3 only; native export needs draw.io; Graphviz is optional.","platforms":["macos","linux","windows"]}+metadata: {"openclaw":{"requires":{"anyBins":["python3"]},"emoji":"📐","os":["darwin","linux","win32"],"install":[{"id":"brew-drawio","kind":"brew","formula":"drawio","bins":["drawio"],"label":"Install draw.io for native exports","os":["darwin"],"optional":true},{"id":"brew-graphviz","kind":"brew","formula":"graphviz","bins":["dot"],"label":"Install Graphviz for automatic layout","os":["darwin"],"optional":true}]},"hermes":{"tags":["drawio","diagram","architecture","visualization","uml"],"category":"design","requires_tools":["python3"],"related_skills":["mermaid","excalidraw","plantuml"]},"author":"Agents365-ai","version":"3.4.1","homepage":"https://github.com/Agents365-ai/drawio-skill","compatibility":"Core IR, XML, sync, query, test, review, and Story workflows need Python 3 only; native export needs draw.io; Graphviz is optional.","platforms":["macos","linux","windows"]}---# Draw.io Architecture Studiodiff --git a/skills/drawio-skill/references/semantic-workflows.md b/skills/drawio-skill/references/semantic-workflows.mdindex eff8a48..6d5ec3a 100644--- a/skills/drawio-skill/references/semantic-workflows.md+++ b/skills/drawio-skill/references/semantic-workflows.md@@ -30,6 +30,11 @@ Errors always fail. Warnings fail only under `--strict`. These rules inspectdeclared diagram semantics; they do not claim to prove that the running systemhas the same properties.+Every rule id must be one of the eight listed above. An unrecognized id (for+example a typo in a policy file) is a configuration error: `test` writes the+offending ids to stderr and exits 2 rather than silently skipping the intended+check.+## Query and review```bashdiff --git a/skills/drawio-skill/scripts/diagram_ir.py b/skills/drawio-skill/scripts/diagram_ir.pyindex 384b1d6..4c329d1 100644--- a/skills/drawio-skill/scripts/diagram_ir.py+++ b/skills/drawio-skill/scripts/diagram_ir.py@@ -752,6 +752,20 @@ DEFAULT_RULES = ["accessible-contrast",]+# Every rule id semantic_findings can evaluate, including the optional rules a+# policy or review() selects on top of DEFAULT_RULES. An id outside this set is+# a configuration error, never a silently skipped check.+SEMANTIC_RULES = (+ "no-direct-internet-to-database",+ "no-cycles",+ "no-orphans",+ "every-service-has-owner",+ "production-has-observability",+ "external-dependencies-have-timeouts",+ "trust-boundaries-use-protocol",+ "accessible-contrast",+)+ARCHITECTURE_KINDS = {"service","gateway",@@ -780,6 +794,14 @@ def infer_profile(ir):def semantic_findings(ir, rule_ids=None):ir = normalize_ir(ir)rules = rule_ids or DEFAULT_RULES+ unknown = [r for r in rules if r not in SEMANTIC_RULES]+ if unknown:+ raise ValueError(+ "unknown semantic rule(s): "+ + ", ".join(str(r) for r in unknown)+ + "; valid rules: "+ + ", ".join(SEMANTIC_RULES)+ )nodes = {n["id"]: n for n in ir["nodes"]}incoming, outgoing = adjacency(ir, reverse=True), adjacency(ir)findings = []diff --git a/skills/drawio-skill/scripts/diagramctl_mcp.py b/skills/drawio-skill/scripts/diagramctl_mcp.pyindex 71a0d3a..a845778 100644--- a/skills/drawio-skill/scripts/diagramctl_mcp.py+++ b/skills/drawio-skill/scripts/diagramctl_mcp.py@@ -266,6 +266,57 @@ def call_tool(name, arguments):return proc.returncode, text+def validate_arguments(tool, arguments):+ """Validate tool arguments against the tool's flat input schema.++ Returns the arguments unchanged, or raises MethodError(-32602) with a+ readable diagnostic. Without this check a missing key reaches argv+ construction and surfaces as a misleading unknown-tool error.+ """+ if arguments is None:+ arguments = {}+ name = tool["name"]+ if not isinstance(arguments, dict):+ raise MethodError(+ -32602, f"invalid params: arguments for tool {name!r} must be an object"+ )+ schema = tool["inputSchema"]+ missing = [key for key in schema["required"] if key not in arguments]+ if missing:+ raise MethodError(+ -32602,+ f"invalid params: missing required argument(s) "+ f"{', '.join(missing)} for tool {name!r}",+ )+ for key, value in arguments.items():+ spec = schema["properties"].get(key)+ if spec is None:+ raise MethodError(+ -32602, f"invalid params: unknown argument {key!r} for tool {name!r}"+ )+ expected = spec["type"]+ if expected == "boolean" and not isinstance(value, bool):+ raise MethodError(+ -32602,+ f"invalid params: argument {key!r} for tool {name!r} "+ f"must be a {expected}",+ )+ if expected == "string" and not isinstance(value, str):+ raise MethodError(+ -32602,+ f"invalid params: argument {key!r} for tool {name!r} "+ f"must be a {expected}",+ )+ allowed = spec.get("enum")+ if allowed is not None and value not in allowed:+ raise MethodError(+ -32602,+ f"invalid params: argument {key!r} for tool {name!r} "+ f"must be one of {', '.join(str(a) for a in allowed)}",+ )+ return arguments++def dispatch(method, params):if method == "initialize":return {@@ -288,10 +339,14 @@ def dispatch(method, params):}if method == "tools/call":name = params.get("name", "")+ if not isinstance(name, str):+ raise MethodError(-32602, "invalid params: tool name must be a string")+ tool = next((t for t in TOOLS if t["name"] == name), None)+ if tool is None:+ raise MethodError(-32602, f"unknown tool {name!r}")+ arguments = validate_arguments(tool, params.get("arguments"))try:- code, text = call_tool(name, params.get("arguments") or {})- except KeyError:- raise MethodError(-32602, f"unknown tool {name!r}") from None+ code, text = call_tool(name, arguments)except ValueError as exc:return {"content": [{"type": "text", "text": str(exc)}], "isError": True}except subprocess.TimeoutExpired:@@ -306,7 +361,7 @@ def dispatch(method, params):}return {"content": [{"type": "text", "text": text}],- "isError": code not in (0, 1),+ "isError": code != 0,}raise MethodError(-32601, f"method not found: {method}")@@ -318,22 +373,57 @@ class MethodError(Exception):self.message = message+def error_response(id_value, code, message):+ return {+ "jsonrpc": "2.0",+ "id": id_value,+ "error": {"code": code, "message": message},+ }++def handle(line):"""Handle one JSON-RPC message; returns a response dict or None (notification)."""try:msg = json.loads(line)except ValueError:- return {- "jsonrpc": "2.0",- "id": None,- "error": {"code": -32700, "message": "parse error"},- }- method = msg.get("method", "")- is_notification = "id" not in msg- if method.startswith("notifications/"):+ return error_response(None, -32700, "parse error")+ if not isinstance(msg, dict):+ return error_response(None, -32600, "invalid request: expected a JSON object")+ method = msg.get("method")+ if isinstance(method, str) and method.startswith("notifications/"):+ # Legacy notification-method suppression (MCP names such as+ # notifications/initialized): never answered, valid or not.return None+ if "id" in msg:+ id_value = msg["id"]+ is_valid_id = id_value is None or (+ not isinstance(id_value, bool)+ and isinstance(id_value, (str, int, float))+ )+ if not is_valid_id:+ return error_response(+ None,+ -32600,+ "invalid request: id must be a string, number, or null",+ )+ if msg.get("jsonrpc") != "2.0":+ return error_response(+ msg.get("id"), -32600, "invalid request: jsonrpc must be '2.0'"+ )+ if not isinstance(method, str):+ return error_response(+ msg.get("id"), -32600, "invalid request: method must be a string"+ )+ is_notification = "id" not in msg+ params = msg.get("params")+ if params is not None and not isinstance(params, dict):+ if is_notification:+ return None+ return error_response(+ msg.get("id"), -32602, "invalid params: expected an object"+ )try:- result = dispatch(method, msg.get("params") or {})+ result = dispatch(method, params or {})return (Noneif is_notificationdiff --git a/tests/test_diagramctl.py b/tests/test_diagramctl.pyindex 01001ca..7eaa358 100644--- a/tests/test_diagramctl.py+++ b/tests/test_diagramctl.py@@ -153,6 +153,50 @@ class TestDiagramIR(unittest.TestCase):findings = d.semantic_findings(ir, ["no-direct-internet-to-database"])self.assertEqual("error", findings[0]["severity"])+ def test_all_eight_semantic_rules_remain_supported(self):+ expected = {+ "no-direct-internet-to-database",+ "no-cycles",+ "no-orphans",+ "every-service-has-owner",+ "production-has-observability",+ "external-dependencies-have-timeouts",+ "trust-boundaries-use-protocol",+ "accessible-contrast",+ }+ self.assertEqual(expected, set(d.SEMANTIC_RULES))+ ir = sample_ir()+ for rule in sorted(expected):+ self.assertIsInstance(d.semantic_findings(ir, [rule]), list)++ def test_unknown_semantic_rule_is_rejected(self):+ with self.assertRaises(ValueError) as ctx:+ d.semantic_findings(sample_ir(), ["no-cycles", "no-cyclse"])+ message = str(ctx.exception)+ self.assertIn("unknown semantic rule(s): no-cyclse", message)+ self.assertIn("; valid rules: ", message)+ for rule in d.SEMANTIC_RULES:+ self.assertIn(rule, message)++ def test_default_and_empty_rule_lists_keep_default_selection(self):+ ir = sample_ir()+ ir["edges"].append(+ {+ "id": "direct",+ "source": "internet",+ "target": "db",+ "label": "",+ "kind": "relation",+ "properties": {},+ }+ )+ for selection in (None, []):+ findings = d.semantic_findings(ir, selection)+ self.assertTrue(+ any(f["rule"] == "no-direct-internet-to-database" for f in findings),+ selection,+ )+def test_drawio_roundtrip_and_provenance(self):with tempfile.TemporaryDirectory() as td:path = os.path.join(td, "out.drawio")@@ -407,6 +451,58 @@ class TestDiagramCtl(unittest.TestCase):)self.assertEqual(d.infer_profile(arch), "architecture")+ def test_policy_with_unknown_rule_fails_readably(self):+ with tempfile.TemporaryDirectory() as td:+ ir_path = os.path.join(td, "model.json")+ ir = sample_ir()+ ir["edges"].append(+ {+ "id": "direct",+ "source": "internet",+ "target": "db",+ "label": "",+ "kind": "relation",+ "properties": {},+ }+ )+ with open(ir_path, "w", encoding="utf-8") as fh:+ json.dump(ir, fh)+ policy = os.path.join(td, "policy.json")+ with open(policy, "w", encoding="utf-8") as fh:+ json.dump({"rules": ["no-direct-internet-to-databse"]}, fh)+ r = self.run_cli("test", ir_path, "--rules", policy)+ self.assertEqual(2, r.returncode, r.stdout)+ self.assertEqual("", r.stdout)+ self.assertIn("unknown semantic rule", r.stderr)+ self.assertIn("no-direct-internet-to-databse", r.stderr)++ def test_policy_with_supported_rule_reports_violation(self):+ with tempfile.TemporaryDirectory() as td:+ ir_path = os.path.join(td, "model.json")+ ir = sample_ir()+ ir["edges"].append(+ {+ "id": "direct",+ "source": "internet",+ "target": "db",+ "label": "",+ "kind": "relation",+ "properties": {},+ }+ )+ with open(ir_path, "w", encoding="utf-8") as fh:+ json.dump(ir, fh)+ policy = os.path.join(td, "policy.json")+ with open(policy, "w", encoding="utf-8") as fh:+ json.dump({"rules": ["no-direct-internet-to-database"]}, fh)+ r = self.run_cli("test", ir_path, "--rules", policy)+ self.assertEqual(1, r.returncode, r.stderr)+ report = json.loads(r.stdout)+ self.assertEqual(1, report["errors"])+ self.assertEqual(+ "no-direct-internet-to-database", report["findings"][0]["rule"]+ )+if __name__ == "__main__":unittest.main()diff --git a/tests/test_mcp_server.py b/tests/test_mcp_server.pyindex 9090688..e2b13cd 100644--- a/tests/test_mcp_server.py+++ b/tests/test_mcp_server.py@@ -63,6 +63,85 @@ class TestMcpProtocol(unittest.TestCase):resp = rpc("tools/call", {"name": "bogus"})self.assertEqual(resp["error"]["code"], -32602)+ def test_non_object_request_is_invalid_request(self):+ for payload in ("[]", "null", "42", '"ping"'):+ resp = mcp.handle(payload)+ self.assertEqual(-32600, resp["error"]["code"], payload)+ self.assertIsNone(resp["id"])++ def test_invalid_version_is_invalid_request(self):+ resp = mcp.handle(json.dumps({"jsonrpc": "1.0", "id": 7, "method": "ping"}))+ self.assertEqual(-32600, resp["error"]["code"])+ self.assertEqual(7, resp["id"])++ def test_missing_or_non_string_method_is_invalid_request(self):+ resp = mcp.handle(json.dumps({"jsonrpc": "2.0", "id": 1}))+ self.assertEqual(-32600, resp["error"]["code"])+ self.assertEqual(1, resp["id"])+ resp = mcp.handle(json.dumps({"jsonrpc": "2.0", "id": 2, "method": ["ping"]}))+ self.assertEqual(-32600, resp["error"]["code"])+ self.assertEqual(2, resp["id"])++ def test_non_object_params_is_invalid_params(self):+ for params in ([], "ping", 3, True):+ line = json.dumps(+ {"jsonrpc": "2.0", "id": 1, "method": "ping", "params": params}+ )+ resp = mcp.handle(line)+ self.assertEqual(-32602, resp["error"]["code"], params)++ def test_unknown_notification_is_silent(self):+ line = json.dumps(+ {+ "jsonrpc": "2.0",+ "method": "notifications/cancelled",+ "params": {"requestId": 3},+ }+ )+ self.assertIsNone(mcp.handle(line))++ def test_notification_with_invalid_params_is_silent(self):+ # A message without an id is a notification: invalid params must not+ # produce an error response.+ line = json.dumps({"jsonrpc": "2.0", "method": "ping", "params": []})+ self.assertIsNone(mcp.handle(line))++ def test_notification_with_invalid_tool_arguments_is_silent(self):+ line = json.dumps(+ {+ "jsonrpc": "2.0",+ "method": "tools/call",+ "params": {"name": "build", "arguments": {}},+ }+ )+ self.assertIsNone(mcp.handle(line))++ def test_invalid_request_without_id_is_still_answered(self):+ # Only the invalid-params path is notification-suppressed; an invalid+ # request is answered even without an id.+ resp = mcp.handle(json.dumps({"jsonrpc": "2.0", "method": ["ping"]}))+ self.assertEqual(-32600, resp["error"]["code"])+ self.assertIsNone(resp["id"])++ def test_invalid_id_shapes_are_rejected(self):+ for bad_id in ([1], {"a": 1}, True, False):+ line = json.dumps(+ {"jsonrpc": "2.0", "id": bad_id, "method": "ping", "params": {}}+ )+ resp = mcp.handle(line)+ self.assertEqual(-32600, resp["error"]["code"], bad_id)+ self.assertIsNone(resp["id"], bad_id)++ def test_supported_ids_are_echoed(self):+ for good_id in ("abc", 7, 2.5, None):+ line = json.dumps(+ {"jsonrpc": "2.0", "id": good_id, "method": "ping", "params": {}}+ )+ resp = mcp.handle(line)+ self.assertIsNone(resp.get("error"), good_id)+ self.assertEqual({}, resp["result"], good_id)+ self.assertEqual(good_id, resp["id"], good_id)+class TestMcpTools(unittest.TestCase):def test_tools_list(self):@@ -140,6 +219,148 @@ class TestMcpTools(unittest.TestCase):self.assertTrue(resp["result"]["isError"])+class TestMcpToolArgumentValidation(unittest.TestCase):+ def test_missing_required_arguments_is_invalid_params(self):+ resp = rpc("tools/call", {"name": "build", "arguments": {"source": "x"}})+ self.assertEqual(-32602, resp["error"]["code"])+ self.assertIn("output", resp["error"]["message"])+ self.assertIn("build", resp["error"]["message"])+ self.assertNotIn("unknown tool", resp["error"]["message"])++ def test_all_missing_required_arguments_are_listed(self):+ resp = rpc("tools/call", {"name": "sync"})+ self.assertEqual(-32602, resp["error"]["code"])+ for key in ("diagram", "source", "output"):+ self.assertIn(key, resp["error"]["message"])++ def test_wrong_type_argument_is_invalid_params(self):+ resp = rpc(+ "tools/call",+ {"name": "build", "arguments": {"source": 3, "output": "x"}},+ )+ self.assertEqual(-32602, resp["error"]["code"])+ self.assertIn("source", resp["error"]["message"])+ resp = rpc("tools/call", {"name": "doctor", "arguments": {"probe": "yes"}})+ self.assertEqual(-32602, resp["error"]["code"])+ self.assertIn("probe", resp["error"]["message"])++ def test_unknown_argument_is_invalid_params(self):+ resp = rpc(+ "tools/call",+ {"name": "doctor", "arguments": {"probe": True, "verbose": True}},+ )+ self.assertEqual(-32602, resp["error"]["code"])+ self.assertIn("verbose", resp["error"]["message"])++ def test_enum_argument_is_invalid_params(self):+ resp = rpc(+ "tools/call",+ {"name": "review", "arguments": {"input": "m.json", "format": "xml"}},+ )+ self.assertEqual(-32602, resp["error"]["code"])+ self.assertIn("format", resp["error"]["message"])+ resp = rpc(+ "tools/call",+ {+ "name": "views",+ "arguments": {"input": "m.json", "output": "o.drawio", "direction": "up"},+ },+ )+ self.assertEqual(-32602, resp["error"]["code"])++ def test_arguments_must_be_an_object(self):+ resp = rpc("tools/call", {"name": "doctor", "arguments": []})+ self.assertEqual(-32602, resp["error"]["code"])++ def test_unknown_tool_stays_distinct(self):+ resp = rpc("tools/call", {"name": "bogus", "arguments": {"source": "x"}})+ self.assertEqual(-32602, resp["error"]["code"])+ self.assertIn("unknown tool", resp["error"]["message"])+++class TestMcpExitCodeMapping(unittest.TestCase):+ """A nonzero diagramctl exit must surface as isError; exit 1 is a+ contract failure or a strict-warning failure, not success."""++ @staticmethod+ def _write(td, name, payload):+ path = Path(td) / name+ path.write_text(json.dumps(payload), encoding="utf-8")+ return path++ @staticmethod+ def _clean_model():+ return {+ "nodes": [+ {"id": "api", "label": "API", "kind": "service"},+ {"id": "orders", "label": "Orders", "kind": "service"},+ ],+ "edges": [+ {"id": "e1", "source": "api", "target": "orders", "label": "HTTP"}+ ],+ }++ def test_contract_failure_exit_one_reports_iserror(self):+ with tempfile.TemporaryDirectory() as td:+ graph = self._write(+ td,+ "violating.json",+ {+ "nodes": [+ {"id": "internet", "label": "Internet", "kind": "external"},+ {"id": "db", "label": "Orders DB", "kind": "database"},+ ],+ "edges": [+ {"id": "e1", "source": "internet", "target": "db", "label": "SQL"}+ ],+ },+ )+ resp = rpc(+ "tools/call",+ {"name": "architecture_test", "arguments": {"input": str(graph)}},+ )+ result = resp["result"]+ self.assertTrue(result["isError"])+ report = json.loads(result["content"][0]["text"])+ self.assertEqual(1, report["errors"])++ def test_clean_run_exit_zero_is_not_error(self):+ with tempfile.TemporaryDirectory() as td:+ graph = self._write(td, "clean.json", self._clean_model())+ resp = rpc(+ "tools/call",+ {"name": "architecture_test", "arguments": {"input": str(graph)}},+ )+ result = resp["result"]+ self.assertFalse(result["isError"])+ self.assertEqual(0, json.loads(result["content"][0]["text"])["errors"])++ def test_strict_warning_exit_one_reports_iserror(self):+ graph = self._clean_model()+ graph["nodes"].append({"id": "lonely", "label": "Lonely", "kind": "service"})+ with tempfile.TemporaryDirectory() as td:+ path = self._write(td, "warning.json", graph)+ resp = rpc(+ "tools/call",+ {"name": "architecture_test", "arguments": {"input": str(path)}},+ )+ result = resp["result"]+ self.assertFalse(result["isError"])+ self.assertEqual(1, json.loads(result["content"][0]["text"])["warnings"])+ resp = rpc(+ "tools/call",+ {+ "name": "architecture_test",+ "arguments": {"input": str(path), "strict": True},+ },+ )+ result = resp["result"]+ self.assertTrue(result["isError"])+ report = json.loads(result["content"][0]["text"])+ self.assertEqual(0, report["errors"])+ self.assertEqual(1, report["warnings"])++class TestMcpStdioProcess(unittest.TestCase):def test_end_to_end_stdio(self):msgs = [@@ -160,6 +381,53 @@ class TestMcpStdioProcess(unittest.TestCase):self.assertEqual(lines[0]["result"]["serverInfo"]["name"], "drawio-skill")self.assertIn("tools", lines[1]["result"])+ def test_malformed_requests_do_not_stop_the_server(self):+ msgs = [+ "[]",+ "null",+ json.dumps({"jsonrpc": "1.0", "id": 1, "method": "ping"}),+ json.dumps({"jsonrpc": "2.0", "id": 2, "method": 5, "params": {}}),+ json.dumps({"jsonrpc": "2.0", "id": 3, "method": "ping", "params": []}),+ {"jsonrpc": "2.0", "method": "notifications/initialized"},+ # notifications (no id) with invalid params: silent+ json.dumps({"jsonrpc": "2.0", "method": "ping", "params": []}),+ {+ "jsonrpc": "2.0",+ "method": "tools/call",+ "params": {"name": "build", "arguments": {}},+ },+ # invalid id shape: rejected with a null id, never echoed+ json.dumps({"jsonrpc": "2.0", "id": [4], "method": "ping"}),+ {+ "jsonrpc": "2.0",+ "id": 4,+ "method": "tools/call",+ "params": {"name": "build", "arguments": {}},+ },+ {"jsonrpc": "2.0", "id": 5, "method": "ping"},+ ]+ payload = "\n".join(+ m if isinstance(m, str) else json.dumps(m) for m in msgs+ ) + "\n"+ proc = subprocess.run(+ [sys.executable, str(SCRIPTS / "diagramctl_mcp.py")],+ input=payload,+ capture_output=True,+ text=True,+ timeout=60,+ )+ self.assertEqual(0, proc.returncode, proc.stderr)+ self.assertNotIn("Traceback", proc.stderr)+ lines = [json.loads(line) for line in proc.stdout.splitlines() if line.strip()]+ self.assertEqual(+ [-32600, -32600, -32600, -32600, -32602, -32600, -32602, None],+ [line.get("error", {}).get("code") for line in lines],+ )+ self.assertEqual(+ [None, None, 1, 2, 3, None, 4, 5], [line["id"] for line in lines]+ )+ self.assertEqual({}, lines[-1]["result"])+if __name__ == "__main__":unittest.main()diff --git a/tests/test_skill_metadata.py b/tests/test_skill_metadata.pyindex e9cceee..5bbbb8b 100644--- a/tests/test_skill_metadata.py+++ b/tests/test_skill_metadata.py@@ -20,7 +20,7 @@ class TestSkillMetadata(unittest.TestCase):assert metadata_match is not Nonemetadata = json.loads(metadata_match.group(1))- self.assertEqual("3.4.0", metadata.get("version"))+ self.assertEqual("3.4.1", metadata.get("version"))self.assertEqual("https://github.com/Agents365-ai/drawio-skill", metadata.get("homepage"))