From eb7bacc2436a7cb018238f16c7da7d00a360caaf Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Fri, 31 Jul 2026 11:32:46 +0200 Subject: [PATCH] ollie-remote: fix empty output and wire generic tool dispatch Shell results were returned as raw strings but the agent expects structured content blocks ({content:[{type:text,text:...}]}). Fixed shell handler to return the same format as the local Server.CallTool. Shell errors now return as isError content blocks rather than RPC errors, matching local behavior (output is preserved in errors). The default RPC handler now dispatches to srv.CallTool() for any unknown method, enabling named tools (file_read, file_grep, etc.) from the embedded tools to be called remotely. --- cmd/ollie-remote/main.go | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/cmd/ollie-remote/main.go b/cmd/ollie-remote/main.go index 6eae78b..304e57b 100644 --- a/cmd/ollie-remote/main.go +++ b/cmd/ollie-remote/main.go @@ -167,13 +167,18 @@ func serveRPC(ctx context.Context, srv *toolsrv.Server, in io.Reader, out io.Wri enc.Encode(rpcResponse{ JSONRPC: "2.0", ID: req.ID, - Error: &rpcError{Code: -32000, Message: err.Error()}, + Result: map[string]any{ + "isError": true, + "content": []map[string]string{{"type": "text", "text": err.Error()}}, + }, }) } else { enc.Encode(rpcResponse{ JSONRPC: "2.0", ID: req.ID, - Result: result, + Result: map[string]any{ + "content": []map[string]string{{"type": "text", "text": result}}, + }, }) } @@ -213,11 +218,27 @@ func serveRPC(ctx context.Context, srv *toolsrv.Server, in io.Reader, out io.Wri }) default: - enc.Encode(rpcResponse{ - JSONRPC: "2.0", - ID: req.ID, - Error: &rpcError{Code: -32601, Message: "method not found: " + req.Method}, + // Dispatch to named tool via the tool server's CallTool. + streamCtx := toolsrv.WithOutputStream(ctx, func(data string) { + enc.Encode(rpcResponse{ + JSONRPC: "2.0", + Result: outputNotif{Data: data}, + }) }) + result, err := srv.CallTool(streamCtx, req.Method, req.Params) + if err != nil { + enc.Encode(rpcResponse{ + JSONRPC: "2.0", + ID: req.ID, + Error: &rpcError{Code: -32000, Message: err.Error()}, + }) + } else { + enc.Encode(rpcResponse{ + JSONRPC: "2.0", + ID: req.ID, + Result: json.RawMessage(result), + }) + } } } }