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), + }) + } } } }