Commit478bb694Recorded22 Jun 2026Repositorysigil-mcp

Guard request dispatch so malformed calls error instead of hanging the client

Message

A tool call that fails during tool lookup or schema validation (before the inner handler guard) escaped uncaught and produced no JSON-RPC response, so a live stdio client hung forever waiting for a reply. Wrap the whole request branch of mcp-server-handle-message in a guard that returns make-error-response on any error. Bump 0.16.0 -> 0.16.1.

Changed
 package.sgl              |  2 +-
 src/sigil/mcp/server.sgl | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)
Diff
package.sglmodified
@@ -7,7 +7,7 @@
7
8
(package
9
name: "sigil-mcp"
10
version: "0.16.0"
+10
version: "0.16.1"
11
sigil: "^0.16"
12
description: "Library for building MCP servers in Sigil"
13
url: "https://codeberg.org/sigil/sigil-mcp"
src/sigil/mcp/server.sglmodified
@@ -361,6 +361,17 @@
361
(let ((method (jsonrpc-request-method msg))
362
(params (or (jsonrpc-request-params msg) '()))
363
(id (jsonrpc-request-id msg)))
+364
;; Guard the entire request dispatch so any error during tool
+365
;; lookup, schema validation, or handler execution still returns a
+366
;; JSON-RPC error response. Without this, an uncaught error escapes
+367
;; the read loop and a live client hangs forever waiting for a reply.
+368
(guard (e (else
+369
(let ((err-msg (guard (fe (else "unknown error"))
+370
(format-exception e))))
+371
(guard (le (else #f))
+372
(log-error "request dispatch failed" id: id error: err-msg))
+373
(make-error-response id error-internal
+374
(format "Internal error: ~a" err-msg)))))
375
(log-debug "request" method: method id: id)
376
(cond
377
((equal? method "initialize")
@@ -385,7 +396,7 @@
396
(else
397
(log-warn "Unknown method" method: method)
398
(make-error-response id error-method-not-found
388
(format "Unknown method: ~a" method))))))
+399
(format "Unknown method: ~a" method)))))))
400
((jsonrpc-notification? msg)
401
;; Handle notifications (no response expected)
402
(let ((method (jsonrpc-notification-method msg)))